mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Rio <rioo.tsukatsukii@gmail.com>
Cc: Feng Tang <feng.tang@linux.alibaba.com>,
	Petr Mladek <pmladek@suse.com>,
	Jinchao Wang <wangjinchao600@gmail.com>,
	Joel Granados <joel.granados@kernel.org>,
	Pnina Feder <pnina.feder@mobileye.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] kernel/panic: increase buffer size for verbose taint logging
Date: Fri, 20 Feb 2026 13:06:43 -0800	[thread overview]
Message-ID: <20260220130643.cd980ab5593e36f84fa72034@linux-foundation.org> (raw)
In-Reply-To: <20260220151500.13585-1-rioo.tsukatsukii@gmail.com>

On Fri, 20 Feb 2026 20:45:00 +0530 Rio <rioo.tsukatsukii@gmail.com> 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)
_


  reply	other threads:[~2026-02-20 21:06 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-20 15:15 Rio
2026-02-20 21:06 ` Andrew Morton [this message]
2026-02-21  6:56   ` Rio
2026-02-21 20:03     ` Andrew Morton
2026-02-22 14:08 ` [PATCHv2] kernel/panic: allocate taint string buffer dynamically Rio
2026-02-22 15:23   ` Rio
2026-02-22 19:25   ` Andrew Morton
2026-02-23  3:59   ` [PATCHv3] kernel/panic: mark init_taint_buf as __initdata and panic instead of warning in alloc_taint_buf() Rio

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260220130643.cd980ab5593e36f84fa72034@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=feng.tang@linux.alibaba.com \
    --cc=joel.granados@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pmladek@suse.com \
    --cc=pnina.feder@mobileye.com \
    --cc=rioo.tsukatsukii@gmail.com \
    --cc=wangjinchao600@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®