kernel_samsung_a53x/kernel/debug/kdb
Daniel Thompson 344409aad2 kdb: Fix buffer overflow during tab-complete
commit e9730744bf3af04cda23799029342aa3cddbc454 upstream.

Currently, when the user attempts symbol completion with the Tab key, kdb
will use strncpy() to insert the completed symbol into the command buffer.
Unfortunately it passes the size of the source buffer rather than the
destination to strncpy() with predictably horrible results. Most obviously
if the command buffer is already full but cp, the cursor position, is in
the middle of the buffer, then we will write past the end of the supplied
buffer.

Fix this by replacing the dubious strncpy() calls with memmove()/memcpy()
calls plus explicit boundary checks to make sure we have enough space
before we start moving characters around.

Reported-by: Justin Stitt <justinstitt@google.com>
Closes: https://lore.kernel.org/all/CAFhGd8qESuuifuHsNjFPR-Va3P80bxrw+LqvC8deA8GziUJLpw@mail.gmail.com/
Cc: stable@vger.kernel.org
Reviewed-by: Douglas Anderson <dianders@chromium.org>
Reviewed-by: Justin Stitt <justinstitt@google.com>
Tested-by: Justin Stitt <justinstitt@google.com>
Link: https://lore.kernel.org/r/20240424-kgdb_read_refactor-v3-1-f236dbe9828d@linaro.org
Signed-off-by: Daniel Thompson <daniel.thompson@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-11-19 12:27:18 +01:00
..
kdb_bp.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
kdb_bt.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
kdb_cmds Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
kdb_debugger.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
kdb_io.c kdb: Fix buffer overflow during tab-complete 2024-11-19 12:27:18 +01:00
kdb_keyboard.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
kdb_main.c kdb: Fix a potential buffer overflow in kdb_local() 2024-11-18 12:12:51 +01:00
kdb_private.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
kdb_support.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
Makefile Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00