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 <atomlin@xxxxxxxxxx> --- kernel.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/kernel.c b/kernel.c index 1310f98..553849c 100644 --- a/kernel.c +++ b/kernel.c @@ -5482,6 +5482,24 @@ cmd_sys(void) } while (args[optind]); } +static int +is_kernel_tainted(void) +{ + ulong tainted_mask; + int tainted; + + if (kernel_symbol_exists("tainted")) { + get_symbol_data("tainted", sizeof(int), &tainted); + if (tainted) + return TRUE; + } else if (kernel_symbol_exists("tainted_mask")) { + get_symbol_data("tainted_mask", sizeof(ulong), &tainted_mask); + if (tainted_mask) + return TRUE; + } + return FALSE; +} + static int is_livepatch(void) { -- 2.31.1 -- Crash-utility mailing list Crash-utility@xxxxxxxxxx https://listman.redhat.com/mailman/listinfo/crash-utility