Skip to content

Commit 64f48ee

Browse files
Aaron Tomlinlian-bo
authored andcommitted
kernel: Introduce is_kernel_tainted()
Provide a quick way to test if the given Linux kernel is "tainted". Support for Linux-2.6.12 and above, to date. Signed-off-by: Aaron Tomlin <[email protected]>
1 parent bfa596f commit 64f48ee

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

kernel.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5483,6 +5483,24 @@ cmd_sys(void)
54835483
} while (args[optind]);
54845484
}
54855485

5486+
static int
5487+
is_kernel_tainted(void)
5488+
{
5489+
ulong tainted_mask;
5490+
int tainted;
5491+
5492+
if (kernel_symbol_exists("tainted")) {
5493+
get_symbol_data("tainted", sizeof(int), &tainted);
5494+
if (tainted)
5495+
return TRUE;
5496+
} else if (kernel_symbol_exists("tainted_mask")) {
5497+
get_symbol_data("tainted_mask", sizeof(ulong), &tainted_mask);
5498+
if (tainted_mask)
5499+
return TRUE;
5500+
}
5501+
return FALSE;
5502+
}
5503+
54865504
static int
54875505
is_livepatch(void)
54885506
{

0 commit comments

Comments
 (0)