Skip to content

Commit bc4f2f5

Browse files
keestorvalds
authored andcommitted
taint: add taint for randstruct
Since the randstruct plugin can intentionally produce extremely unusual kernel structure layouts (even performance pathological ones), some maintainers want to be able to trivially determine if an Oops is coming from a randstruct-built kernel, so as to keep their sanity when debugging. This adds the new flag and initializes taint_mask immediately when built with randstruct. Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Kees Cook <[email protected]> Reviewed-by: Andrew Morton <[email protected]> Cc: Al Viro <[email protected]> Cc: Alexey Dobriyan <[email protected]> Cc: Jonathan Corbet <[email protected]> Cc: Randy Dunlap <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 9c4560e commit bc4f2f5

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

Documentation/sysctl/kernel.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -991,6 +991,7 @@ ORed together. The letters are seen in "Tainted" line of Oops reports.
991991
16384 (L): A soft lockup has previously occurred on the system.
992992
32768 (K): The kernel has been live patched.
993993
65536 (X): Auxiliary taint, defined and used by for distros.
994+
131072 (T): The kernel was built with the struct randomization plugin.
994995

995996
==============================================================
996997

include/linux/kernel.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,8 @@ extern enum system_states {
562562
#define TAINT_SOFTLOCKUP 14
563563
#define TAINT_LIVEPATCH 15
564564
#define TAINT_AUX 16
565-
#define TAINT_FLAGS_COUNT 17
565+
#define TAINT_RANDSTRUCT 17
566+
#define TAINT_FLAGS_COUNT 18
566567

567568
struct taint_flag {
568569
char c_true; /* character printed when tainted */

kernel/panic.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@
3434
#define PANIC_BLINK_SPD 18
3535

3636
int panic_on_oops = CONFIG_PANIC_ON_OOPS_VALUE;
37-
static unsigned long tainted_mask;
37+
static unsigned long tainted_mask =
38+
IS_ENABLED(CONFIG_GCC_PLUGIN_RANDSTRUCT) ? (1 << TAINT_RANDSTRUCT) : 0;
3839
static int pause_on_oops;
3940
static int pause_on_oops_flag;
4041
static DEFINE_SPINLOCK(pause_on_oops_lock);
@@ -325,6 +326,7 @@ const struct taint_flag taint_flags[TAINT_FLAGS_COUNT] = {
325326
[ TAINT_SOFTLOCKUP ] = { 'L', ' ', false },
326327
[ TAINT_LIVEPATCH ] = { 'K', ' ', true },
327328
[ TAINT_AUX ] = { 'X', ' ', true },
329+
[ TAINT_RANDSTRUCT ] = { 'T', ' ', true },
328330
};
329331

330332
/**

0 commit comments

Comments
 (0)