CVE-2026-142819: kgdb: Fix buffer overflow in the qRcmd packet handler
In the Linux kernel, the following vulnerability has been resolved:
kgdb: Fix buffer overflow in the qRcmd packet handler
gdbcmdquery() decodes the hex payload of a qRcmd packet (the GDB "monitor" command passthrough to kdb) into remcomoutbuffer and hands it to kdbparse(). It sizes the decode with strlen() of the payload:
int len = strlen(remcominbuffer + 6); ... kgdbhex2mem(remcominbuffer + 6, remcomoutbuffer, len); len = len / 2;
kgdbhex2mem() takes count as the number of bytes to produce and decodes them in place at buf, reading and writing 2 count bytes there. len here is the hex character count, twice the decoded size, so the decode runs over 2 len bytes at remcominbuffer + 6, off the end of the buffer. On x86 BUFMAX is 1024, so a 256-byte monitor command (512 hex characters) overruns remcominbuffer during the in-place decode:
BUG: KASAN: global-out-of-bounds in kgdbhex2mem+0x131/0x160 Read of size 1 at addr ffffffff8765ef05 by task sh/1 ... kgdbhex2mem+0x131/0x160 gdbserialstub+0x16d4/0x3170 kgdbcpuenter+0xb68/0x1520 ... The buggy address belongs to the variable: remcominbuffer+0x405/0x420
Halve len before the call so kgdbhex2mem() gets the decoded byte count. It then reads the len hex characters already in remcominbuffer and writes len / 2 bytes, all inside the buffer, and remcomoutbuffer holds the same command as before.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 5.10.275 - Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 5.15.226 - Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 6.1.193 - Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 6.6.163 - Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 6.12.117 - Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 6.18.63 - Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 7.3.4 - Upgrade
Upgrade
debian/linuxto a version that resolves this vulnerability.Fixed in 6.12.117-1 - Upgrade
Upgrade
debian/linuxto a version that resolves this vulnerability.Fixed in 7.3.4-1 - Upgrade
Upgrade
debian/linuxto a version that resolves this vulnerability.Fixed in 6.12.117-1Fixed in 7.3.4-1 - Compensating control
In gdb_cmd_query(), halve len (len = len / 2) before calling kgdb_hex2mem(), so it receives the decoded byte count.
Event History
Frequently Asked Questions
What access does an attacker need to trigger this issue?
The attacker needs to send a GDB remote qRcmd packet, which carries a GDB "monitor" command that kgdb passes through to kdb. Systems are exposed where that kgdb debugging interface is reachable by the attacker.
What input size is known to cause the overflow?
On x86, where BUFMAX is 1024, a 256-byte monitor command encoded as 512 hexadecimal characters overruns remcom_in_buffer during decoding. The flawed handler passes the hexadecimal character count as a decoded-byte count, causing kgdb_hex2mem() to process too much input.
How can I identify a likely occurrence on an affected system?
A KASAN-enabled kernel may report a global-out-of-bounds read in kgdb_hex2mem(), with the stack including gdb_serial_stub and kgdb_cpu_enter. The report may identify remcom_in_buffer as the overrun buffer.
What should be verified in a fix?
Verify that the qRcmd handler halves the hexadecimal payload length before calling kgdb_hex2mem(), so the function receives the number of decoded bytes rather than the number of hex characters. The listed stable-kernel references contain fixes for this issue.