CVE-2025-71159 Overview
A use-after-free vulnerability has been identified in the Linux kernel's Btrfs file system implementation, specifically within the btrfs_get_or_create_delayed_node() function. This race condition vulnerability occurs due to improper memory ordering when setting reference counts for delayed nodes, potentially allowing another thread to access memory that hasn't been properly initialized.
The vulnerability was introduced by commit e8513c012de7 ("btrfs: implement ref_tracker for delayed_nodes"), which moved the refcount_set operation inside the critical section. This change removed the implicit memory barrier that previously existed between setting the refcount and setting btrfs_inode->delayed_node, creating a window for exploitation.
Critical Impact
Race condition in Btrfs delayed node handling can lead to use-after-free conditions, potentially causing system instability or kernel memory corruption.
Affected Products
- Linux Kernel with Btrfs file system support
- Systems running kernels with commit e8513c012de7 applied
- Linux distributions using affected kernel versions
Discovery Timeline
- 2026-01-23 - CVE CVE-2025-71159 published to NVD
- 2026-01-26 - Last updated in NVD database
Technical Details for CVE-2025-71159
Vulnerability Analysis
This vulnerability represents a classic race condition pattern in kernel code where memory visibility ordering between threads becomes critical. The btrfs_get_or_create_delayed_node() function is responsible for managing delayed node structures used in Btrfs's delayed inode update mechanism.
When a delayed node is created, the function must initialize the node's reference count and associate it with the corresponding btrfs_inode structure. Prior to the problematic commit, these operations were ordered such that the reference count was set before acquiring the root->delayed_nodes lock, providing an implicit memory barrier through the lock acquisition.
After the commit e8513c012de7, the refcount_set call was moved inside the critical section. This seemingly innocuous change removed the memory barrier that guaranteed proper ordering of store operations. As a result, from the perspective of another CPU, the store to btrfs_inode->delayed_node could become visible before the store to node->refs, even though they appear in the opposite order in the source code.
Root Cause
The root cause is a missing memory barrier between setting the delayed node's reference count and publishing the pointer to that node via btrfs_inode->delayed_node. Without proper synchronization, the CPU and compiler are free to reorder these store operations. When another thread observes the published pointer and attempts to increment the reference count, it may encounter an uninitialized value, triggering a refcounting bug.
The fix restores the original behavior by moving refcount_set back outside the critical section, leveraging the implicit memory barrier provided by the subsequent lock acquisition. An additional benefit of this fix is that memory allocations can now use GFP_NOFS instead of GFP_ATOMIC since they occur outside the locked region.
Attack Vector
The attack vector requires local access to a system with a Btrfs file system mounted. An attacker would need to trigger concurrent operations on delayed nodes, potentially through rapid file system operations that cause multiple threads to access the same inode's delayed node simultaneously.
While exploitation of this vulnerability would be complex due to the tight timing requirements, successful exploitation could lead to kernel memory corruption, denial of service through system crashes, or potentially privilege escalation if an attacker can control the freed memory contents.
The vulnerability manifests in the memory ordering of reference count initialization and pointer publication. When a racing thread reads the delayed_node pointer before the reference count is properly initialized, it attempts to increment an invalid refcount value. This can cause the kernel's reference counting subsystem to detect the inconsistency and trigger a use-after-free warning. See the kernel git commits for the complete fix implementation.
Detection Methods for CVE-2025-71159
Indicators of Compromise
- Kernel warning messages containing "use-after-free" related to Btrfs delayed nodes
- System crashes or kernel panics during heavy Btrfs file system operations
- Unexpected Btrfs file system errors or corruption warnings in dmesg logs
- Reference counting warnings in kernel logs mentioning btrfs_get_or_create_delayed_node
Detection Strategies
- Monitor kernel logs for Btrfs-related warnings using tools like dmesg or journalctl with filters for "btrfs" and "delayed_node"
- Implement kernel log aggregation to detect patterns of memory corruption warnings
- Use kernel debugging tools like KASAN (Kernel Address Sanitizer) to detect use-after-free conditions in development and testing environments
Monitoring Recommendations
- Enable kernel logging for Btrfs subsystem and monitor for anomalous behavior patterns
- Deploy SentinelOne Singularity Platform to detect kernel-level anomalies and exploit attempts
- Implement file integrity monitoring on systems using Btrfs to detect potential corruption from exploitation
How to Mitigate CVE-2025-71159
Immediate Actions Required
- Apply the latest kernel patches from your Linux distribution that address this vulnerability
- Consider temporarily using alternative file systems (ext4, XFS) on critical systems until patches are applied
- Monitor Btrfs-mounted systems for unusual kernel warnings or crashes
- Restrict local access to systems with Btrfs file systems to trusted users only
Patch Information
The Linux kernel maintainers have released fixes for this vulnerability. The patches restore the original memory ordering by moving refcount_set back outside the critical section, ensuring proper synchronization through the implicit memory barrier provided by lock acquisition.
Relevant patches can be found in the following kernel commits:
System administrators should update to kernel versions containing these fixes through their distribution's package management system.
Workarounds
- Limit concurrent operations on Btrfs file systems where possible to reduce race condition probability
- Use file system mounting options that reduce delayed node usage if available
- Implement access controls to restrict which users can perform heavy file system operations on Btrfs volumes
# Check current kernel version for vulnerability assessment
uname -r
# Monitor for Btrfs-related kernel warnings
dmesg | grep -i "btrfs\|delayed_node\|use-after-free"
# List Btrfs file systems on the system
btrfs filesystem show
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

