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

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

CVE-2024-50154 is a use-after-free flaw in the Linux Kernel TCP/DCCP request socket handling that allows memory corruption during timer operations. This post explains the technical details, 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-50154 Overview

CVE-2024-50154 is a use-after-free vulnerability [CWE-416] in the Linux kernel's TCP/DCCP request socket handling. The flaw exists in reqsk_queue_unlink(), where a race condition between expire_timers() and the timer_pending() check allows the kernel to skip a required del_timer_sync() call. When this occurs, the request socket timer continues running after the associated socket has been accepted and closed, leading to a use-after-free when the timer fires against freed memory. The issue was reported by Martin KaFai Lau after observing crashes in a BPF program attached to trace_tcp_retransmit_synack.

Critical Impact

A local attacker on an affected Linux host can trigger memory corruption in kernel space, potentially leading to privilege escalation, information disclosure, or system crash.

Affected Products

  • Linux Kernel (multiple stable branches prior to the fix)
  • Linux Kernel 6.12-rc1, 6.12-rc2, 6.12-rc3
  • Debian LTS distributions (addressed in January and May 2025 advisories)

Discovery Timeline

  • 2024-11-07 - CVE-2024-50154 published to NVD
  • 2026-08-04 - Last updated in NVD database

Technical Details for CVE-2024-50154

Vulnerability Analysis

The vulnerability resides in the TCP and DCCP request socket (reqsk) queue management code. Commit 83fccfc3940c previously introduced a timer_pending() check inside reqsk_queue_unlink() to avoid calling del_timer_sync() from the timer handler itself. That change prevented a potential deadlock but opened a narrow race window.

Before executing a scheduled timer, expire_timers() calls detach_timer(timer, true), which clears timer->entry.pprev and marks the timer as not pending. If reqsk_queue_unlink() evaluates timer_pending() immediately after detach_timer() but before the handler runs, TCP skips del_timer_sync(). The reqsk timer then continues and can transmit multiple SYN+ACK retransmissions until its 63-second default expiration.

The reported crash chain is: inet_csk_complete_hashdance() calls inet_csk_reqsk_queue_drop() and misses del_timer_sync(); the request socket is accepted, reqsk_put() decrements rsk_refcnt, but the stray timer still holds a reference; the socket is closed; the timer fires again and a BPF program attached to trace_tcp_retransmit_synack dereferences the freed req->sk.

Root Cause

The root cause is a time-of-check to time-of-use race between expire_timers() clearing the pending flag and reqsk_queue_unlink() reading it. The fix removes the timer_pending() check by passing the caller context into __inet_csk_reqsk_queue_drop(), ensuring the correct synchronization path is always taken.

Attack Vector

Exploitation requires local privileges and the ability to drive TCP connection state transitions, such as establishing connections that complete the SYN+ACK retransmission path and are quickly accepted and closed. The condition is further contingent on BPF programs or other kernel paths that dereference req->sk after the race, as demonstrated by the KFENCE report involving bpf_sk_storage_get_tracing. Reliable triggering is difficult because the request socket timer is CPU-pinned, which narrows the race window in most workloads.

No public proof-of-concept exploit is available. The vulnerability is described in prose only; see the upstream kernel commits referenced below for implementation detail.

Detection Methods for CVE-2024-50154

Indicators of Compromise

  • Kernel KFENCE or KASAN reports citing use-after-free reads in reqsk_timer_handler, tcp_rtx_synack, or bpf_sk_storage_get_tracing.
  • Unexpected kernel panics or BUG: entries in dmesg referencing run_timer_softirq and the TCP retransmit path.
  • Anomalous bursts of SYN+ACK retransmissions originating from a server after a connection has already been accepted.

Detection Strategies

  • Enable KFENCE or KASAN on test and staging kernels to surface use-after-free conditions in the TCP request socket path.
  • Monitor kernel ring buffer and journald for tcp_rtx_synack or reqsk_timer_handler stack traces.
  • Audit loaded BPF programs attached to tracepoints such as trace_tcp_retransmit_synack that dereference req->sk.

Monitoring Recommendations

  • Track installed kernel package versions against vendor advisories, including the Debian LTS announcements of January and May 2025.
  • Alert on repeated kernel oops or soft lockup events in TCP softirq context across the Linux fleet.
  • Correlate host crash telemetry with workloads that use eBPF tracing on TCP control paths.

How to Mitigate CVE-2024-50154

Immediate Actions Required

  • Inventory all Linux hosts and identify kernels built before the fix commits referenced by upstream and distribution advisories.
  • Apply the latest stable kernel update from your distribution vendor, prioritizing hosts running custom BPF tracing on TCP paths.
  • Reboot patched systems to activate the fixed kernel, since live patching coverage for this change may be limited.

Patch Information

The upstream fix passes the caller context to __inet_csk_reqsk_queue_drop() and removes the racy timer_pending() check in reqsk_queue_unlink(). Backports are available in the stable tree commits 5071beb, 51e34db, 8459d61, 997ae8d, and e8c526f. Debian users should consult the Debian LTS Announcement January 2025 and the Debian LTS Announcement May 2025.

Workarounds

  • Restrict loading of BPF programs that dereference req->sk on tracepoints such as trace_tcp_retransmit_synack until the kernel is patched.
  • Limit local shell access and tighten CAP_BPF/CAP_SYS_ADMIN grants to reduce the population of users who can exercise the race.
  • Enable KFENCE in non-production environments to detect exploitation attempts during validation.
bash
# Example: verify kernel version and planned update on Debian
uname -r
apt list --upgradable | grep -i linux-image
sudo apt update && sudo apt install --only-upgrade linux-image-$(uname -r | sed 's/.*-//')
sudo reboot

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.