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

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

CVE-2024-26865 is a use-after-free vulnerability in the Linux Kernel's RDS TCP reqsk timer handler that can cause system crashes. This post explains the technical details, affected versions, security impact, 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-26865 Overview

CVE-2024-26865 is a use-after-free vulnerability [CWE-416] in the Linux kernel's Reliable Datagram Sockets (RDS) TCP subsystem. The flaw resides in reqsk_timer_handler() where a request socket (reqsk) can outlive the network namespace that owns its kernel listener. When the reqsk timer fires after the netns has been dismantled, the handler dereferences freed memory, triggering memory corruption detectable via KASAN.

The issue was discovered by syzkaller fuzzing and traced to kernel listeners created by rds_tcp_listen_init() not being purged during namespace teardown. The vulnerability affects local attackers who can create and tear down network namespaces.

Critical Impact

Local attackers with the ability to create network namespaces can trigger kernel memory corruption, leading to privilege escalation or denial of service through use-after-free of struct net.

Affected Products

  • Linux Kernel (multiple stable branches prior to patched commits)
  • Distributions shipping the Linux kernel with RDS TCP support enabled
  • Systems permitting unprivileged user namespace creation (CLONE_NEWNET)

Discovery Timeline

  • 2024-04-17 - CVE-2024-26865 published to NVD
  • 2026-08-04 - Last updated in NVD database

Technical Details for CVE-2024-26865

Vulnerability Analysis

The Reliable Datagram Sockets (RDS) subsystem over TCP initializes a per-netns listener in rds_tcp_listen_init() using __sock_create(). When a client calls connect() to the RDS TCP port (0x4001), the kernel allocates a request socket (reqsk) with an associated timer managed by reqsk_timer_handler() in net/ipv4/inet_connection_sock.c.

The reqsk design assumes the parent listener holds the netns alive until all pending request timers expire. For user-space listeners this holds, because socket close waits for pending reqsk. For kernel listeners, however, netns teardown can proceed while reqsk entries remain in the global established hash (ehash), leaving the timer with a dangling struct net pointer.

Root Cause

Commit 740ea3c4a0b2 previously addressed the equivalent issue for per-netns ehash by cleaning kernel listener reqsk in inet_twsk_purge(). The fix was never extended to the global ehash path used by RDS TCP listeners. As a result, reqsk_timer_handler() can read freed memory at struct request_sock_queue after the namespace has been destroyed, as evidenced by the KASAN slab-use-after-free report in inet_csk_reqsk_queue_drop().

Attack Vector

Exploitation requires local access and the ability to call unshare(CLONE_NEWNET). The reproduction sequence observed by syzkaller is:

  1. unshare(CLONE_NEWNET) creates a new netns, which invokes rds_tcp_listen_init() to create a kernel listener bound to RDS TCP port 0x4001.
  2. A process calls connect() to the loopback RDS TCP port, inserting a reqsk into the global ehash with a pending timer.
  3. The process exits immediately before the three-way handshake completes.
  4. The netns is dismantled and struct net is freed, but the orphan reqsk timer remains armed.
  5. When the timer fires, reqsk_timer_handler() dereferences the freed net structure, producing the use-after-free. The listener is only freed after an RCU grace period, masking the race.

No verified public exploit is available. See the upstream fixes for technical remediation detail: Kernel Git Commit 9ceac04 and Kernel Git Commit 2a750d6.

Detection Methods for CVE-2024-26865

Indicators of Compromise

  • KASAN reports showing slab-use-after-free in inet_csk_reqsk_queue_drop originating from reqsk_timer_handler in softirq context.
  • ref_tracker warnings in lib/ref_tracker.c:179 referencing sk_alloc and rds_tcp_listen_init call paths.
  • Unexpected kernel oops or panic traces originating from run_timer_softirq with RDS listener allocations in the backtrace.

Detection Strategies

  • Enable KASAN on test and staging kernels to surface use-after-free conditions on struct net during namespace teardown.
  • Audit kernel logs for warnings tied to net notrefcnt and reference-tracker reports involving rds_tcp_init_net.
  • Monitor for processes creating network namespaces followed by rapid exit, especially those binding or connecting to TCP port 0x4001 (16385).

Monitoring Recommendations

  • Collect kernel dmesg and audit logs centrally and alert on KASAN or WARNING: lines matching reqsk_timer_handler or ref_tracker_dir_exit.
  • Instrument unshare and clone syscalls with CLONE_NEWNET flags via eBPF or auditd to baseline legitimate namespace creation activity.
  • Track loaded kernel modules; alert when rds or rds_tcp is loaded on hosts that do not require RDS.

How to Mitigate CVE-2024-26865

Immediate Actions Required

  • Apply the upstream fixes merged into Linux stable branches referenced by commits 9ceac04, 2a750d6, 1e9fd5c, 9905a15, and f901ee0.
  • Update to a distribution kernel that incorporates these patches and reboot affected systems.
  • Where patching is deferred, blacklist the rds and rds_tcp kernel modules on systems that do not require them.

Patch Information

The fix extends the cleanup performed by commit 740ea3c4a0b2 to the global ehash, ensuring kernel listeners' pending reqsk entries are purged during netns teardown. Patches are available in the mainline and stable trees via the following references: Kernel Git Commit 1e9fd5c, Kernel Git Commit 2a750d6, Kernel Git Commit 9905a15, Kernel Git Commit 9ceac04, and Kernel Git Commit f901ee0.

Workarounds

  • Prevent loading of RDS modules by adding install rds /bin/true and install rds_tcp /bin/true to /etc/modprobe.d/.
  • Restrict unprivileged user namespace creation by setting kernel.unprivileged_userns_clone=0 (where supported) to limit the attacker's ability to invoke unshare(CLONE_NEWNET).
  • Monitor and restrict workloads that legitimately require network namespace creation to trusted service accounts.
bash
# Configuration example: disable RDS modules and restrict unprivileged netns
echo 'install rds /bin/true' | sudo tee /etc/modprobe.d/disable-rds.conf
echo 'install rds_tcp /bin/true' | sudo tee -a /etc/modprobe.d/disable-rds.conf

# Restrict unprivileged user namespace creation (Debian/Ubuntu)
sudo sysctl -w kernel.unprivileged_userns_clone=0
echo 'kernel.unprivileged_userns_clone=0' | sudo tee /etc/sysctl.d/99-no-userns.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.