Skip to content

Commit 4f41d30

Browse files
tititiou36Daniel Thompson
authored andcommitted
kdb: Fix a potential buffer overflow in kdb_local()
When appending "[defcmd]" to 'kdb_prompt_str', the size of the string already in the buffer should be taken into account. An option could be to switch from strncat() to strlcat() which does the correct test to avoid such an overflow. However, this actually looks as dead code, because 'defcmd_in_progress' can't be true here. See a more detailed explanation at [1]. [1]: https://lore.kernel.org/all/CAD=FV=WSh7wKN7Yp-3wWiDgX4E3isQ8uh0LCzTmd1v9Cg9j+nQ@mail.gmail.com/ Fixes: 5d5314d ("kdb: core for kgdb back end (1 of 2)") Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> Reviewed-by: Douglas Anderson <dianders@chromium.org>
1 parent 610a9b8 commit 4f41d30

File tree

1 file changed

+0
-2
lines changed

1 file changed

+0
-2
lines changed

kernel/debug/kdb/kdb_main.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1348,8 +1348,6 @@ static int kdb_local(kdb_reason_t reason, int error, struct pt_regs *regs,
13481348
/* PROMPT can only be set if we have MEM_READ permission. */
13491349
snprintf(kdb_prompt_str, CMD_BUFLEN, kdbgetenv("PROMPT"),
13501350
raw_smp_processor_id());
1351-
if (defcmd_in_progress)
1352-
strncat(kdb_prompt_str, "[defcmd]", CMD_BUFLEN);
13531351

13541352
/*
13551353
* Fetch command from keyboard

0 commit comments

Comments
 (0)