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

CVE-2024-42072: Linux Kernel BPF may_goto Logic Vulnerability

CVE-2024-42072 is a BPF may_goto logic flaw in Linux Kernel that affects offset patching and verifier state handling, potentially allowing infinite loops. 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-42072 Overview

CVE-2024-42072 is a Linux kernel vulnerability in the Berkeley Packet Filter (BPF) subsystem. The flaw affects how the BPF verifier handles the may_goto instruction when combined with a negative offset. A syzbot-crafted BPF program exposed two distinct bugs: incorrect instruction patching when may_goto carries a negative offset, and a verifier state-pruning error that fails to detect genuine infinite loops.

The vulnerability affects Linux kernel release candidates 6.10-rc1 through 6.10-rc5. Local attackers with the ability to load BPF programs can trigger kernel-level impact on confidentiality, integrity, and availability.

Critical Impact

A local attacker loading a crafted BPF program can bypass verifier safety checks and trigger infinite loops or memory corruption in the kernel.

Affected Products

  • Linux Kernel 6.10-rc1
  • Linux Kernel 6.10-rc2 through 6.10-rc4
  • Linux Kernel 6.10-rc5

Discovery Timeline

  • 2024-07-29 - CVE-2024-42072 published to the National Vulnerability Database
  • 2026-08-04 - Last updated in NVD database

Technical Details for CVE-2024-42072

Vulnerability Analysis

The vulnerability resides in the BPF verifier's handling of the may_goto instruction. may_goto is a kernel helper that lets BPF programs include bounded backward branches while still passing verification. The verifier tracks a may_goto_depth counter to prevent unbounded iteration.

Two separate defects were identified. First, when may_goto carries a negative offset, the patching logic emits incorrect bytecode because the instruction rewrite assumes a positive branch target. Second, the verifier incorrectly prunes exploration when the current state's may_goto_depth matches a previously visited state's depth. This pruning hides genuine infinite loops because the current state always observes may_goto_depth == 0 while queued states carry the incremented depth.

The combined effect allows a crafted program to pass verification despite containing an infinite loop, undermining a core safety guarantee of the BPF subsystem [CWE-noinfo].

Root Cause

The root cause is twofold. The instruction patching routine does not account for signed negative branch displacements when rewriting may_goto. Separately, the state-equivalence check in the verifier treats matching may_goto_depth values as evidence that further exploration is unnecessary, which is incorrect for the current state versus a queued state.

Attack Vector

Exploitation requires local access and the privileges necessary to load BPF programs, typically CAP_BPF or CAP_SYS_ADMIN. An attacker crafts a BPF program containing may_goto with a negative offset arranged to defeat the state-pruning logic. Once loaded, the mis-patched program executes in kernel context, producing an infinite loop or executing bytecode the verifier never fully analyzed.

No public proof-of-concept exists outside the original syzbot reproducer referenced in the upstream commit messages. See the Kernel Git Commit 2b2efe1 and Kernel Git Commit 175827e for the authoritative fix details.

Detection Methods for CVE-2024-42072

Indicators of Compromise

  • Unexpected bpf() syscall activity from non-privileged service accounts or interactive user sessions.
  • Kernel soft-lockup messages (watchdog: BUG: soft lockup) coincident with recent BPF program loads.
  • Unexplained CPU saturation on a single core consistent with an infinite kernel loop.

Detection Strategies

  • Audit bpf() syscalls using auditd rules targeting BPF_PROG_LOAD to establish a baseline of expected loaders.
  • Correlate BPF program-load events with the loading process, parent, and effective capabilities.
  • Flag any BPF program load originating from processes outside an allow-list of orchestrators, observability agents, and system services.

Monitoring Recommendations

  • Collect kernel logs via journalctl -k or syslog forwarding to a central store for soft-lockup pattern detection.
  • Monitor per-CPU utilization and alert on sustained 100% kernel-mode time on individual cores.
  • Track loaded BPF program inventory with bpftool prog show snapshots to identify unauthorized additions.

How to Mitigate CVE-2024-42072

Immediate Actions Required

  • Upgrade affected systems off of Linux kernel 6.10 release candidates to a patched stable release.
  • Restrict CAP_BPF and CAP_SYS_ADMIN to a minimum set of trusted service accounts.
  • Set kernel.unprivileged_bpf_disabled=1 to prevent unprivileged users from loading BPF programs.
  • Inventory running BPF programs and remove any that are unexpected or unattributed.

Patch Information

The fix is applied in upstream commits 175827e04f4b and 2b2efe1937ca. The patches correct the may_goto patching path for negative offsets and remove the incorrect state-pruning behavior so the verifier continues exploring until bpf_exit. Deploy a kernel build that incorporates both commits.

Workarounds

  • Disable unprivileged BPF program loading by setting kernel.unprivileged_bpf_disabled=1 in /etc/sysctl.d/.
  • Apply Linux Security Module policies (SELinux, AppArmor) that deny bpf operations to non-system domains.
  • Remove CAP_BPF from container runtimes and workloads that do not require BPF.
bash
# Disable unprivileged BPF loading persistently
echo 'kernel.unprivileged_bpf_disabled=1' | sudo tee /etc/sysctl.d/90-disable-unpriv-bpf.conf
sudo sysctl --system

# Verify the setting
sysctl kernel.unprivileged_bpf_disabled

# Inventory currently loaded BPF programs
sudo bpftool prog show

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.