The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] kdb: use sizeof(kdb_prompt_str) instead of mismatched CMD_BUFLEN
@ 2026-06-16 16:44 Naveen Kumar Chaudhary
  2026-06-16 20:20 ` David Laight
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Naveen Kumar Chaudhary @ 2026-06-16 16:44 UTC (permalink / raw)
  To: jason.wessel, danielt, dianders; +Cc: kgdb-bugreport, linux-kernel

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.

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
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2026-06-18 10:04 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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-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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox