CVE-2024-26616: btrfs: scrub: avoid use-after-free when chunk length is not 64K aligned

Published Feb 29, 2024
·
Updated

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 blkrqmapsg+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> dumpstacklvl+0x43/0x60 printreport+0xcf/0x640 kasanreport+0xa6/0xd0 blkrqmapsg+0x18f/0x7c0 virtblkpreprq.isra.0+0x215/0x6a0 [virtioblk 19a65eeee9ae6fcf02edfad39bb9ddee07dcdaff] virtioqueuerqs+0xc4/0x310 [virtioblk 19a65eeee9ae6fcf02edfad39bb9ddee07dcdaff] blkmqflushpluglist.part.0+0x780/0x860 blkflushplug+0x1ba/0x220 blkfinishplug+0x3b/0x60 submitinitialgroupread+0x10a/0x290 [btrfs e57987a360bed82fe8756dcd3e0de5406ccfe965] flushscrubstripes+0x38e/0x430 [btrfs e57987a360bed82fe8756dcd3e0de5406ccfe965] scrubstripe+0x82a/0xae0 [btrfs e57987a360bed82fe8756dcd3e0de5406ccfe965] scrubchunk+0x178/0x200 [btrfs e57987a360bed82fe8756dcd3e0de5406ccfe965] scrubenumeratechunks+0x4bc/0xa30 [btrfs e57987a360bed82fe8756dcd3e0de5406ccfe965] btrfsscrubdev+0x398/0x810 [btrfs e57987a360bed82fe8756dcd3e0de5406ccfe965] btrfsioctl+0x4b9/0x3020 [btrfs e57987a360bed82fe8756dcd3e0de5406ccfe965] x64sysioctl+0xbd/0x100 dosyscall64+0x5d/0xe0 entrySYSCALL64afterhwframe+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 (FIRSTCHUNKTREE CHUNKITEM 2214658048) itemoff 16025 itemsize 80 length 86016 owner 2 stripelen 65536 type DATA|single

For above logical bytenr 2214744064, it's at the chunk end (2214658048 + 86016 = 2214744064).

This means btrfssubmitbio() would split the bio, and trigger endio function for both of the two halves.

However scrubsubmitinitialread() 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 scrubreadendio() 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 scrubsubmitinitialread() 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:

- scrubstripesubmitrepairread() With above fixes, we won't update error bit for range beyond chunk, thus scrubstripesubmitrepairread() should never submit any read beyond the chunk.

Affected Software

4 affected componentsFixes available
Linux Linux kernel>=6.4<6.6.15
Linux Linux kernel>=6.7<6.7.3
Linux Linux kernel=6.8-rc1
debian/linux
5.10.223-15.10.234-16.1.129-16.1.135-16.12.25-1

Event History

Feb 29, 2024
CVE Published
via MITRE·03:52 PM
Data Sourced
via MITRE·03:52 PM
Description
May 11, 2024
Data Sourced
via Launchpad·04:29 PM
Description
Dec 17, 2024
Data Sourced
via Ubuntu·04:39 AM
RemedyDescriptionSeverityAffected Software
May 2, 2025
Data Sourced
via Debian·02:21 PM
DescriptionAffected Software

Frequently Asked Questions

1

What is the severity of CVE-2024-26616?

CVE-2024-26616 has a medium severity, as it involves a use-after-free vulnerability in the Linux kernel's btrfs file system.

2

How do I fix CVE-2024-26616?

To fix CVE-2024-26616, update your Linux kernel to a version that is not affected, such as 6.8-rc1 or a later version.

3

What are the affected versions for CVE-2024-26616?

CVE-2024-26616 affects Linux kernel versions from 6.4 up to 6.6.15 and certain versions up to 6.7.

4

Is CVE-2024-26616 a remote exploit?

CVE-2024-26616 is not classified as a remote exploit; it primarily affects local users exploiting btrfs scrubbing operations.

5

What problems does CVE-2024-26616 cause in the btrfs file system?

CVE-2024-26616 can lead to issues such as 'unable to find chunk map' errors and potential system instability when using the scrub feature.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203