Linux Kernel Btrfs Subvolume Race Bug CVE-2024-23850 Fixed

  • Thread Author
A recently disclosed robustness bug in the Linux kernel’s Btrfs implementation can trigger an assertion failure and a kernel crash when a newly created subvolume is read before the filesystem has finished the final steps of subvolume creation, producing a local-denial-of-service condition that affects kernels up to and including 6.7.1 and which has been patched upstream and picked into distributor kernels.

Glowing tree-like circuitry beneath the Linux penguin, labeled anon_dev with a checkmark badge.Background / Overview​

Btrfs (B-tree filesystem) exposes subvolumes and snapshots as lightweight, filesystem-level constructs used heavily by modern Linux distributions for system snapshots, container images, and multi-tenant storage layouts. The bug tracked as CVE-2024-23850 occurs in the kernel function btrfs_get_root_ref (file fs/btrfs/disk-io.c) and manifests as an assertion failure — the kernel hits an ASSERT() that was written with an assumption that can be violated by concurrent reads. The result is an immediate kernel oops/assertion trace and crash, producing a loss of availability for the affected host.
Major vendor advisories and vulnerability databases describe the issue consistently: the problem arises because a subvolume can be "read out" (i.e., traversed or referenced) too soon after its root item is inserted during subvolume creation. If that read occurs before the kernel's subvolume-creation path completes certain assignments (notably a preallocated anonymous device number), the code triggers an assertion intended to catch an impossible state — but that state can actually occur in real workloads. Upstream maintainers fixed the bug by removing the dangerous ASSERT and handling the preallocated resource defensively.

What exactly fails: technical root cause​

The assertion and the race​

The vulnerable code path attempts to preallocate an anon_dev identifier for the new subvolume while it writes the subvolume’s root item into the metadata trees. The kernel assumed that no other execution context could see (and therefore "read out") the new subvolume before the create operation finished; an ASSERT() enforces this invariant. However, background metadata walks (for example, backref or other filesystem iterators) can cause the newly-inserted subvolume tree to be read concurrently. If that happens, the subvolume may be assigned a new anon_dev by the reader, and then when the creator later runs the ASSERT() it sees a conflicting anon_dev and crashes. In short: the code asserted an invariant that could legitimately be violated by concurrent activity.

The fix​

Upstream authors chose a minimal, robustness-first fix: remove the ASSERT and defensively free the preallocated anon_dev (resetting it) if the subvolume has already been read and assigned an identifier by another reader. This preserves correct behavior in both single-threaded and concurrent scenarios, avoids aborting the kernel on an assert, and accepts that the race can validly happen. The change is small but important: it converts a reachable kernel assertion (CWE-617, reachable assertion) into normal error-handling that keeps the system running. The commit is credited to the Btrfs maintainer team and is in the upstream kernel trees referenced by vendor patches.

Affected systems and severity​

  • Scope: Linux kernels up to and including 6.7.1 are affected; upstream patches were merged into later 6.7.x series maintenance releases and distributed as vendor patches. Distributors have published fixes or backports for their kernels.
  • Attack vector: Local (the attacker must have the ability to create subvolumes or otherwise trigger btrfs operations). Several vendor writeups classify this as an availability (DoS) risk rather than confidentiality or integrity.
  • Impact: Total loss of availability for the host (kernel crash/panic). In cloud or multi-tenant environments this can translate quickly to service disruption for containers, VMs, or shared host services. The common CVSS assessments in public databases assign a medium-severity score (typically around CVSS 5.5 in vendor entries), reflecting the local requirement and the availability-only impact.
Note: the vulnerability is a robustness/logic race issue rather than a memory-corruption or privilege-escalation bug; it cannot be used to execute arbitrary code on the kernel, as described in the vendor advisories. That said, availability-impacting kernel crashes are operationally severe and deserve rapid remediation in production environments.

Who is at risk — practical scenarios​

  • Machines running Btrfs as the host filesystem (desktop, laptop, or servers) where local users or services can create subvolumes.
  • Systems that provide delegated subvolume operations to unprivileged users via setuid helpers, containers, or weird mount options.
  • Multi-tenant hosts (container hosts, platform providers) where an attacker with a constrained local account might be able to call btrfs subvolume creation, or where untrusted code can manipulate mounted btrfs filesystems.
  • Automated test harnesses and syzbot/test-farm images that exercise filesystem code paths — those environments are likely to have reproduced this crash already during fuzzing.
Important operational detail: creating a btrfs subvolume normally requires administrative privileges or specific capability allowances (for example, many btrfs ioctl interfaces and helper library calls mention CAP_SYS_ADMIN for creation or default-subvolume operations). Some user-space workflows and specially-mounted images can allow non-root subvolume creation in limited situations, so administrators must not assume subvolume creation is impossible for ordinary users on every configuration. Tightening who can run btrfs commands is therefore a useful mitigation.

Detection and forensic indicators​

If you suspect an exploit or a crash due to this bug, look for the kernel assertion and stack trace in dmesg or system logs. Typical indicators include:
  • Kernel assertion message similar to:
  • "assertion failed: !anon_dev, in fs/btrfs/disk-io.c:1319"
  • A stack trace listing:
  • btrfs_get_root_ref
  • btrfs_get_new_fs_root
  • create_subvol / btrfs_mksubvol
  • __btrfs_ioctl_snap_create / btrfs_ioctl_snap_create
  • Crash timestamps aligned with userland btrfs subvolume creation operations (btrfs subvolume create, btrfs-progs calls, or automated snapshot tooling).
Operational detection steps:
  • Check kernel logs: dmesg | grep -i btrfs and journalctl -k for assertion traces referencing fs/btrfs/disk-io.c.
  • Correlate with user actions: audit logs or shell history showing btrfs subvolume create or snapshot tooling activity.
  • If possible, reproduce on a test host with the same kernel version (do not reproduce on production) to confirm whether the patched behavior is present.

Mitigation and remediation guidance​

The only complete mitigation is to install the vendor-supplied kernel patches or upgrade to a kernel version or vendor package that contains the upstream fix.
  • Patch or upgrade: Apply vendor kernel updates (Ubuntu, Debian, SUSE, Fedora, etc.) that include the fix. Several distributors have already issued security updates and SRU packages applying the upstream change; test and deploy them per your change-control procedures.
  • Restrict subvolume creation: Limit who can create subvolumes. Ensure only trusted administrators or service accounts have the ability to issue btrfs subvolume creation ioctls. Where feasible, avoid granting untrusted containers or users the necessary mount options or capabilities that permit subvolume creation. Note that some legitimate automation or backup tools may require elevated capabilities; review those tools before locking them down.
  • Temporary hardening: If a kernel update cannot be immediately applied, consider isolating Btrfs-mounted volumes from untrusted accounts (e.g., run services that need user subvolumes on different hosts or storage backends) or remove the setuid helpers that escalate privileges to run btrfs commands.
  • Monitoring: Add dmesg / kernel oops monitoring and alerting for Btrfs assertion strings to catch attempted triggers quickly.
Vendor-specific advice: follow your distribution’s security advisory and replace kernels only with signed, tested packages from your vendor. The upstream fix was intentionally small (removes ASSERT, frees the preallocated anon_dev) and has been backported or packaged by multiple distributors. Confirm vendor SRU/errata identifiers before roll-out.

Practical patching notes and timeline​

  • Upstream: the change was submitted to the kernel and included in the Btrfs patch set that flowed into the 6.7.x maintenance trees; maintainer lists and patchew entries show the commit listing and integration into 6.7.x review candidates.
  • Distribution SRUs/backports: Ubuntu and other distributors accepted the patch and published kernel SRUs; Ubuntu’s kernel-team logs show the cherry-pick for Mantic and Jammy series and QA/ACK notes as the fix was staged for stable releases. Operators should check their distribution’s CVE advisory and package tracker for the exact package name (kernel-image, linux-image, kernel-rt, etc.) and the SRU version.
  • Verific irm the absence of the ASSERT by monitoring for related dmesg messages and by running the previously-failing test-case in a controlled, instrumented environment where you can reproduce the subvolume creation race if required.

Risk analysis and operational recommendations​

Why this matters beyond the single crash​

A kernel assertion that crashes the whole OS is one of the simplest and yet most disruptive failure modes. In modern operations:
  • Service disruption: A single host kernel panic takes down all services running on that host — containers, virtual machines, storage-serving processes — and can cause cascading failures in clustered environments if HA controls are not tuned for unexpected node loss.
  • Multi-tenant exposure: In environments where untrusted tenants share the same kernel and storage backend (e.g., some container-as-a-service designs), a malicious or buggy tenant could repeatedly trigger subvolume creation to deny service to other tenants or the host.
  • Supply-chain confusion: Distribution attestations and mappings matter. Vendor advisories that identify specific products as "potentially affected" help administrators narrow their mitigation scope, but they do not automatically guarantee that other artifacts are unaffected. Treat vendor attestation as product-scoped inventory information, not as a universal proof of absence elsewhere. This nuance has been highlighted in vendor-security discussions in community threads and internal advisory mappings.

Practical recommendations (priority-ranked)​

  • Patch high-priority hosts first: Patch hosts that run Btrfs as a production filesystem, especially multi-tenant or container hosts.
  • Harden capability exposure: Remove unnecessary CAP_SYS_ADMIN capability from containers and processes; avoid granting system-level btrfs privileges to untrusted workloads.
  • Monitor kernel logs: Create alerts for assertion strings and large numbers of subvolume creation operations from unprivileged sources.
  • Audit automation and tooling: Ensure backup/snapshot tooling that manipulates subvolumes runs under controlled accounts and uses least privilege.
  • Test before rollout: As with all kernel updates, test patched kernels on staging hosts to ensure compatibility with custom modules, drivers, and production workloads.

What we verified and outstanding unknowns​

  • Verified facts:
  • The vulnerability exists in fs/btrfs/disk-io.c btrfs_get_root_ref, causing an assertion failure that can crash the kernel. This description and the stack trace pattern are present in public advisories and vulnerability databases.
  • The fix was to remove the ASSERT and defensively free/reset the preallocated anon_dev, avoiding the crash and allowing concurrent reads to coexist with subvolume creation. This is reflected in upstream commits and distributor SRUs.
  • Distributors (Ubuntu, Debian, SUSE, Fedora) published advisories and backports; operators should install these updates.
  • Unverified / caution flag:
  • There is no authoritative public proof-of-concept exploit in vendor advisories or NVD entries that demonstrates exploitation in the wild; the vulnerability is classed as a local DoS, and the practical exploitability depends on local privileges and environment configuration. Readers should treat the absence of public PoC as an informational gap and prioritize patching on the basis of the operational impact of a kernel crash rather than on the presence of exploit code. (No proof-of-concept was observed in the vendor advisories and major vulnerability trackers consulted during our verification.) ([nvd.nist.gov](https://nvd.nist.gov/vuln/detail/cve-2024-2icklist for system administrators
  • Confirm whether any hosts run kernels ≤ 6.7.1 and have Btrfs mounted as a used filesystem.
  • Check vendor advisories and apply the vendor-supplied kernel patch or upgrade to a patched kernel package.
  • If immediate patching is impossible:
  • Restrict who can create subvolumes (remove untrusted CAP_SYS_ADMIN capability).
  • Monitor kernel logs for the assertion and set alerts.
  • Consider isolating Btrfs-mounted workloads onto patched hosts only.
  • Validate patch effectiveness by confirming the absence of the assertion signature in kernel logs after upgrade and by running minimal, controlled subvolume creation tests on a staging host.

Final analysis — strengths and residual risks​

The upstream fix for CVE-2024-23850 is a measured, low-risk change: removing an unreachable-but-reachable ASSERT and replacing it with defensive cleanup elegantly avoids a kernel crash while preserving Btrfs functionality. That’s the correct principle for robustness fixes in kernel code: tolerate concurrency and clean up rather than aborting the entire kernel.
However, the residual operational risk remains social and organizational more than technical. Systems where untrusted code can manipulate subvolumes or where kernel upgrades are slow to roll out (long-lived appliances, embedded devices, or poorly maintained cloud images) will continue to be exposed. In addition, the way distribution advisories are phrased — product-scoped attestations about which Microsoft or vendor artifacts are known carriers — means operators must actively verify their own images and appliances instead of assuming safety by omission. Community and vendor messaging has highlighted that nuance; operators should map their inventory to CVE carriers and SRUs carefully.
In short: technically the bug is fixed with a small patch; operationally, the real work is in inventory, patch management, and reducing the blast radius of local filesystem operations.

CVE-2024-23850 is therefore an example of a subtle concurrency assumption that turned into a real-world denial-of-service vector. The cure is straightforward — apply the kernel updates and reduce unnecessary privilege exposure — but complacency in patching or capability hardening leaves systems exposed to the blunt but damaging effect of a kernel panic.

Source: MSRC Security Update Guide - Microsoft Security Response Center
 

Back
Top