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

From: Andrew Morton

Date: Sat Feb 21 2026 - 15:03:34 EST


On Sat, 21 Feb 2026 12:26:03 +0530 Rio <rioo.tsukatsukii@xxxxxxxxx> wrote:

> > "accommodate". I'll fix this.
>
> Thanks
>
> > How does this look?
>
> > + *
> > + * Also, update TAINT_BUF_MAX below.
> > */
> > ...
> > -/* 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
>
> Looks good, though it might help future maintainers if we document the current
> maximum length of the verbose string (excluding the trailing NULL). Happy to
> send a small follow-up patch if needed.

OK, how about this idea.

- Allocating static storage is annoying: dynamic allocation is better

- Now knowing how large to make the storage is also annoying.

So:

- define a static buffer, mark it __initdata so it gets released
later in boot. Make print_tainted() use that, initially, so
print_tainted() is available at initial bootup time.

- write a new __init function which adds up all string lengths in
taint_flags[] and calculates the precise maximum needed buffer size.

Allocate that much memory (kmalloc) and switch print_tainted() over
to using that buffer.

- When __init data gets released, the initial static buffer and the
new __init function get thrown away.