From 8e3ac6c585333ddb093c57ccd6e3e5ce28a9d4cc Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Tue, 2 Jan 2024 12:58:54 +0100 Subject: [PATCH] Print some tainted kernel warnings on snapshot page --- drmtree/drmtree.go | 47 ++++++++++++++++++++++++++++++++++++----- public/assets/style.css | 4 ++++ public/snapshot.html | 12 +++++++++++ 3 files changed, 58 insertions(+), 5 deletions(-) diff --git a/drmtree/drmtree.go b/drmtree/drmtree.go index 675b77e..94baa08 100644 --- a/drmtree/drmtree.go +++ b/drmtree/drmtree.go @@ -40,14 +40,51 @@ func (ver *DriverVersion) Less(other *DriverVersion) bool { return false } +// https://www.kernel.org/doc/html/latest/admin-guide/tainted-kernels.html +type Tainted uint64 + +const ( + taintedProprietary Tainted = 1 << iota + taintedModuleForceLoaded + taintedOutOfSpecSystem + taintedModuleForceUnloaded + taintedMCE + taintedBadPage + taintedUserspace + taintedOops + taintedACPIOverridden + taintedWarn + taintedStagingDriver + taintedWorkaround + taintedExternalModule + taintedUnsignedModule + taintedSoftLockup + taintedLivePatched + taintedAuxiliary + taintedStructRandomization + taintedInKernelTestRan +) + +func (t Tainted) Proprietary() bool { + return t&taintedProprietary != 0 +} + +func (t Tainted) StagingDriver() bool { + return t&taintedStagingDriver != 0 +} + +func (t Tainted) ExternalModule() bool { + return t&taintedExternalModule != 0 +} + type Kernel struct { - SysName string `json:"sysname"` - Release string `json:"release"` - Version string `json:"version"` - Tainted *uint64 `json:"tainted"` + SysName string `json:"sysname"` + Release string `json:"release"` + Version string `json:"version"` + Tainted *Tainted `json:"tainted"` } -func (k Kernel) String() string { +func (k *Kernel) String() string { if k.SysName == "" { return "unknown kernel" } diff --git a/public/assets/style.css b/public/assets/style.css index ff3b896..19dcdf7 100644 --- a/public/assets/style.css +++ b/public/assets/style.css @@ -153,3 +153,7 @@ dd.muted { text-decoration: none; color: white; } + +.warning { + color: red; +} diff --git a/public/snapshot.html b/public/snapshot.html index 481cd88..6c75f24 100644 --- a/public/snapshot.html +++ b/public/snapshot.html @@ -127,6 +127,18 @@ {{end}} +{{with .Node.Driver.Kernel.Tainted}} + {{if .Proprietary}} +

⚠ This snapshot was captured with a proprietary driver loaded.

+ {{end}} + {{if .StagingDriver}} +

⚠ This snapshot was captured with a staging driver loaded.

+ {{end}} + {{if .ExternalModule}} +

⚠ This snapshot was captured with an external module loaded.

+ {{end}} +{{end}} + {{with .Node}}