Skip to contentSkip to conversation

CVE-2024-39480: kdb: Fix buffer overflow during tab-complete

DISCUSSION Greg Kroah-Hartman 1 participant 1 message Jul 5, 2024

lore
Share & tools
lore
#0 lore raw

Description
===========

In the Linux kernel, the following vulnerability has been resolved:

kdb: Fix buffer overflow during tab-complete

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.

The Linux kernel CVE team has assigned CVE-2024-39480 to this issue.

Affected and fixed versions
===========================

	Fixed in 4.19.316 with commit fb824a99e148
	Fixed in 5.4.278 with commit ddd2972d8e2d
	Fixed in 5.10.219 with commit cfdc2fa4db57
	Fixed in 5.15.161 with commit f636a40834d2
	Fixed in 6.1.94 with commit 33d9c814652b
	Fixed in 6.6.34 with commit 107e825cc448
	Fixed in 6.9.5 with commit f694da720dcf
	Fixed in 6.10-rc1 with commit e9730744bf3a

Please see https://www.kernel.org for a full list of currently supported kernel versions by the kernel community.

Unaffected versions might change over time as fixes are backported to older supported kernel versions. The official CVE entry at

	https://cve.org/CVERecord/?id=CVE-2024-39480

will be updated if fixes are backported, please check that for the most up to date information about this issue.

Affected files
==============

The file(s) affected by this issue are:
kernel/debug/kdb/kdb_io.c

Mitigation
==========

The Linux kernel CVE team recommends that you update to the latest stable kernel version for this, and many other bugfixes. Individual changes are never tested alone, but rather are part of a larger kernel release. Cherry-picking individual commits is not recommended or supported by the Linux kernel community at all. If however, updating to the latest release is impossible, the individual changes to resolve this issue can be found at these commits:

	https://git.kernel.org/stable/c/fb824a99e148ff272a53d71d84122728b5f00992
	https://git.kernel.org/stable/c/ddd2972d8e2dee3b33e8121669d55def59f0be8a
	https://git.kernel.org/stable/c/cfdc2fa4db57503bc6d3817240547c8ddc55fa96
	https://git.kernel.org/stable/c/f636a40834d22e5e3fc748f060211879c056cd33
	https://git.kernel.org/stable/c/33d9c814652b971461d1e30bead6792851c209e7
	https://git.kernel.org/stable/c/107e825cc448b7834b31e8b1b3cf0f57426d46d5
	https://git.kernel.org/stable/c/f694da720dcf795dc3eb97bf76d220213f76aaa7
	https://git.kernel.org/stable/c/e9730744bf3af04cda23799029342aa3cddbc454