Skip to content

Commit 2852ca7

Browse files
sulixshuahkh
authored andcommitted
panic: Taint kernel if tests are run
Most in-kernel tests (such as KUnit tests) are not supposed to run on production systems: they may do deliberately illegal things to trigger errors, and have security implications (for example, KUnit assertions will often deliberately leak kernel addresses). Add a new taint type, TAINT_TEST to signal that a test has been run. This will be printed as 'N' (originally for kuNit, as every other sensible letter was taken.) This should discourage people from running these tests on production systems, and to make it easier to tell if tests have been run accidentally (by loading the wrong configuration, etc.) Acked-by: Luis Chamberlain <[email protected]> Reviewed-by: Brendan Higgins <[email protected]> Signed-off-by: David Gow <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
1 parent f2906aa commit 2852ca7

File tree

3 files changed

+4
-1
lines changed

3 files changed

+4
-1
lines changed

Documentation/admin-guide/tainted-kernels.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ Bit Log Number Reason that got the kernel tainted
100100
15 _/K 32768 kernel has been live patched
101101
16 _/X 65536 auxiliary taint, defined for and used by distros
102102
17 _/T 131072 kernel was built with the struct randomization plugin
103+
18 _/N 262144 an in-kernel test has been run
103104
=== === ====== ========================================================
104105

105106
Note: The character ``_`` is representing a blank in this table to make reading

include/linux/panic.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ static inline void set_arch_panic_timeout(int timeout, int arch_default_timeout)
6868
#define TAINT_LIVEPATCH 15
6969
#define TAINT_AUX 16
7070
#define TAINT_RANDSTRUCT 17
71-
#define TAINT_FLAGS_COUNT 18
71+
#define TAINT_TEST 18
72+
#define TAINT_FLAGS_COUNT 19
7273
#define TAINT_FLAGS_MAX ((1UL << TAINT_FLAGS_COUNT) - 1)
7374

7475
struct taint_flag {

kernel/panic.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,7 @@ const struct taint_flag taint_flags[TAINT_FLAGS_COUNT] = {
428428
[ TAINT_LIVEPATCH ] = { 'K', ' ', true },
429429
[ TAINT_AUX ] = { 'X', ' ', true },
430430
[ TAINT_RANDSTRUCT ] = { 'T', ' ', true },
431+
[ TAINT_TEST ] = { 'N', ' ', true },
431432
};
432433

433434
/**

0 commit comments

Comments
 (0)