Skip to contentSkip to conversation

CVE-2025-21879: btrfs: fix use-after-free on inode when scanning root during em shrinking

DISCUSSION Greg Kroah-Hartman 1 participant 1 message Mar 27, 2025

lore
Share & tools
lore
#0 lore raw

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

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

btrfs: fix use-after-free on inode when scanning root during em shrinking

At btrfs_scan_root() we are accessing the inode's root (and fs_info) in a call to btrfs_fs_closing() after we have scheduled the inode for a delayed iput, and that can result in a use-after-free on the inode in case the cleaner kthread does the iput before we dereference the inode in the call to btrfs_fs_closing().

Fix this by using the fs_info stored already in a local variable instead of doing inode->root->fs_info.

The Linux kernel CVE team has assigned CVE-2025-21879 to this issue.

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

	Issue introduced in 6.13 with commit 1020443840569535f6025a855958f07ea3eebf71 and fixed in 6.13.6 with commit 5e79d26014f9386387575b9ed60d342057cee49b
	Issue introduced in 6.13 with commit 1020443840569535f6025a855958f07ea3eebf71 and fixed in 6.14 with commit 59f37036bb7ab3d554c24abc856aabca01126414

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-2025-21879

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:
fs/btrfs/extent_map.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/5e79d26014f9386387575b9ed60d342057cee49b
	https://git.kernel.org/stable/c/59f37036bb7ab3d554c24abc856aabca01126414