Skip to main content
CVE Vulnerability Database
Vulnerability Database/CVE-2025-38502

CVE-2025-38502: Linux Kernel Buffer Overflow Vulnerability

CVE-2025-38502 is a buffer overflow vulnerability in the Linux Kernel affecting cgroup local storage via tail calls. Attackers can craft out-of-bounds access exploits. This article covers technical details, impact, and mitigation.

Published:

CVE-2025-38502 Overview

CVE-2025-38502 is an out-of-bounds access vulnerability in the Linux kernel's Berkeley Packet Filter (BPF) subsystem, specifically in cgroup local storage handling. The flaw was reported by a researcher named Lonial and can be triggered through crafted BPF tail calls between programs using cgroup local storage maps of differing value sizes. The BPF verifier validates each program independently, but at runtime the callee inherits the caller's bpf_prog_array_item, causing bpf_get_local_storage() to return the wrong storage buffer. This size mismatch enables an out-of-bounds read or write against kernel memory, mapped to [CWE-125].

Critical Impact

A local, low-privileged attacker with the ability to load BPF programs can trigger out-of-bounds memory access in the kernel, leading to information disclosure or denial of service on affected Linux systems.

Affected Products

  • Linux Kernel (multiple stable branches prior to the fix commits)
  • Debian Linux 11 (Bullseye) — addressed via Debian LTS
  • Siemens SIMATIC CN 4100 firmware

Discovery Timeline

  • 2025-08-16 - CVE-2025-38502 published to the National Vulnerability Database (NVD)
  • 2026-07-30 - Last updated in NVD database

Technical Details for CVE-2025-38502

Vulnerability Analysis

The defect lives in the BPF cgroup local storage runtime path. When a BPF program executes, the kernel stores a pointer to the currently-running program's bpf_prog_array_item in current->bpf_ctx. Helpers such as bpf_get_local_storage() resolve the storage pointer through this context:

ctx = container_of(current->bpf_ctx, struct bpf_cg_run_ctx, run_ctx);
storage = ctx->prog_item->cgroup_storage[stype];

The verifier checks each program in isolation and confirms that its accesses fit within its own storage map's value size. However, when program A performs a bpf_tail_call() into program B, the bpf_cg_run_ctx is not refreshed. Program B continues to read prog_item->cgroup_storage[stype] belonging to program A. If B was verified against a larger value size than A's map provides, subsequent loads and stores read or write past the end of A's per-cgroup or per-CPU storage buffer.

Root Cause

The verifier lacks a cross-program invariant tying tail-call chains to a consistent cgroup local storage layout. bpf_map_owner did not previously track the storage maps a program is bound to, so tail-call compatibility checks ignored storage size mismatches. The upstream fix extends bpf_map_owner with a storage_cookie[] array. Tail calls are now rejected unless the callee either references the same storage maps as the original attached program, or does not use any cgroup local storage helpers.

Attack Vector

Exploitation requires local access and the ability to load BPF programs, typically CAP_BPF or CAP_SYS_ADMIN, or an unprivileged BPF configuration on older systems. An attacker crafts two BPF programs attached to a cgroup: a first program with a small cgroup local storage map, and a second program calling bpf_get_local_storage() against a larger declared value size. Chaining them via bpf_tail_call() causes the second program to index past the first program's storage buffer, yielding out-of-bounds kernel memory access.

Detection Methods for CVE-2025-38502

Indicators of Compromise

  • Unexpected loading of BPF programs by non-root users or short-lived processes on production hosts.
  • Kernel oops, KASAN reports, or general protection faults referencing bpf_get_local_storage, cgroup_storage, or bpf_cg_run_ctx.
  • Anomalous use of bpf(BPF_PROG_LOAD) and bpf(BPF_MAP_CREATE) with BPF_MAP_TYPE_CGROUP_STORAGE or BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE.

Detection Strategies

  • Audit bpf() syscalls with auditd rules on -S bpf and alert on unexpected callers.
  • Enable KASAN on test kernels to surface out-of-bounds accesses during triage of suspicious workloads.
  • Correlate BPF program loads with subsequent kernel warnings using centralized log aggregation.

Monitoring Recommendations

  • Track /sys/kernel/debug/tracing/events/bpf activity and cgroup attachment events for anomalies.
  • Monitor kernel version and patch state across Linux fleets to identify unpatched hosts.
  • Alert on new setuid/CAP_BPF grants and container escapes attempting to load eBPF programs.

How to Mitigate CVE-2025-38502

Immediate Actions Required

  • Apply vendor-provided kernel updates as soon as they are available for your distribution and stable branch.
  • Restrict BPF program loading to trusted administrators by setting kernel.unprivileged_bpf_disabled=1.
  • Inventory container and workload nodes that expose CAP_BPF or CAP_SYS_ADMIN to non-root users and reduce the attack surface.

Patch Information

The fix is available across multiple stable kernel branches. See the upstream commits: Kernel commit 19341d5c, Kernel commit 41688d1f, Kernel commit 66da7cee, Kernel commit 7acfa07c, Kernel commit abad3d0b, and Kernel commit c1c74584. Distribution-specific guidance is available in the Debian LTS Announcement and the Siemens Security Advisory SSA-032379.

Workarounds

  • Disable unprivileged BPF via sysctl -w kernel.unprivileged_bpf_disabled=1 and persist the setting in /etc/sysctl.d/.
  • Drop CAP_BPF and CAP_SYS_ADMIN from container runtime defaults where BPF is not required.
  • Apply Linux Security Module policies (SELinux or AppArmor) to constrain which processes can call bpf().
bash
# Disable unprivileged BPF program loading
echo 'kernel.unprivileged_bpf_disabled=1' | sudo tee /etc/sysctl.d/90-bpf-hardening.conf
sudo sysctl --system

# Verify the setting is active
sysctl kernel.unprivileged_bpf_disabled

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

Default Legacy - Prefooter | Experience the World’s Most Advanced Cybersecurity Platform

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.