CVE-2024-35949: btrfs: make sure that WRITTEN is set on all metadata blocks

Published May 20, 2024
·
Updated

In the Linux kernel, the following vulnerability has been resolved:

btrfs: make sure that WRITTEN is set on all metadata blocks

We previously would call btrfscheckleaf() if we had the check integrity code enabled, which meant that we could only run the extended leaf checks if we had WRITTEN set on the header flags.

This leaves a gap in our checking, because we could end up with corruption on disk where WRITTEN isn't set on the leaf, and then the extended leaf checks don't get run which we rely on to validate all of the item pointers to make sure we don't access memory outside of the extent buffer.

However, since 732fab95abe2 ("btrfs: check-integrity: remove CONFIGBTRFSFSCHECKINTEGRITY option") we no longer call btrfscheckleaf() from btrfsmarkbufferdirty(), which means we only ever call it on blocks that are being written out, and thus have WRITTEN set, or that are being read in, which should have WRITTEN set.

Add checks to make sure we have WRITTEN set appropriately, and then make sure btrfscheckleaf() always does the item checking. This will protect us from file systems that have been corrupted and no longer have WRITTEN set on some of the blocks.

This was hit on a crafted image tweaking the WRITTEN bit and reported by KASAN as out-of-bound access in the eb accessors. The example is a dir item at the end of an eb.

[2.042] BTRFS warning (device loop1): bad eb member start: ptr 0x3fff start 30572544 member offset 16410 size 2 [2.040] general protection fault, probably for non-canonical address 0xe0009d1000000003: 0000 [#1] PREEMPT SMP KASAN NOPTI [2.537] KASAN: maybe wild-memory-access in range [0x0005088000000018-0x000508800000001f] [2.729] CPU: 0 PID: 2587 Comm: mount Not tainted 6.8.2 #1 [2.729] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.15.0-1 04/01/2014 [2.621] RIP: 0010:btrfsget16+0x34b/0x6d0 [2.621] RSP: 0018:ffff88810871fab8 EFLAGS: 00000206 [2.621] RAX: 0000a11000000003 RBX: ffff888104ff8720 RCX: ffff88811b2288c0 [2.621] RDX: dffffc0000000000 RSI: ffffffff81dd8aca RDI: ffff88810871f748 [2.621] RBP: 000000000000401a R08: 0000000000000001 R09: ffffed10210e3ee9 [2.621] R10: ffff88810871f74f R11: 205d323430333737 R12: 000000000000001a [2.621] R13: 000508800000001a R14: 1ffff110210e3f5d R15: ffffffff850011e8 [2.621] FS: 00007f56ea275840(0000) GS:ffff88811b200000(0000) knlGS:0000000000000000 [2.621] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [2.621] CR2: 00007febd13b75c0 CR3: 000000010bb50000 CR4: 00000000000006f0 [2.621] Call Trace: [2.621] <TASK> [2.621] ? showregs+0x74/0x80 [2.621] ? dieaddr+0x46/0xc0 [2.621] ? excgeneralprotection+0x161/0x2a0 [2.621] ? asmexcgeneralprotection+0x26/0x30 [2.621] ? btrfsget16+0x33a/0x6d0 [2.621] ? btrfsget16+0x34b/0x6d0 [2.621] ? btrfsget16+0x33a/0x6d0 [2.621] ? pfxbtrfsget16+0x10/0x10 [2.621] ? pfxmutexunlock+0x10/0x10 [2.621] btrfsmatchdiritemname+0x101/0x1a0 [2.621] btrfslookupdiritem+0x1f3/0x280 [2.621] ? pfxbtrfslookupdiritem+0x10/0x10 [2.621] btrfsgettree+0xd25/0x1910

[ copy more details from report ]

Affected Software

12 affected componentsFixes available
debian/linux<=5.10.223-1, <=5.10.234-1, <=6.1.129-1, <=6.1.135-1
6.12.25-16.12.27-1
Linux Linux kernel<6.6.85
Linux Linux kernel>=6.7<6.8.10
Linux Linux kernel=6.9-rc1
Linux Linux kernel=6.9-rc2
Linux Linux kernel=6.9-rc3
Linux Linux kernel=6.9-rc4
Linux Linux kernel=6.9-rc5
Linux Linux kernel=6.9-rc6
Linux Linux kernel=6.9-rc7
Fedoraproject Fedora=40
Microsoft cbl2 kernel 5.15.186.1-1

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade debian/linux to a version that resolves this vulnerability.

    Fixed in 6.12.25-1Fixed in 6.12.27-1
  2. Upgrade

    Upgrade Linux kernel btrfs to a version that resolves this vulnerability.

    Patch 732fab95abe2
  3. Configuration

    Ensure the btrfs check-integrity code behavior matches the post-732fab95abe2 change: do not rely on CONFIG_BTRFS_FS_CHECK_INTEGRITY to call btrfs_check_leaf() during btrfs_mark_buffer_dirty(); instead, ensure the metadata leaf validation happens in __btrfs_check_leaf() regardless of call path.

    btrfs CONFIG_BTRFS_FS_CHECK_INTEGRITY = removed (no longer call btrfs_check_leaf() from btrfs_mark_buffer_dirty())

Event History

May 20, 2024
CVE Published
via MITRE·09:17 AM
Data Sourced
via MITRE·09:17 AM
DescriptionSeverity
Data Sourced
via NVD·10:15 AM
Description
Data Sourced
via NVD·10:15 AM
RemedySeverityWeaknessAffected Software
Aug 8, 2024
Data Sourced
via Launchpad·11:25 PM
Description
Apr 27, 2025
Data Sourced
via Ubuntu·12:23 AM
RemedyDescriptionSeverityAffected Software
Dec 25, 2025
Data Sourced
via Microsoft·01:01 AM
DescriptionSeverityWeaknessAffected Software
Free Weekly Intel

Don't miss critical vulnerabilities

Join thousands of security professionals who receive our weekly digest of trending CVEs, zero-days, and exploited vulnerabilities.

No spam. Unsubscribe anytime.

Frequently Asked Questions

1

What is the severity of CVE-2024-35949?

CVE-2024-35949 has been classified with a moderate severity level due to its potential impact on data integrity.

2

How do I fix CVE-2024-35949?

To fix CVE-2024-35949, update your Linux kernel to version 6.12.12-1, 6.12.15-1 or later.

3

Which Linux kernel versions are affected by CVE-2024-35949?

CVE-2024-35949 affects Linux kernel versions up to 5.10.226-1 and 6.1.128-1.

4

Is there a workaround for CVE-2024-35949?

There is no known workaround for CVE-2024-35949, applying the update is the recommended action.

5

What components are impacted by CVE-2024-35949?

CVE-2024-35949 impacts the btrfs filesystem in the Linux kernel.

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