CVE-2024-50118: btrfs: reject ro->rw reconfiguration if there are hard ro requirements

Published Nov 5, 2024
·
Updated

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

btrfs: reject ro->rw reconfiguration if there are hard ro requirements

[BUG] Syzbot reports the following crash:

BTRFS info (device loop0 state MCS): disabling free space tree BTRFS info (device loop0 state MCS): clearing compat-ro feature flag for FREESPACETREE (0x1) BTRFS info (device loop0 state MCS): clearing compat-ro feature flag for FREESPACETREEVALID (0x2) Oops: general protection fault, probably for non-canonical address 0xdffffc0000000003: 0000 [#1] PREEMPT SMP KASAN NOPTI KASAN: null-ptr-deref in range [0x0000000000000018-0x000000000000001f] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2~bpo12+1 04/01/2014 RIP: 0010:backupsuperroots fs/btrfs/disk-io.c:1691 [inline] RIP: 0010:writeallsupers+0x97a/0x40f0 fs/btrfs/disk-io.c:4041 Call Trace: <TASK> btrfscommittransaction+0x1eae/0x3740 fs/btrfs/transaction.c:2530 btrfsdeletefreespacetree+0x383/0x730 fs/btrfs/free-space-tree.c:1312 btrfsstartprerwmount+0xf28/0x1300 fs/btrfs/disk-io.c:3012 btrfsremountrw fs/btrfs/super.c:1309 [inline] btrfsreconfigure+0xae6/0x2d40 fs/btrfs/super.c:1534 btrfsreconfigureformount fs/btrfs/super.c:2020 [inline] btrfsgettreesubvol fs/btrfs/super.c:2079 [inline] btrfsgettree+0x918/0x1920 fs/btrfs/super.c:2115 vfsgettree+0x90/0x2b0 fs/super.c:1800 donewmount+0x2be/0xb40 fs/namespace.c:3472 domount fs/namespace.c:3812 [inline] dosysmount fs/namespace.c:4020 [inline] sesysmount+0x2d6/0x3c0 fs/namespace.c:3997 dosyscallx64 arch/x86/entry/common.c:52 [inline] dosyscall64+0xf3/0x230 arch/x86/entry/common.c:83 entrySYSCALL64afterhwframe+0x77/0x7f

[CAUSE] To support mounting different subvolume with different RO/RW flags for the new mount APIs, btrfs introduced two workaround to support this feature:

- Skip mount option/feature checks if we are mounting a different subvolume

- Reconfigure the fs to RW if the initial mount is RO

Combining these two, we can have the following sequence:

- Mount the fs ro,rescue=all,clearcache,spacecache=v1 rescue=all will mark the fs as hard read-only, so no v2 cache clearing will happen.

- Mount a subvolume rw of the same fs. We go into btrfsgettreesubvol(), but fcmount() returns EBUSY because our new fc is RW, different from the original fs.

Now we enter btrfsreconfigureformount(), which switches the RO flag first so that we can grab the existing fsinfo. Then we reconfigure the fs to RW.

- During reconfiguration, option/features check is skipped This means we will restart the v2 cache clearing, and convert back to v1 cache. This will trigger fs writes, and since the original fs has "rescue=all" option, it skips the csum tree read.

And eventually causing NULL pointer dereference in super block writeback.

[FIX] For reconfiguration caused by different subvolume RO/RW flags, ensure we always run btrfscheckoptions() to ensure we have proper hard RO requirements met.

In fact the function btrfscheckoptions() doesn't really do many complex checks, but hard RO requirement and some feature dependency checks, thus there is no special reason not to do the check for mount reconfiguration.

Affected Software

6 affected componentsFixes available
Linux Linux kernel>=6.8<6.11.6
Linux Linux kernel=6.12-rc1
Linux Linux kernel=6.12-rc2
Linux Linux kernel=6.12-rc3
Linux Linux kernel=6.12-rc4
debian/linux
5.10.223-15.10.234-16.1.129-16.1.135-16.12.22-16.12.25-1

Event History

Nov 5, 2024
CVE Published
via MITRE·05:10 PM
Data Sourced
via MITRE·05:10 PM
Description
Data Sourced
via NVD·06:15 PM
RemedyDescriptionSeverityWeaknessAffected Software
Apr 29, 2025
Data Sourced
via Ubuntu·01:03 AM
RemedyDescriptionSeverityAffected 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-50118?

CVE-2024-50118 is classified as a moderate severity vulnerability in the Linux kernel.

2

How do I fix CVE-2024-50118?

To fix CVE-2024-50118, you should upgrade to Linux kernel versions 6.12 or later, or ensure that versions below 6.11.6 are patched.

3

What systems are affected by CVE-2024-50118?

CVE-2024-50118 affects Linux kernel versions from 6.8 up to 6.11.6 and the release candidates for version 6.12.

4

What is the impact of CVE-2024-50118?

CVE-2024-50118 can cause a crash in the btrfs filesystem when changing read-only to read-write states under certain conditions.

5

Is CVE-2024-50118 publicly known?

Yes, CVE-2024-50118 is publicly known and reported, allowing users to take action to mitigate the vulnerability.

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