CVE-2026-23181 Overview
A race condition vulnerability exists in the Linux kernel's btrfs file system implementation. When a user performs a btrfs mount operation, the block device is not set correctly, leading to potential null pointer dereference and memory corruption issues. The vulnerability arises from improper synchronization between the BLKBSZSET command execution and the cache page read operations, allowing inconsistent block size or mapping flags to affect folio allocation.
Critical Impact
This vulnerability can cause a kernel null pointer dereference in create_empty_buffers() due to buffer head allocation failure, potentially leading to system crashes or denial of service conditions on affected Linux systems.
Affected Products
- Linux kernel with btrfs file system support
- Systems using block devices with configurable block sizes
- Linux distributions with kernel versions containing the vulnerable code path
Discovery Timeline
- 2026-02-14 - CVE CVE-2026-23181 published to NVD
- 2026-02-18 - Last updated in NVD database
Technical Details for CVE-2026-23181
Vulnerability Analysis
This vulnerability stems from a race condition in the btrfs disk superblock read operation. The core issue involves a timing discrepancy between folio (memory page) allocation and block size changes on the underlying block device.
When do_read_cache_folio() allocates a folio before the BLKBSZSET command is executed, the folio is created with an order value of 0 (corresponding to the default block size of 0x1000). Subsequently, if BLKBSZSET changes the block size to 0x4000, the mapping_min_folio_order() calculation returns 2 instead of 0, creating a mismatch between the allocated folio and the expected minimum folio order.
This inconsistency manifests in two critical failure modes: first, it triggers a VM_BUG_ON_FOLIO assertion when filemap_add_folio() detects that the folio order is less than the mapping minimum; second, it causes a null pointer dereference in create_empty_buffers() at fs/buffer.c:1694 due to failed buffer head allocation.
Root Cause
The root cause is the lack of proper synchronization based on the inode between the BLKBSZSET ioctl command and the read cache page operation. The block size change modifies mapping->flags, which directly affects the mapping_min_folio_order() calculation. Without synchronization, a folio can be allocated with parameters inconsistent with the current mapping configuration, leading to assertion failures or null pointer dereferences in the buffer management code path.
Attack Vector
The vulnerability can be triggered through the following sequence:
- A user initiates a btrfs mount operation on a block device
- Before the mount operation completes reading the disk superblock, the user executes the BLKBSZSET ioctl command to change the block size from 0x1000 to 0x4000
- The do_read_cache_folio() function allocates a folio with order 0 before the block size change
- After BLKBSZSET execution, mapping_min_folio_order() returns 2
- The mismatch causes either a VM_BUG_ON_FOLIO assertion or a null pointer dereference in create_empty_buffers()
The vulnerable code path flows through: btrfs_read_disk_super() → read_cache_page_gfp() → do_read_cache_folio() → filemap_read_folio() → block_read_full_folio() → folio_create_buffers() → create_empty_buffers().
Detection Methods for CVE-2026-23181
Indicators of Compromise
- Kernel panic messages referencing create_empty_buffers+0x4d/0x480 at fs/buffer.c:1694
- KASAN reports indicating null pointer dereference in the range 0x0000000000000000-0x0000000000000007
- VM_BUG_ON_FOLIO assertions in filemap_add_folio() related to folio order mismatches
- System crashes during btrfs mount operations, particularly when concurrent block device configuration changes occur
Detection Strategies
- Monitor kernel logs for KASAN: null-ptr-deref messages originating from buffer management functions
- Implement auditd rules to track BLKBSZSET ioctl calls on block devices with btrfs file systems
- Configure crash dump analysis to identify kernel panics with call traces involving btrfs_read_disk_super and create_empty_buffers
Monitoring Recommendations
- Enable KASAN (Kernel Address Sanitizer) in development and testing environments to detect early signs of exploitation
- Set up kernel log monitoring for VM_BUG_ON assertions related to folio operations
- Monitor for unusual patterns of BLKBSZSET ioctl calls coinciding with btrfs mount operations
How to Mitigate CVE-2026-23181
Immediate Actions Required
- Apply the official kernel patch that establishes synchronization based on the inode between BLKBSZSET commands and read cache page operations
- Restrict access to block device ioctl commands for non-privileged users
- Avoid concurrent block device configuration changes during btrfs mount operations
Patch Information
The Linux kernel maintainers have released patches to address this vulnerability. The fix establishes proper synchronization between block size changes and folio allocation operations to prevent inconsistencies in mapping flags.
Official patch commits are available:
System administrators should update to a patched kernel version from their distribution's security repository.
Workarounds
- Restrict access to the BLKBSZSET ioctl by limiting block device permissions to trusted administrators only
- Serialize btrfs mount operations to prevent concurrent block device configuration changes
- Consider using mandatory access controls (SELinux/AppArmor) to restrict ioctl operations on block devices during mount operations
# Configuration example
# Restrict block device access to root only
chmod 600 /dev/sd*
# Monitor for BLKBSZSET ioctl calls using auditd
auditctl -a always,exit -F arch=b64 -S ioctl -F a1=0x1269 -k blkbszset_monitor
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

