taint: Add TAINT_FWCTL
authorJason Gunthorpe <jgg@nvidia.com>
Fri, 28 Feb 2025 00:26:32 +0000 (20:26 -0400)
committerJason Gunthorpe <jgg@nvidia.com>
Thu, 6 Mar 2025 19:13:13 +0000 (15:13 -0400)
Requesting a fwctl scope of access that includes mutating device debug
data will cause the kernel to be tainted. Changing the device operation
through things in the debug scope may cause the device to malfunction in
undefined ways. This should be reflected in the TAINT flags to help any
debuggers understand that something has been done.

Link: https://patch.msgid.link/r/4-v5-642aa0c94070+4447f-fwctl_jgg@nvidia.com
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Reviewed-by: Shannon Nelson <shannon.nelson@amd.com>
Tested-by: Dave Jiang <dave.jiang@intel.com>
Tested-by: Shannon Nelson <shannon.nelson@amd.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Documentation/admin-guide/tainted-kernels.rst
include/linux/panic.h
kernel/panic.c
tools/debugging/kernel-chktaint

index 700aa72eecb16941847cd7a2afea2f79db536e4e..a0cc017e44246f7f87ca26cc8aecc2c2eab0c116 100644 (file)
@@ -101,6 +101,7 @@ Bit  Log  Number  Reason that got the kernel tainted
  16  _/X   65536  auxiliary taint, defined for and used by distros
  17  _/T  131072  kernel was built with the struct randomization plugin
  18  _/N  262144  an in-kernel test has been run
+ 19  _/J  524288  userspace used a mutating debug operation in fwctl
 ===  ===  ======  ========================================================
 
 Note: The character ``_`` is representing a blank in this table to make reading
@@ -184,3 +185,7 @@ More detailed explanation for tainting
      build time.
 
  18) ``N`` if an in-kernel test, such as a KUnit test, has been run.
+
+ 19) ``J`` if userpace opened /dev/fwctl/* and performed a FWTCL_RPC_DEBUG_WRITE
+     to use the devices debugging features. Device debugging features could
+     cause the device to malfunction in undefined ways.
index 54d90b6c5f47bd6978654b3f61261943a37e2052..2494d51707ef422dfe191e484c0676e428a2de09 100644 (file)
@@ -74,7 +74,8 @@ static inline void set_arch_panic_timeout(int timeout, int arch_default_timeout)
 #define TAINT_AUX                      16
 #define TAINT_RANDSTRUCT               17
 #define TAINT_TEST                     18
-#define TAINT_FLAGS_COUNT              19
+#define TAINT_FWCTL                    19
+#define TAINT_FLAGS_COUNT              20
 #define TAINT_FLAGS_MAX                        ((1UL << TAINT_FLAGS_COUNT) - 1)
 
 struct taint_flag {
index d8635d5cecb2505da1c08a4f70814e9b87ac3b37..0c55eec9e8744a573472c02544048f8cb4249516 100644 (file)
@@ -511,6 +511,7 @@ const struct taint_flag taint_flags[TAINT_FLAGS_COUNT] = {
        TAINT_FLAG(AUX,                         'X', ' ', true),
        TAINT_FLAG(RANDSTRUCT,                  'T', ' ', true),
        TAINT_FLAG(TEST,                        'N', ' ', true),
+       TAINT_FLAG(FWCTL,                       'J', ' ', true),
 };
 
 #undef TAINT_FLAG
index 279be06332be990754490662ee00fa4257cecbda..e7da0909d09707c0a9b057c0a940772f57ed17eb 100755 (executable)
@@ -204,6 +204,14 @@ else
        echo " * an in-kernel test (such as a KUnit test) has been run (#18)"
 fi
 
+T=`expr $T / 2`
+if [ `expr $T % 2` -eq 0 ]; then
+       addout " "
+else
+       addout "J"
+       echo " * fwctl's mutating debug interface was used (#19)"
+fi
+
 echo "For a more detailed explanation of the various taint flags see"
 echo " Documentation/admin-guide/tainted-kernels.rst in the Linux kernel sources"
 echo " or https://kernel.org/doc/html/latest/admin-guide/tainted-kernels.html"