]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
taint/module: remove unnecessary taint_flag.module field
authorPetr Pavlu <petr.pavlu@suse.com>
Wed, 22 Oct 2025 08:28:04 +0000 (10:28 +0200)
committerAndrew Morton <akpm@linux-foundation.org>
Wed, 12 Nov 2025 18:00:15 +0000 (10:00 -0800)
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>
include/linux/panic.h
kernel/module/main.c
kernel/panic.c

index 6f972a66c13ee7803ab1c7ec57a352e859de3c07..a00bc0937698c4bca3aa95b75c2458bc70094bf4 100644 (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 */
 };
 
index c66b261849362abb58cd9c52a59cc95ac44ed0c5..6f219751df7e97de0e4bbdcfccc0c17631064302 100644 (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;
        }
 
index ec59cade1f83f7786dba924c5ed97ec3154cf3fd..ffceb6f13935f1d996e13b55e303f6d16bf8977c 100644 (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