Skip to main content

CVE-2024-26616: Vulnerability in Linux Linux

High
VulnerabilityCVE-2024-26616cvecve-2024-26616
Published: Thu Feb 29 2024 (02/29/2024, 15:52:19 UTC)
Source: CVE
Vendor/Project: Linux
Product: Linux

Description

In the Linux kernel, the following vulnerability has been resolved: btrfs: scrub: avoid use-after-free when chunk length is not 64K aligned [BUG] There is a bug report that, on a ext4-converted btrfs, scrub leads to various problems, including: - "unable to find chunk map" errors BTRFS info (device vdb): scrub: started on devid 1 BTRFS critical (device vdb): unable to find chunk map for logical 2214744064 length 4096 BTRFS critical (device vdb): unable to find chunk map for logical 2214744064 length 45056 This would lead to unrepariable errors. - Use-after-free KASAN reports: ================================================================== BUG: KASAN: slab-use-after-free in __blk_rq_map_sg+0x18f/0x7c0 Read of size 8 at addr ffff8881013c9040 by task btrfs/909 CPU: 0 PID: 909 Comm: btrfs Not tainted 6.7.0-x64v3-dbg #11 c50636e9419a8354555555245df535e380563b2b Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 2023.11-2 12/24/2023 Call Trace: <TASK> dump_stack_lvl+0x43/0x60 print_report+0xcf/0x640 kasan_report+0xa6/0xd0 __blk_rq_map_sg+0x18f/0x7c0 virtblk_prep_rq.isra.0+0x215/0x6a0 [virtio_blk 19a65eeee9ae6fcf02edfad39bb9ddee07dcdaff] virtio_queue_rqs+0xc4/0x310 [virtio_blk 19a65eeee9ae6fcf02edfad39bb9ddee07dcdaff] blk_mq_flush_plug_list.part.0+0x780/0x860 __blk_flush_plug+0x1ba/0x220 blk_finish_plug+0x3b/0x60 submit_initial_group_read+0x10a/0x290 [btrfs e57987a360bed82fe8756dcd3e0de5406ccfe965] flush_scrub_stripes+0x38e/0x430 [btrfs e57987a360bed82fe8756dcd3e0de5406ccfe965] scrub_stripe+0x82a/0xae0 [btrfs e57987a360bed82fe8756dcd3e0de5406ccfe965] scrub_chunk+0x178/0x200 [btrfs e57987a360bed82fe8756dcd3e0de5406ccfe965] scrub_enumerate_chunks+0x4bc/0xa30 [btrfs e57987a360bed82fe8756dcd3e0de5406ccfe965] btrfs_scrub_dev+0x398/0x810 [btrfs e57987a360bed82fe8756dcd3e0de5406ccfe965] btrfs_ioctl+0x4b9/0x3020 [btrfs e57987a360bed82fe8756dcd3e0de5406ccfe965] __x64_sys_ioctl+0xbd/0x100 do_syscall_64+0x5d/0xe0 entry_SYSCALL_64_after_hwframe+0x63/0x6b RIP: 0033:0x7f47e5e0952b - Crash, mostly due to above use-after-free [CAUSE] The converted fs has the following data chunk layout: item 2 key (FIRST_CHUNK_TREE CHUNK_ITEM 2214658048) itemoff 16025 itemsize 80 length 86016 owner 2 stripe_len 65536 type DATA|single For above logical bytenr 2214744064, it's at the chunk end (2214658048 + 86016 = 2214744064). This means btrfs_submit_bio() would split the bio, and trigger endio function for both of the two halves. However scrub_submit_initial_read() would only expect the endio function to be called once, not any more. This means the first endio function would already free the bbio::bio, leaving the bvec freed, thus the 2nd endio call would lead to use-after-free. [FIX] - Make sure scrub_read_endio() only updates bits in its range Since we may read less than 64K at the end of the chunk, we should not touch the bits beyond chunk boundary. - Make sure scrub_submit_initial_read() only to read the chunk range This is done by calculating the real number of sectors we need to read, and add sector-by-sector to the bio. Thankfully the scrub read repair path won't need extra fixes: - scrub_stripe_submit_repair_read() With above fixes, we won't update error bit for range beyond chunk, thus scrub_stripe_submit_repair_read() should never submit any read beyond the chunk.

AI-Powered Analysis

AILast updated: 06/29/2025, 21:13:25 UTC

Technical Analysis

CVE-2024-26616 is a vulnerability in the Linux kernel's Btrfs filesystem scrub functionality. The issue arises specifically when a Btrfs filesystem has been converted from ext4 and contains data chunks whose lengths are not aligned to the expected 64KB boundary. During a scrub operation, which is intended to verify and repair filesystem integrity, the kernel attempts to read these chunks. However, due to the misalignment, the bio (block I/O) submitted for reading is split into two halves, each triggering an end I/O (endio) callback. The scrub code incorrectly assumes only a single endio call per bio, leading to a use-after-free condition when the first endio frees the bio and the second endio attempts to access already freed memory. This results in kernel memory corruption, reported by Kernel Address Sanitizer (KASAN) as slab-use-after-free, and can cause system crashes or unrecoverable filesystem errors such as "unable to find chunk map" errors. The root cause is that scrub_read_endio() updates bits beyond the chunk boundary and scrub_submit_initial_read() does not correctly limit the read range to the chunk size. The fix involves ensuring that scrub_read_endio() only updates bits within the chunk range and that scrub_submit_initial_read() calculates and submits bio requests strictly within chunk boundaries. This prevents the double endio calls on the same bio and eliminates the use-after-free condition. The vulnerability affects Linux kernel versions containing the vulnerable Btrfs scrub implementation prior to the fix, notably kernel version 6.7.0-x64v3-dbg as referenced in the report. There are no known exploits in the wild at this time, and no CVSS score has been assigned yet.

Potential Impact

For European organizations, the impact of this vulnerability can be significant, especially for those relying on Btrfs filesystems on Linux servers for critical data storage and integrity verification. The use-after-free bug can lead to kernel crashes (denial of service), potential data corruption, and unrecoverable filesystem errors during scrub operations. This can disrupt services, cause data loss, and require time-consuming recovery efforts. Organizations using Btrfs on converted ext4 filesystems are particularly at risk. Since the vulnerability is triggered during scrub operations, which are often scheduled for routine maintenance or data integrity checks, the risk of unexpected downtime increases. Additionally, if attackers gain local access, they might be able to trigger the vulnerability to cause denial of service or potentially escalate privileges by exploiting kernel memory corruption, although no direct exploit is known yet. The vulnerability affects confidentiality, integrity, and availability by risking data corruption and system stability. Given the widespread use of Linux in European data centers, cloud providers, and enterprise environments, the vulnerability poses a moderate to high operational risk if unpatched.

Mitigation Recommendations

European organizations should take the following specific mitigation steps: 1) Identify Linux systems using Btrfs filesystems, especially those converted from ext4, and verify kernel versions for vulnerability. 2) Apply the official Linux kernel patches that fix CVE-2024-26616 as soon as they become available, or upgrade to a fixed kernel version. 3) Temporarily disable or avoid running Btrfs scrub operations on affected systems until patches are applied to prevent triggering the use-after-free. 4) Implement monitoring for kernel crash logs and KASAN reports related to Btrfs scrub to detect potential exploitation or triggering of the vulnerability. 5) For critical systems, consider filesystem backups and recovery plans to mitigate data loss risk from potential corruption. 6) Limit local user access to systems running vulnerable kernels to reduce risk of intentional triggering. 7) Coordinate with Linux distribution vendors for timely patch deployment and security advisories. These targeted steps go beyond generic advice by focusing on the specific conditions and operations (scrub on converted ext4 Btrfs) that trigger the vulnerability.

Need more detailed analysis?Get Pro

Technical Details

Data Version
5.1
Assigner Short Name
Linux
Date Reserved
2024-02-19T14:20:24.131Z
Cisa Enriched
true
Cvss Version
null
State
PUBLISHED

Threat ID: 682d982bc4522896dcbe41c7

Added to database: 5/21/2025, 9:08:59 AM

Last enriched: 6/29/2025, 9:13:25 PM

Last updated: 7/27/2025, 1:34:38 AM

Views: 14

Actions

PRO

Updates to AI analysis are available only with a Pro account. Contact root@offseq.com for access.

Please log in to the Console to use AI analysis features.

Need enhanced features?

Contact root@offseq.com for Pro access with improved analysis and higher rate limits.

Latest Threats