Re: [PATCH] kdb: use sizeof(kdb_prompt_str) instead of mismatched CMD_BUFLEN

From: Doug Anderson

Date: Tue Jun 16 2026 - 18:07:01 EST


Hi,

On Tue, Jun 16, 2026 at 1:20 PM David Laight
<david.laight.linux@xxxxxxxxx> wrote:
>
> On Tue, 16 Jun 2026 22:14:54 +0530
> Naveen Kumar Chaudhary <naveen.osdev@xxxxxxxxx> 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).

For some history, see commit ad99b5105c08 ("kdb: Censor attempts to
set PROMPT without ENABLE_MEM_READ").

I have no idea how truly useful it is to be able to mess with your
prompt like this to begin with, but at least the "safety" of it has
been considered a little.

-Doug