Re: [PATCH] kernel/panic: increase buffer size for verbose taint logging

From: Andrew Morton

Date: Fri Feb 20 2026 - 16:07:12 EST


On Fri, 20 Feb 2026 20:45:00 +0530 Rio <rioo.tsukatsukii@xxxxxxxxx> wrote:

> The verbose 'Tainted: ...' string in print_tainted_seq
> can total to 327 characters while the buffer defined in
> _print_tainted is 320 bytes. Increase its size to 350
> characters to hold all flags, along with some headroom.
>
> ...
>
> --- a/kernel/panic.c
> +++ b/kernel/panic.c
> @@ -854,10 +854,12 @@ static void print_tainted_seq(struct seq_buf *s, bool verbose)
> }
> }
>
> +/* 350 can accomadate all taint flags in verbose mode, with some headroom */

"accommodate". I'll fix this.

> +#define TAINT_BUF_MAX 350
> +
> static const char *_print_tainted(bool verbose)
> {
> - /* FIXME: what should the size be? */
> - static char buf[sizeof(taint_flags)];

Well that was weird.

> + static char buf[TAINT_BUF_MAX];

Can you think of a way to do this more flexibly? Something which
scales as we add more flags?

Probably not, as it's dependent upon the length of the various
taint_flags.desc strings.


> struct seq_buf s;
>
> BUILD_BUG_ON(ARRAY_SIZE(taint_flags) != TAINT_FLAGS_COUNT);

How does this look?

--- a/kernel/panic.c~kernel-panic-increase-buffer-size-for-verbose-taint-logging-fix
+++ a/kernel/panic.c
@@ -801,6 +801,8 @@ EXPORT_SYMBOL(panic);
* Documentation/admin-guide/tainted-kernels.rst, including its
* small shell script that prints the TAINT_FLAGS_COUNT bits of
* /proc/sys/kernel/tainted.
+ *
+ * Also, update TAINT_BUF_MAX below.
*/
const struct taint_flag taint_flags[TAINT_FLAGS_COUNT] = {
TAINT_FLAG(PROPRIETARY_MODULE, 'P', 'G'),
@@ -854,7 +856,7 @@ static void print_tainted_seq(struct seq
}
}

-/* 350 can accomadate all taint flags in verbose mode, with some headroom */
+/* 350 can accommodate all taint flags in verbose mode, with some headroom */
#define TAINT_BUF_MAX 350

static const char *_print_tainted(bool verbose)
_