From: David Laight <david.laight.linux@gmail.com>
To: Naveen Kumar Chaudhary <naveen.osdev@gmail.com>
Cc: jason.wessel@windriver.com, danielt@kernel.org,
dianders@chromium.org, kgdb-bugreport@lists.sourceforge.net,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] kdb: use sizeof(kdb_prompt_str) instead of mismatched CMD_BUFLEN
Date: Tue, 16 Jun 2026 21:20:29 +0100 [thread overview]
Message-ID: <20260616212029.39d35f5c@pumpkin> (raw)
In-Reply-To: <uqjlxgcu6y6ukayda7jka7ji73ctkj4f3632rejud6cqqayfwx@kuyf2f2lvett>
On Tue, 16 Jun 2026 22:14:54 +0530
Naveen Kumar Chaudhary <naveen.osdev@gmail.com> wrote:
> kdb_main.c defines CMD_BUFLEN as 200 (for command history buffers),
> while kdb_io.c defines it as 256 (for kdb_prompt_str). The snprintf()
> filling kdb_prompt_str incorrectly used the local CMD_BUFLEN (200),
> truncating the prompt unnecessarily. Use sizeof(kdb_prompt_str) to
> always match the actual buffer size.
As a matter of interest what sets the string that kdbgetenv("PROMPT")
returns?
If it is user settable, using it as a format string doesn't seem wise
(even for kdbg).
David
>
> Signed-off-by: Naveen Kumar Chaudhary <naveen.osdev@gmail.com>
> ---
> kernel/debug/kdb/kdb_main.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
> index ddce56b47b25..571e9e61b40e 100644
> --- a/kernel/debug/kdb/kdb_main.c
> +++ b/kernel/debug/kdb/kdb_main.c
> @@ -1265,8 +1265,8 @@ static int kdb_local(kdb_reason_t reason, int error, struct pt_regs *regs,
>
> do_full_getstr:
> /* PROMPT can only be set if we have MEM_READ permission. */
> - snprintf(kdb_prompt_str, CMD_BUFLEN, kdbgetenv("PROMPT"),
> - raw_smp_processor_id());
> + snprintf(kdb_prompt_str, sizeof(kdb_prompt_str),
> + kdbgetenv("PROMPT"), raw_smp_processor_id());
>
> /*
> * Fetch command from keyboard
next prev parent reply other threads:[~2026-06-16 20:20 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-16 16:44 [PATCH] kdb: use sizeof(kdb_prompt_str) instead of mismatched CMD_BUFLEN Naveen Kumar Chaudhary
2026-06-16 20:20 ` David Laight [this message]
2026-06-16 22:06 ` Doug Anderson
2026-06-16 22:04 ` Doug Anderson
2026-06-17 2:28 ` [PATCH v2] kdb: unify CMD_BUFLEN definition into kdb_private.h Naveen Kumar Chaudhary
2026-06-17 3:00 ` Naveen Kumar Chaudhary
2026-06-17 21:16 ` Doug Anderson
2026-06-18 10:04 ` David Laight
2026-06-18 16:02 ` Doug Anderson
2026-06-18 20:56 ` David Laight
2026-06-25 12:52 ` Daniel Thompson
2026-06-17 10:43 ` [PATCH] kdb: use sizeof(kdb_prompt_str) instead of mismatched CMD_BUFLEN kernel test robot
2026-06-17 19:49 ` kernel test robot
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=20260616212029.39d35f5c@pumpkin \
--to=david.laight.linux@gmail.com \
--cc=danielt@kernel.org \
--cc=dianders@chromium.org \
--cc=jason.wessel@windriver.com \
--cc=kgdb-bugreport@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=naveen.osdev@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.