Look up another CVE · open CVE-2024-50217 in the interactive tracker
CVE-2024-50217
btrfs: fix use-after-free of block device file in __btrfs_free_extra_devids()
Published 2024-11-09 (23 months ago) by the Linux kernel CNA. Subsystem fs/btrfs. Debian urgency: not yet assigned.
What to do, per Debian release
Debian's own status for CVE-2024-50217 in every release this site tracks, and what each one means in practice. Every status below is the one the Debian Security Team publishes for this CVE. source
| Release | Status | Version | What this means |
|---|---|---|---|
| Debian 12bookworm | vulnerable | 6.1.190-1 | No fix published anywhere yet, neither in Debian nor upstream for the series bookworm tracks. Watch the Debian tracker page for this CVE. Advisories for bookworm have historically landed a median of 23 days after publication. |
| Debian 13trixie | fixed | 6.11.7-1 | Update the kernel and reboot. Fixed in 6.11.7-1. A running kernel keeps the old code until the machine restarts. |
| Debian 14forky | fixed | 6.11.7-1 | Update the kernel and reboot. Fixed in 6.11.7-1. A running kernel keeps the old code until the machine restarts. |
| Debian unstablesid | fixed | 6.11.7-1 | Update the kernel and reboot. Fixed in 6.11.7-1. A running kernel keeps the old code until the machine restarts. |
The vulnerability
What the bug is
Mounting btrfs from two images (which have the same one fsid and two different dev_uuids) in certain executing order may trigger an UAF for variable 'device->bdev_file' in __btrfs_free_extra_devids(). And following are the details: 1. Attach image_1 to loop0, attach image_2 to loop1, and scan btrfs devices by ioctl(BTRFS_IOC_SCAN_DEV): / btrfs_device_1 → loop0 fs_device \ btrfs_device_2 → loop1 2. mount /dev/loop0 /mnt btrfs_open_devices btrfs_device_1->bdev_file = btrfs_get_bdev_and_sb(loop0) btrfs_device_2->bdev_file = btrfs_get_bdev_and_sb(loop1) btrfs_fill_super open_ctree fail: btrfs_close_devices // -ENOMEM btrfs_close_bdev(btrfs_device_1) fput(btrfs_device_1->bdev_file) // btrfs_device_1->bdev_file is freed btrfs_close_bdev(btrfs_device_2) fput(btrfs_device_2->bdev_file) 3. mount /dev/loop1 /mnt btrfs_open_devices btrfs_get_bdev_and_sb(&bdev_file) // EIO, btrfs_device_1->bdev_file is not assigned, // which points to a freed memory area btrfs_device_2->bdev_file = btrfs_get_bdev_and_sb(loop1) btrfs_fill_super open_ctree btrfs_free_extra_devids if (btrfs_device_1->bdev_file) fput(btrfs_device_1->bdev_file) // UAF ! Fix it by setting 'device->bdev_file' as 'NULL' after closing the btrfs_device in btrfs_close_one_device().
Where it lives
The fix touches these files. If the subsystem is one you do not use, the practical exposure is lower, though the package is still the vulnerable one.
fs/btrfs/volumes.c
- What this is
- BTRFS FILE SYSTEMMAINTAINERS section matched on fs/btrfs/ · linux-btrfs@vger.kernel.org · Maintained
- Kernel module
- btrfs
Check it on the machine
grep -w CONFIG_BTRFS_FS /boot/config-$(uname -r)Reads the booted kernel's own configuration, on the machine and nowhere else. =y is built in, =m is a module, and an is not set line means the code is not there.
lsmod | grep -w btrfsPrints a line if that module is loaded right now, and nothing if it is not. One that is not loaded can still be loaded later by anything that needs it.
Show whether Debian builds this, per release
Debian builds this as a loadable module. Every release below compiles it as a module on every flavour, so whether the code is in the running kernel depends on whether that module is loaded.
- bookworm, trixie, forky, sidm
- m
- a loadable module on every flavour - check lsmod, can be blacklisted
- Build switch
- CONFIG_BTRFS_FS
From the configuration Debian publishes for every kernel flavour it builds. It covers only the architectures Debian ships a linux-config package for, and nothing about a kernel you built yourself. Debian's own status above stays authoritative about the source package.MAINTAINERS kbuild Makefiles Debian linux-config packages
Signals
- Published
- 2024-11-09 (23 months ago)source
- CVSS
- 7.8 high
CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:Hsource recompute it - Attack vector
- local (AV:L)source
- EPSS
- 0.28%, higher than 18.9% of all CVEssource
- CISA KEV
- not listedthe KEV catalogue
- Debian urgency
- not yet assignedsource
- Subsystem
- fs/btrfs
Upstream fixes
The versions the CNA records as introducing and fixing this, and the commit for each. source
| Introduced | Fixed in | Commit |
|---|---|---|
| 4.8 | 6.11.7 | 47a83f8df395 |
| 4.8 | 6.12 | aec8e6bf8391 |
Why the CNA scored it this way
Quoted from the kernel CNA's own scoring file, word for word. A highlighted metric carries the most severe value CVSS v3.1 defines for it, which is what pushes the score up. source
- AV:LAttack vector, local
- The vulnerability is reached only through local block-device operations — `mount(2)` of a btrfs volume plus device registration via `BTRFS_IOC_SCAN_DEV`/`device=` — on a locally attached device or loop-mounted image. No network or remote-peer data is involved.
- AC:LAttack complexity, low
- The attacker fully controls both filesystem images and the order of the two mounts; the first mount's `open_ctree()` failure can be forced deterministically by corrupting the superblock/chunk tree rather than relying on the ENOMEM fault injection in the report, and no race must be won. Heap grooming of the `filp` slab between the two mounts is entirely under attacker control.
- PR:NPrivileges required, none
- The attacker supplies only the malicious images (USB stick, disk image file, or loop-backed file) and needs no account or privilege on the target system; the privileged mount is performed by the victim or by an automounter such as udisks2 on the attacker's behalf.
- UI:RUser interaction, required
- Exploitation requires the victim (or an automount daemon acting for a logged-in user) to mount the attacker's crafted btrfs images, twice in sequence, since btrfs lacks `FS_USERNS_MOUNT` and cannot be mounted directly by an unprivileged attacker.
- S:UScope, unchanged
- The corruption and its consequences are confined to the kernel of the same system; no VM, IOMMU, or sandbox boundary is crossed.
- C:HConfidentiality impact, high
- The stray `fput()` on a freed `struct file` in a `SLAB_TYPESAFE_BY_RCU` cache causes a live file's refcount to be dropped, yielding a reusable use-after-free object that can be leveraged for arbitrary kernel memory disclosure.
- I:HIntegrity impact, high
- The same reference-count underflow gives a premature-free UAF on `struct file`, a well-established primitive for heap spraying, arbitrary write, and control-flow hijack leading to privilege escalation.
- A:HAvailability impact, high
- Even without full exploitation the `fput()` on freed memory corrupts the slab and reliably produces a KASAN splat, refcount BUG, or kernel panic, taking the system down.