diff options
| author | Fang Xieyan <fangxy@xiaopeng.com> | 2026-09-22 23:49:07 +0800 |
|---|---|---|
| committer | Daniel Thompson <daniel@riscstar.com> | 2026-10-28 16:55:40 +0000 |
| commit | 13962ef7021ef2531a4f6650eca87c363e6c9c32 (patch) | |
| tree | ca87b4257c92aeb30e054a0bdfe9df96d3a49fa3 /include/linux/debugobjects.h | |
| parent | ac0159129e2cb99a70c4b80cfbf58d03e092dc7b (diff) | |
kgdb: Fix buffer overflow in the 'M' and 'X' packet handlers
write_mem_msg() passes the length claimed by an 'M' or 'X' packet directly
to kgdb_hex2mem() or kgdb_ebin2mem(). A malformed packet can claim more
data than was actually received, causing the decoders to read past
remcom_in_buffer.
Record the received payload length in get_packet() and use it to bound
the decoders. 'M' carries two hex characters per byte, while 'X' carries
one byte per output byte except that a 0x7d escape consumes an additional
input byte. Pass the packet end to kgdb_ebin2mem() so both reads are
checked against the received data.
Keep zero-length 'X' packets valid, as GDB uses them to probe binary
download support.
Fixes: dc7d55270521 ("kgdb: core")
Cc: stable@vger.kernel.org
Assisted-by: Hawkeye:GLM-5.3-flash
Assisted-by: Qoder:Qwen3.8-Max
Signed-off-by: Fang Xieyan <fangxy@xiaopeng.com>
Link: https://lore.kernel.org/r/20260922154907.90535-1-fangxy@xiaopeng.com
Signed-off-by: Daniel Thompson <daniel@riscstar.com>
Diffstat (limited to 'include/linux/debugobjects.h')
0 files changed, 0 insertions, 0 deletions
