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 7fd8329ba5 ("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>
pull/1354/merge
Petr Pavlu 2025-10-22 10:28:04 +02:00 committed by Andrew Morton
parent ed4bbe7e8f
commit 37ade54f38
3 changed files with 22 additions and 27 deletions

View File

@ -86,7 +86,6 @@ static inline void set_arch_panic_timeout(int timeout, int arch_default_timeout)
struct taint_flag {
char c_true; /* character printed when tainted */
char c_false; /* character printed when not tainted */
bool module; /* also show as a per-module taint flag */
const char *desc; /* verbose description of the set taint flag */
};

View File

@ -954,7 +954,7 @@ size_t module_flags_taint(unsigned long taints, char *buf)
int i;
for (i = 0; i < TAINT_FLAGS_COUNT; i++) {
if (taint_flags[i].module && test_bit(i, &taints))
if (test_bit(i, &taints))
buf[l++] = taint_flags[i].c_true;
}

View File

@ -628,17 +628,13 @@ void panic(const char *fmt, ...)
}
EXPORT_SYMBOL(panic);
#define TAINT_FLAG(taint, _c_true, _c_false, _module) \
#define TAINT_FLAG(taint, _c_true, _c_false) \
[ TAINT_##taint ] = { \
.c_true = _c_true, .c_false = _c_false, \
.module = _module, \
.desc = #taint, \
}
/*
* TAINT_FORCED_RMMOD could be a per-module flag but the module
* is being removed anyway.
*
* NOTE: if you modify the taint_flags or TAINT_FLAGS_COUNT,
* please also modify tools/debugging/kernel-chktaint and
* Documentation/admin-guide/tainted-kernels.rst, including its
@ -646,26 +642,26 @@ EXPORT_SYMBOL(panic);
* /proc/sys/kernel/tainted.
*/
const struct taint_flag taint_flags[TAINT_FLAGS_COUNT] = {
TAINT_FLAG(PROPRIETARY_MODULE, 'P', 'G', true),
TAINT_FLAG(FORCED_MODULE, 'F', ' ', true),
TAINT_FLAG(CPU_OUT_OF_SPEC, 'S', ' ', false),
TAINT_FLAG(FORCED_RMMOD, 'R', ' ', false),
TAINT_FLAG(MACHINE_CHECK, 'M', ' ', false),
TAINT_FLAG(BAD_PAGE, 'B', ' ', false),
TAINT_FLAG(USER, 'U', ' ', false),
TAINT_FLAG(DIE, 'D', ' ', false),
TAINT_FLAG(OVERRIDDEN_ACPI_TABLE, 'A', ' ', false),
TAINT_FLAG(WARN, 'W', ' ', false),
TAINT_FLAG(CRAP, 'C', ' ', true),
TAINT_FLAG(FIRMWARE_WORKAROUND, 'I', ' ', false),
TAINT_FLAG(OOT_MODULE, 'O', ' ', true),
TAINT_FLAG(UNSIGNED_MODULE, 'E', ' ', true),
TAINT_FLAG(SOFTLOCKUP, 'L', ' ', false),
TAINT_FLAG(LIVEPATCH, 'K', ' ', true),
TAINT_FLAG(AUX, 'X', ' ', true),
TAINT_FLAG(RANDSTRUCT, 'T', ' ', true),
TAINT_FLAG(TEST, 'N', ' ', true),
TAINT_FLAG(FWCTL, 'J', ' ', true),
TAINT_FLAG(PROPRIETARY_MODULE, 'P', 'G'),
TAINT_FLAG(FORCED_MODULE, 'F', ' '),
TAINT_FLAG(CPU_OUT_OF_SPEC, 'S', ' '),
TAINT_FLAG(FORCED_RMMOD, 'R', ' '),
TAINT_FLAG(MACHINE_CHECK, 'M', ' '),
TAINT_FLAG(BAD_PAGE, 'B', ' '),
TAINT_FLAG(USER, 'U', ' '),
TAINT_FLAG(DIE, 'D', ' '),
TAINT_FLAG(OVERRIDDEN_ACPI_TABLE, 'A', ' '),
TAINT_FLAG(WARN, 'W', ' '),
TAINT_FLAG(CRAP, 'C', ' '),
TAINT_FLAG(FIRMWARE_WORKAROUND, 'I', ' '),
TAINT_FLAG(OOT_MODULE, 'O', ' '),
TAINT_FLAG(UNSIGNED_MODULE, 'E', ' '),
TAINT_FLAG(SOFTLOCKUP, 'L', ' '),
TAINT_FLAG(LIVEPATCH, 'K', ' '),
TAINT_FLAG(AUX, 'X', ' '),
TAINT_FLAG(RANDSTRUCT, 'T', ' '),
TAINT_FLAG(TEST, 'N', ' '),
TAINT_FLAG(FWCTL, 'J', ' '),
};
#undef TAINT_FLAG