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...@mail.gmail.com/

Fixes: 5d5314d6795f ("kdb: core for kgdb back end (1 of 2)")
Signed-off-by: Christophe JAILLET <christophe.jail...@wanadoo.fr>
---
Changes in v2:
   - Delete the strncat() call   [Doug Anderson]

v1: 
https://lore.kernel.org/all/0b1790ca91b71e3362a6a4c2863bc5787b4d60c9.1698501284.git.christophe.jail...@wanadoo.fr/
---
 kernel/debug/kdb/kdb_main.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
index 6b213c8252d6..d05066cb40b2 100644
--- a/kernel/debug/kdb/kdb_main.c
+++ b/kernel/debug/kdb/kdb_main.c
@@ -1348,8 +1348,6 @@ static int kdb_local(kdb_reason_t reason, int error, 
struct pt_regs *regs,
                /* PROMPT can only be set if we have MEM_READ permission. */
                snprintf(kdb_prompt_str, CMD_BUFLEN, kdbgetenv("PROMPT"),
                         raw_smp_processor_id());
-               if (defcmd_in_progress)
-                       strncat(kdb_prompt_str, "[defcmd]", CMD_BUFLEN);
 
                /*
                 * Fetch command from keyboard
-- 
2.34.1



_______________________________________________
Kgdb-bugreport mailing list
Kgdb-bugreport@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kgdb-bugreport

Reply via email to