Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.
Sources: National Vulnerability Database, CISA KEV, Exploit-DB
CVE-2026-97416 Overview
CVE-2026-97416 is a null pointer dereference vulnerability in the Linux kernel's btrfs filesystem. The flaw resides in btrfs_may_alloc_data_chunk() within fs/btrfs/volumes.c and can be triggered when running btrfs balance against a filesystem with metadata corruption. When a chunk item exists in the chunk tree without a matching block group item, btrfs_lookup_block_group() returns NULL. The code subsequently dereferences cache->flags, crashing the kernel [CWE-476]. The condition is guarded only by ASSERT(cache), which becomes a no-op when CONFIG_BTRFS_ASSERT is disabled in production kernels.
Critical Impact
A local user with privileges to run btrfs balance on a crafted or corrupted btrfs image can trigger a kernel null pointer dereference, resulting in a denial of service.
Affected Products
- Linux kernel btrfs filesystem (versions prior to the fixing commits)
- Distributions shipping affected kernels with CONFIG_BTRFS_FS enabled
- Systems where CONFIG_BTRFS_ASSERT is disabled are most exposed
Discovery Timeline
- 2026-09-24 - CVE-2026-97416 published to NVD
- 2026-09-25 - Last updated in NVD database
Technical Details for CVE-2026-97416
Vulnerability Analysis
The __btrfs_balance() function iterates the on-disk chunk tree and passes each chunk logical bytenr to btrfs_may_alloc_data_chunk() before relocating a data chunk. The helper then queries the in-memory block group cache using btrfs_lookup_block_group(fs_info, chunk_offset) and immediately reads cache->flags to determine the chunk type.
When the filesystem image is corrupted such that a chunk item exists without a corresponding block group item, no entry is inserted into the in-memory cache. The lookup returns NULL, and the subsequent dereference crashes the kernel with a KASAN report indicating a null pointer dereference in the range [0x88-0x8f].
The fix adds an explicit NULL check after btrfs_lookup_block_group() and emits an error message, replacing the ineffective ASSERT(cache) guard that provided no protection in standard production builds.
Root Cause
The root cause is missing input validation on return values from btrfs_lookup_block_group(). The code relied on a debug-only assertion rather than runtime error handling, so corrupted on-disk metadata could propagate into an unchecked pointer dereference during balance operations.
Attack Vector
Exploitation requires local access and the ability to mount a crafted btrfs image or operate on a filesystem with corrupted metadata, then invoke the btrfs balance ioctl (BTRFS_IOC_BALANCE). The call path leads from btrfs_ioctl_balance through btrfs_balance and __btrfs_balance into the vulnerable btrfs_may_alloc_data_chunk function. Successful triggering results in a kernel oops and system denial of service.
See the upstream patches for implementation details: Kernel Git Commit 18d32b0, Kernel Git Commit 59f75e0, and Kernel Git Commit 9740dd0.
Detection Methods for CVE-2026-97416
Indicators of Compromise
- Kernel oops or KASAN reports referencing btrfs_may_alloc_data_chunk+0x40 in fs/btrfs/volumes.c
- Call traces including __btrfs_balance, btrfs_balance, and btrfs_ioctl_balance preceding a crash
- Unexpected system reboots or hangs during or shortly after invoking btrfs balance
Detection Strategies
- Monitor kernel ring buffer (dmesg) and /var/log/kern.log for null pointer dereference traces originating in btrfs code paths
- Audit invocations of btrfs balance and the BTRFS_IOC_BALANCE ioctl using auditd rules on filesystem management utilities
- Flag mounts of btrfs images from untrusted sources, particularly removable media and user-supplied disk images
Monitoring Recommendations
- Enable persistent kernel crash collection with kdump to capture full stack traces for post-mortem analysis
- Track running kernel versions across the fleet and correlate against the fixing commits referenced above
- Alert on btrfs check output reporting missing or orphaned block group items, which indicates the preconditions for this bug
How to Mitigate CVE-2026-97416
Immediate Actions Required
- Apply the upstream kernel patches referenced in the vendor commits as soon as distribution packages are available
- Restrict permissions on btrfs management ioctls and avoid granting CAP_SYS_ADMIN to untrusted users
- Prohibit mounting of btrfs images originating from untrusted or unverified sources
Patch Information
The issue is resolved by adding a NULL check after btrfs_lookup_block_group() in btrfs_may_alloc_data_chunk(). Fixes are available in the following upstream commits: 18d32b0, 59f75e0, and 9740dd0. Rebuild and deploy kernels incorporating these patches, or install vendor kernel updates once released.
Workarounds
- Avoid running btrfs balance on filesystems suspected of metadata corruption; run btrfs check first and repair before balancing
- Enable CONFIG_BTRFS_ASSERT in custom-built kernels to convert the latent dereference into a controlled assertion failure during testing
- Limit which accounts can execute btrfs administrative commands by tightening sudoers rules and filesystem management RBAC
# Configuration example: verify running kernel and audit btrfs balance usage
uname -r
auditctl -w /usr/sbin/btrfs -p x -k btrfs_admin
btrfs check --readonly /dev/sdX # inspect for corruption before balancing
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.
Sources: National Vulnerability Database, CISA KEV, Exploit-DB

