Skip to main content
Vulnerability Database/CVE-2024-57896

CVE-2024-57896: Linux Kernel Use-After-Free Vulnerability

CVE-2024-57896 is a use-after-free flaw in Linux Kernel that occurs during unmount when delalloc workers access freed cleaner kthread memory. This post explains its impact, affected versions, and mitigation steps.

Published:

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Sources: National Vulnerability Database, CISA KEV, Exploit-DB

CVE-2024-57896 Overview

CVE-2024-57896 is a use-after-free vulnerability [CWE-416] in the Btrfs filesystem implementation of the Linux kernel. The flaw resides in the close_ctree() unmount path in fs/btrfs/disk-io.c, where the cleaner kthread is stopped before pending delalloc workers finish executing. A worker running submit_compressed_extents() can call btrfs_add_delayed_iput(), which attempts to wake the already-freed cleaner task_struct. Syzbot reproduced the issue on kernel 6.13.0-rc1 and KASAN flagged a slab-use-after-free in __lock_acquire(). A local user with the ability to mount and unmount Btrfs volumes can trigger memory corruption that leads to kernel crashes or privilege escalation.

Critical Impact

Local exploitation can corrupt kernel memory via a freed task_struct, enabling denial of service and potential privilege escalation on systems using Btrfs.

Affected Products

  • Linux kernel versions through the stable branches that received the fix
  • Linux kernel 6.13-rc1
  • Linux kernel 6.13-rc2

Discovery Timeline

  • 2025-01-15 - CVE-2024-57896 published to NVD
  • 2026-06-17 - Last updated in NVD database

Technical Details for CVE-2024-57896

Vulnerability Analysis

The vulnerability is a use-after-free condition in the Btrfs unmount sequence. During close_ctree(), the kernel calls kthread_stop() on the cleaner thread, which frees the thread's task_struct. The unmount path then proceeds to stop and destroy work queues. Between these two operations, a worker from the delalloc_workers queue may still be executing inode.c:submit_compressed_extents().

That worker calls btrfs_add_delayed_iput(), which in turn invokes try_to_wake_up() targeting the cleaner thread. Because the cleaner's task_struct has already been released back to the slab allocator, the wake-up operation dereferences freed memory. KASAN reports the read in __lock_acquire() at kernel/locking/lockdep.c:5089 with the stack originating from btrfs_work_helper on the btrfs-delalloc workqueue.

Root Cause

The root cause is incorrect shutdown ordering in close_ctree(). The delalloc workqueue is not drained before kthread_stop() releases the cleaner thread. This produces a race in which in-flight compressed extent submissions wake a destroyed kernel thread. The fix flushes the delalloc workers queue before stopping the cleaner kthread, ensuring no worker can reference the freed task_struct.

Attack Vector

Exploitation requires local access and the ability to mount, use, and unmount a Btrfs filesystem. An attacker schedules compressed write I/O against a Btrfs volume and then initiates an unmount while delalloc work is still outstanding. The resulting race corrupts kernel slab memory. Successful exploitation can cause a kernel panic or, with careful heap grooming, be leveraged for local privilege escalation. The vulnerability is not remotely exploitable and no public proof-of-concept beyond the Syzbot reproducer is listed.

Detection Methods for CVE-2024-57896

Indicators of Compromise

  • KASAN reports showing slab-use-after-free in __lock_acquire with a call stack transiting submit_compressed_extents, btrfs_add_delayed_iput, and btrfs_work_helper.
  • Kernel oops or panic messages originating from the btrfs-delalloc workqueue during or immediately after a Btrfs umount operation.
  • Unexpected reboots or crashes on hosts that repeatedly mount and unmount Btrfs volumes under write load.

Detection Strategies

  • Query installed kernel versions across the fleet and flag hosts running vulnerable Linux kernel builds, including 6.13-rc1 and 6.13-rc2.
  • Enable KASAN on test or canary systems to surface the use-after-free during fuzzing or regression workloads.
  • Monitor dmesg and journalctl -k for Btrfs-related warnings tied to unmount sequences and cleaner thread activity.

Monitoring Recommendations

  • Centralize kernel logs and alert on BUG:, KASAN:, and general protection fault strings paired with btrfs symbols.
  • Track filesystem lifecycle events, especially mount and unmount of Btrfs volumes by non-root service accounts.
  • Correlate kernel crashes with preceding umount activity in audit logs to identify suspected exploitation attempts.

How to Mitigate CVE-2024-57896

Immediate Actions Required

  • Apply the upstream Btrfs patches that flush the delalloc workers queue before stopping the cleaner kthread during close_ctree().
  • Update to a patched stable kernel from your distribution; Debian LTS has published advisories covering this issue.
  • Restrict the ability of unprivileged users to mount and unmount Btrfs volumes, including removable media auto-mount behavior.

Patch Information

The fix is merged in the stable kernel tree across multiple branches. Reference commits include 1ea629e7bb2f, 35916b2f9650, 63f4b594a688, a2718ed1eb8c, d77a3a99b53d, and f10bef73fb35. Distribution advisories are available from Debian LTS (March 2025 msg00001) and Debian LTS (March 2025 msg00002). Upstream commits are published on git.kernel.org.

Workarounds

  • Avoid using Btrfs on multi-tenant hosts where untrusted local users can trigger mount or unmount operations until patches are applied.
  • Disable automatic mounting of removable Btrfs media through udisks2 or desktop policy on at-risk endpoints.
  • Reduce exposure by migrating workloads temporarily to alternative filesystems such as ext4 or XFS where feasible.
bash
# Verify running kernel version and distribution patch status
uname -r

# Debian / Ubuntu: apply vendor-supplied kernel update
sudo apt update && sudo apt upgrade linux-image-$(uname -r | cut -d- -f3-)
sudo reboot

# Restrict non-root mount of Btrfs volumes via udev / policykit
# Example: disable auto-mount of removable Btrfs devices
sudo sed -i 's/^#*\s*automount.*/automount=false/' /etc/udisks2/udisks2.conf

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Sources: National Vulnerability Database, CISA KEV, Exploit-DB

Experience the Most Advanced Cybersecurity Platform

See how the world’s most intelligent, autonomous cybersecurity platform can protect your organization today and into the future.