Skip to main content
Vulnerability Database/CVE-2026-98646

CVE-2026-98646: Linux Kernel TCP Race Condition Vulnerability

CVE-2026-98646 is a race condition flaw in the Linux kernel TCP stack that causes incorrect scheduling under BPF context. This article covers the technical details, affected versions, impact, and mitigation strategies.

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-2026-98646 Overview

CVE-2026-98646 is a Linux kernel defect in the TCP subsystem. The flaw occurs when bpf_sock_destroy() is invoked from a BPF TCP iterator against a listening socket that still has children in its accept queue. The resulting call chain reaches inet_csk_listen_stop(), which calls cond_resched() while the iterator holds rcu_read_lock(). This triggers a sleeping-in-atomic-context debug violation (BUG: sleeping function called from invalid context). The fix skips cond_resched() when running under a BPF context, consistent with existing has_current_bpf_ctx() guards already present in tcp_abort() and udp_abort().

Critical Impact

A privileged BPF program iterating TCP sockets can trigger a kernel warning and potential soft-lockup when destroying a listener with pending children, affecting kernel stability on systems using BPF socket iterators.

Affected Products

  • Linux kernel (upstream, versions prior to the fix commits)
  • Distributions shipping kernels with BPF TCP iterator and bpf_sock_destroy() support
  • Systems running BPF programs that iterate and destroy TCP sockets

Discovery Timeline

  • 2026-10-18 - CVE-2026-98646 published to NVD
  • 2026-10-19 - Last updated in NVD database

Technical Details for CVE-2026-98646

Vulnerability Analysis

The defect lives in net/ipv4/inet_connection_sock.c at the inet_csk_listen_stop() function. BPF programs can call bpf_sock_destroy() from a TCP iterator context, which executes under rcu_read_lock(). When the target socket is a listener with children still queued in its accept queue, tcp_abort() dispatches into inet_csk_listen_stop().

Inside that loop, a call to cond_resched() voluntarily yields the CPU. Yielding is prohibited while holding an RCU read-side critical section because it may report a quiescent state and allow readers to observe partially freed structures. The kernel's __might_resched() debug check detects the violation and emits a warning with a full call trace.

The root issue is a missed guard. Earlier work that introduced the kfunc wrapped lock_sock() in both tcp_abort() and udp_abort() with has_current_bpf_ctx(). The listener accept-queue drain path was overlooked. The patch adds the same conditional check around the cond_resched() call, preserving scheduling fairness outside BPF while suppressing the reschedule when inside an iterator.

Root Cause

The root cause is improper synchronization between BPF iterator context and the TCP listener teardown path. cond_resched() is called unconditionally inside inet_csk_listen_stop() without checking whether the current task is executing a BPF program under RCU protection. This is a context-mismatch defect rather than a memory-safety bug.

Attack Vector

Exploitation requires the ability to load and run a BPF program with CAP_BPF or CAP_SYS_ADMIN, invoke a TCP iterator, and call bpf_sock_destroy() on a listening socket with pending accept-queue entries. The attacker must already hold privileged BPF access, which limits exposure to local, privileged contexts. The resulting behavior is a kernel warning (WARN) and tainting of the kernel; on PREEMPT_RT or hardened configurations with panic-on-warn enabled, this can escalate to a denial-of-service.

The vulnerability mechanism is documented in the upstream commit messages. See the Linux Kernel Commit ee7246bc for the authoritative technical description.

Detection Methods for CVE-2026-98646

Indicators of Compromise

  • Kernel log entries containing BUG: sleeping function called from invalid context at net/ipv4/inet_connection_sock.c
  • Call traces including inet_csk_listen_stop, tcp_abort, bpf_sock_destroy, and bpf_iter_tcp_seq_show
  • Kernel taint flag W appearing after BPF TCP iterator workloads execute

Detection Strategies

  • Monitor /var/log/kern.log, dmesg, and journald for sleeping function called from invalid context warnings referencing inet_connection_sock.c
  • Audit loaded BPF programs with bpftool prog list and flag any iterators invoking bpf_sock_destroy
  • Correlate kernel warnings with the PID and comm name of processes reading BPF iterator files under /sys/fs/bpf/ or /proc/self/fd/

Monitoring Recommendations

  • Forward kernel ring buffer events to a centralized log platform and alert on __might_resched warnings tied to TCP paths
  • Track CAP_BPF and CAP_SYS_ADMIN grants to non-root workloads and review BPF iterator usage in production
  • Baseline kernel version and patch level across the fleet to identify hosts missing the upstream fix

How to Mitigate CVE-2026-98646

Immediate Actions Required

  • Update the Linux kernel to a version containing one of the fix commits listed in the Patch Information section
  • Restrict CAP_BPF and CAP_SYS_ADMIN to trusted administrators and audit existing grants
  • Review in-house and third-party BPF programs for use of bpf_sock_destroy() against listening sockets

Patch Information

The fix adds a has_current_bpf_ctx() guard around cond_resched() in inet_csk_listen_stop(). Apply one of the following upstream commits based on your kernel branch:

Distribution-maintained kernels should receive backports through their respective security update channels.

Workarounds

  • Disable or unload BPF TCP iterator programs that call bpf_sock_destroy() until the kernel is patched
  • Ensure panic_on_warn is disabled on affected hosts to prevent the warning from escalating to a kernel panic
  • Remove CAP_BPF from unprivileged service accounts and containers that do not require socket iteration
bash
# Check current kernel version and panic_on_warn setting
uname -r
sysctl kernel.panic_on_warn

# Temporarily disable panic_on_warn if enabled
sysctl -w kernel.panic_on_warn=0

# List loaded BPF programs and identify TCP iterators
bpftool prog list | grep -i iter

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.