CVE-2025-21879 btrfs: fix use-after-free on inode when scanning root during em shrinking
A use-after-free vulnerability in the Linux kernel's btrfs filesystem allows attackers to potentially execute code or escalate privileges.
- Exploited in the wild
- Not known
- Login needed
- Any signed-in user
- Attackable
- Local or same network only
- Victim action needed
- Not needed
- Fix
- Available
What is CVE-2025-21879?
CVE-2025-21879 is a high-severity use after free vulnerability in Linux kernel, published on 27 Mar 2025. It can only be exploited from the same machine or local network, with no action from the victim.
Official 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.
Weakness: CWE-416
Which versions are affected by CVE-2025-21879?
It affects 1 product.
Products include Linux kernel.
How do I fix CVE-2025-21879?
Apply the vendor's patch.
Upgrade to the fixed version. These bugs are found with fuzzing and sanitisers and avoided by memory-safe languages. More about Use after free.
Is CVE-2025-21879 being exploited?
There is no known exploitation of CVE-2025-21879 in the wild and no public exploit code.
Other vulnerabilities in Linux kernel
Sources
Also known as BELL-CVE-2025-21879, GHSA-pwxf-vp8f-f327, UBUNTU-CVE-2025-21879.