Skip to contentSkip to conversation

CVE-2024-39482: bcache: fix variable length array abuse in btree_iter

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:

bcache: fix variable length array abuse in btree_iter

btree_iter is used in two ways: either allocated on the stack with a fixed size MAX_BSETS, or from a mempool with a dynamic size based on the specific cache set. Previously, the struct had a fixed-length array of size MAX_BSETS which was indexed out-of-bounds for the dynamically-sized iterators, which causes UBSAN to complain.

This patch uses the same approach as in bcachefs's sort_iter and splits the iterator into a btree_iter with a flexible array member and a btree_iter_stack which embeds a btree_iter as well as a fixed-length data array.

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

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

	Fixed in 6.1.94 with commit 934e1e433185
	Fixed in 6.6.34 with commit 6479b9f41583
	Fixed in 6.9.5 with commit 0c31344e22dd
	Fixed in 6.10-rc1 with commit 3a861560ccb3

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-39482

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:
drivers/md/bcache/bset.c
drivers/md/bcache/bset.h
drivers/md/bcache/btree.c
drivers/md/bcache/super.c
drivers/md/bcache/sysfs.c
drivers/md/bcache/writeback.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/934e1e4331859183a861f396d7dfaf33cb5afb02
	https://git.kernel.org/stable/c/6479b9f41583b013041943c4602e1ad61cec8148
	https://git.kernel.org/stable/c/0c31344e22dd8d6b1394c6e4c41d639015bdc671
	https://git.kernel.org/stable/c/3a861560ccb35f2a4f0a4b8207fa7c2a35fc7f31