Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

taint/module: remove unnecessary taint_flag.module field

The TAINT_RANDSTRUCT and TAINT_FWCTL flags are mistakenly set in the
taint_flags table as per-module flags. While this can be trivially
corrected, the issue can be avoided altogether by removing the
taint_flag.module field.

This is possible because, since commit 7fd8329ba502 ("taint/module: Clean
up global and module taint flags handling") in 2016, the handling of
module taint flags has been fully generic. Specifically,
module_flags_taint() can print all flags, and the required output buffer
size is properly defined in terms of TAINT_FLAGS_COUNT. The actual
per-module flags are always those added to module.taints by calls to
add_taint_module().

Link: https://lkml.kernel.org/r/20251022082938.26670-1-petr.pavlu@suse.com
Signed-off-by: Petr Pavlu <petr.pavlu@suse.com>
Acked-by: Petr Mladek <pmladek@suse.com>
Reviewed-by: Randy Dunlap <rdunlap@infradead.org>
Cc: Aaron Tomlin <atomlin@atomlin.com>
Cc: Luis Chamberalin <mcgrof@kernel.org>
Cc: Petr Pavlu <petr.pavlu@suse.com>
Cc: Sami Tolvanen <samitolvanen@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Petr Pavlu and committed by
Andrew Morton
37ade54f ed4bbe7e

+22 -27
-1
include/linux/panic.h
··· 86 86 struct taint_flag { 87 87 char c_true; /* character printed when tainted */ 88 88 char c_false; /* character printed when not tainted */ 89 - bool module; /* also show as a per-module taint flag */ 90 89 const char *desc; /* verbose description of the set taint flag */ 91 90 }; 92 91
+1 -1
kernel/module/main.c
··· 954 954 int i; 955 955 956 956 for (i = 0; i < TAINT_FLAGS_COUNT; i++) { 957 - if (taint_flags[i].module && test_bit(i, &taints)) 957 + if (test_bit(i, &taints)) 958 958 buf[l++] = taint_flags[i].c_true; 959 959 } 960 960
+21 -25
kernel/panic.c
··· 628 628 } 629 629 EXPORT_SYMBOL(panic); 630 630 631 - #define TAINT_FLAG(taint, _c_true, _c_false, _module) \ 631 + #define TAINT_FLAG(taint, _c_true, _c_false) \ 632 632 [ TAINT_##taint ] = { \ 633 633 .c_true = _c_true, .c_false = _c_false, \ 634 - .module = _module, \ 635 634 .desc = #taint, \ 636 635 } 637 636 638 637 /* 639 - * TAINT_FORCED_RMMOD could be a per-module flag but the module 640 - * is being removed anyway. 641 - * 642 638 * NOTE: if you modify the taint_flags or TAINT_FLAGS_COUNT, 643 639 * please also modify tools/debugging/kernel-chktaint and 644 640 * Documentation/admin-guide/tainted-kernels.rst, including its ··· 642 646 * /proc/sys/kernel/tainted. 643 647 */ 644 648 const struct taint_flag taint_flags[TAINT_FLAGS_COUNT] = { 645 - TAINT_FLAG(PROPRIETARY_MODULE, 'P', 'G', true), 646 - TAINT_FLAG(FORCED_MODULE, 'F', ' ', true), 647 - TAINT_FLAG(CPU_OUT_OF_SPEC, 'S', ' ', false), 648 - TAINT_FLAG(FORCED_RMMOD, 'R', ' ', false), 649 - TAINT_FLAG(MACHINE_CHECK, 'M', ' ', false), 650 - TAINT_FLAG(BAD_PAGE, 'B', ' ', false), 651 - TAINT_FLAG(USER, 'U', ' ', false), 652 - TAINT_FLAG(DIE, 'D', ' ', false), 653 - TAINT_FLAG(OVERRIDDEN_ACPI_TABLE, 'A', ' ', false), 654 - TAINT_FLAG(WARN, 'W', ' ', false), 655 - TAINT_FLAG(CRAP, 'C', ' ', true), 656 - TAINT_FLAG(FIRMWARE_WORKAROUND, 'I', ' ', false), 657 - TAINT_FLAG(OOT_MODULE, 'O', ' ', true), 658 - TAINT_FLAG(UNSIGNED_MODULE, 'E', ' ', true), 659 - TAINT_FLAG(SOFTLOCKUP, 'L', ' ', false), 660 - TAINT_FLAG(LIVEPATCH, 'K', ' ', true), 661 - TAINT_FLAG(AUX, 'X', ' ', true), 662 - TAINT_FLAG(RANDSTRUCT, 'T', ' ', true), 663 - TAINT_FLAG(TEST, 'N', ' ', true), 664 - TAINT_FLAG(FWCTL, 'J', ' ', true), 649 + TAINT_FLAG(PROPRIETARY_MODULE, 'P', 'G'), 650 + TAINT_FLAG(FORCED_MODULE, 'F', ' '), 651 + TAINT_FLAG(CPU_OUT_OF_SPEC, 'S', ' '), 652 + TAINT_FLAG(FORCED_RMMOD, 'R', ' '), 653 + TAINT_FLAG(MACHINE_CHECK, 'M', ' '), 654 + TAINT_FLAG(BAD_PAGE, 'B', ' '), 655 + TAINT_FLAG(USER, 'U', ' '), 656 + TAINT_FLAG(DIE, 'D', ' '), 657 + TAINT_FLAG(OVERRIDDEN_ACPI_TABLE, 'A', ' '), 658 + TAINT_FLAG(WARN, 'W', ' '), 659 + TAINT_FLAG(CRAP, 'C', ' '), 660 + TAINT_FLAG(FIRMWARE_WORKAROUND, 'I', ' '), 661 + TAINT_FLAG(OOT_MODULE, 'O', ' '), 662 + TAINT_FLAG(UNSIGNED_MODULE, 'E', ' '), 663 + TAINT_FLAG(SOFTLOCKUP, 'L', ' '), 664 + TAINT_FLAG(LIVEPATCH, 'K', ' '), 665 + TAINT_FLAG(AUX, 'X', ' '), 666 + TAINT_FLAG(RANDSTRUCT, 'T', ' '), 667 + TAINT_FLAG(TEST, 'N', ' '), 668 + TAINT_FLAG(FWCTL, 'J', ' '), 665 669 }; 666 670 667 671 #undef TAINT_FLAG