Skip to content

Commit 8eea4e7

Browse files
committed
taint: Add TAINT_FWCTL
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/[email protected] Reviewed-by: Jonathan Cameron <[email protected]> Reviewed-by: Dave Jiang <[email protected]> Reviewed-by: Shannon Nelson <[email protected]> Tested-by: Dave Jiang <[email protected]> Tested-by: Shannon Nelson <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent fb39e90 commit 8eea4e7

File tree

4 files changed

+16
-1
lines changed

4 files changed

+16
-1
lines changed

Documentation/admin-guide/tainted-kernels.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ Bit Log Number Reason that got the kernel tainted
101101
16 _/X 65536 auxiliary taint, defined for and used by distros
102102
17 _/T 131072 kernel was built with the struct randomization plugin
103103
18 _/N 262144 an in-kernel test has been run
104+
19 _/J 524288 userspace used a mutating debug operation in fwctl
104105
=== === ====== ========================================================
105106

106107
Note: The character ``_`` is representing a blank in this table to make reading
@@ -184,3 +185,7 @@ More detailed explanation for tainting
184185
build time.
185186

186187
18) ``N`` if an in-kernel test, such as a KUnit test, has been run.
188+
189+
19) ``J`` if userpace opened /dev/fwctl/* and performed a FWTCL_RPC_DEBUG_WRITE
190+
to use the devices debugging features. Device debugging features could
191+
cause the device to malfunction in undefined ways.

include/linux/panic.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ static inline void set_arch_panic_timeout(int timeout, int arch_default_timeout)
7474
#define TAINT_AUX 16
7575
#define TAINT_RANDSTRUCT 17
7676
#define TAINT_TEST 18
77-
#define TAINT_FLAGS_COUNT 19
77+
#define TAINT_FWCTL 19
78+
#define TAINT_FLAGS_COUNT 20
7879
#define TAINT_FLAGS_MAX ((1UL << TAINT_FLAGS_COUNT) - 1)
7980

8081
struct taint_flag {

kernel/panic.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,7 @@ const struct taint_flag taint_flags[TAINT_FLAGS_COUNT] = {
511511
TAINT_FLAG(AUX, 'X', ' ', true),
512512
TAINT_FLAG(RANDSTRUCT, 'T', ' ', true),
513513
TAINT_FLAG(TEST, 'N', ' ', true),
514+
TAINT_FLAG(FWCTL, 'J', ' ', true),
514515
};
515516

516517
#undef TAINT_FLAG

tools/debugging/kernel-chktaint

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,14 @@ else
204204
echo " * an in-kernel test (such as a KUnit test) has been run (#18)"
205205
fi
206206

207+
T=`expr $T / 2`
208+
if [ `expr $T % 2` -eq 0 ]; then
209+
addout " "
210+
else
211+
addout "J"
212+
echo " * fwctl's mutating debug interface was used (#19)"
213+
fi
214+
207215
echo "For a more detailed explanation of the various taint flags see"
208216
echo " Documentation/admin-guide/tainted-kernels.rst in the Linux kernel sources"
209217
echo " or https://kernel.org/doc/html/latest/admin-guide/tainted-kernels.html"

0 commit comments

Comments
 (0)