⚠️

Disclaimer & Liability

The content provided on this website is for educational, research, and security awareness purposes only. Any unauthorized, illegal, or abusive use of the information, tools, and techniques discussed is solely the responsibility of the user. The author and publisher assume no liability for any damages, injuries, or consequences resulting from the misuse of this content.

CVE-2026-139131: Linux Kernel Use-After-Free in BPF Task Reference Lifecycle | Alireza Bolbolabadi - Red Team Security
LOADING

CVE-2026-139131: Linux Kernel Use-After-Free in BPF Task Reference Lifecycle

Affected Products: 90660309b0c76c564a31a21f3a81d6641a9acaa0, 6.2, 6.6.163, 6.12.119, 6.18.65, 7.3.6, 7.4-rc1

Overview

CVE-2026-139131 describes a slab use-after-free in the Linux kernel that becomes reachable when BPF programs acquire references to a task before its creation can be considered final. The bug surfaces in the fork path and is triggered by an interplay between dup_task_struct(), bpf_task_acquire(), and copy_process(). Resolving the count alone is not enough, since a partially built task may already have released its mm, files, and credentials.

Affected systems

The vulnerability affects the Linux kernel. The linked vulnerability record identifies the following affected revisions and versions:

  • Revision 90660309b0c76c564a31a21f3a81d6641a9acaa0

  • Linux kernel 6.2

  • Linux kernel 6.6.163

  • Linux kernel 6.12.119

  • Linux kernel 6.18.65

  • Linux kernel 7.3.6

  • Linux kernel 7.4-rc1

The supplied material does not list an explicit fixed version set, so downstream distributions and stable maintainers should be consulted to confirm backport coverage before treating a build as patched.

Root cause

During task creation, dup_task_struct() sets rcu_users to 2 before the kernel can guarantee that the new task will survive. As a result, bpf_task_acquire() is able to return references to a structure that BPF programs treat as a trusted pointer inside task_alloc LSM hooks and inside sched_ext ops.init_task(). If copy_process() subsequently fails, the kernel tears the task down and frees it without reconciling those outstanding references. A program that has stored its reference in a BPF map is left with a pointer into freed slab memory, and the runtime symptom reported is:

> BUG: KASAN: slab-use-after-free in put_task_struct_rcu_user+0x22/0x90

The upstream resolution holds rcu_users at zero until copy_process() reaches the point where it can no longer fail. From that design change, bpf_task_acquire() returns NULL until the task is viable, and its callers must accept that outcome. The same treatment already applies to init_task, which has historically carried a zero count.

Trigger conditions

The vulnerability requires a specific combination of conditions:

  1. A vulnerable Linux kernel is running.

  1. A privileged actor has loaded a BPF program that acquires task references through bpf_task_acquire() and stores them in a map.

  1. A local process causes copy_process() to fail after the reference was taken. pids.max on a cgroup is cited as a simple route to that outcome.

  1. The freed allocation is later accessed through the stale BPF map pointer.

Because BPF loading is itself an administrator-level operation, ordinary Linux deployments that do not run the relevant BPF programs are unlikely to reach the vulnerable path even on an unpatched kernel.

Real-world impact

The supplied risk assessment frames this issue at a technical score of 25/100 and assigns a low editorial severity. Key observations:

  • No CVSS vector or base score has been published.

  • The vulnerability is not listed in the CISA KEV catalog.

  • No exploit code, in-the-wild campaign, or incident report accompanies the record.

  • The demonstrated effect is a KASAN-detected slab use-after-free, which establishes a denial-of-service baseline but does not establish code execution.

The reachable impact is a kernel crash or panic once the stale pointer is dereferenced. Whether that can be converted into arbitrary kernel execution depends on allocator behavior, hardening, and the specific BPF program logic. That conversion is not demonstrated in the supplied material and should not be assumed.

Mitigation

The primary mitigation is to apply the upstream Linux kernel fix associated with CVE-2026-139131, or to install a distribution kernel update that explicitly includes that fix. Distribution advisories and changelogs are the authoritative source of backport status.

Where immediate patching is impractical, exposure can be reduced by:

  • Avoiding the load of BPF programs that use bpf_task_acquire() and retain task pointers across the task-creation window.

  • Restricting BPF loading to trusted administrators through capabilities, security modules, and container policies.

  • Ensuring BPF consumers tolerate NULL from bpf_task_acquire() rather than caching the result.

  • Reducing opportunities for unprivileged users to saturate process-creation limits on cgroups when affected BPF programs are present.

These are exposure-reduction measures; they are not substitutes for the upstream kernel fix.

Detection

Useful signals to watch for include:

  • KASAN reports containing "slab-use-after-free".

  • Kernel log entries referencing put_task_struct_rcu_user+0x22/0x90.

  • Kernel crashes or panics during BPF task-reference handling.

  • Unexpected BPF program loads that involve bpf_task_acquire().

  • Patterns of repeated fork failures associated with pids.max followed by memory-safety faults.

Detection based solely on fork failures is weak because ordinary process-limit exhaustion is common and benign. The strongest signal combines a relevant BPF program, a failed task-creation path, and a subsequent slab use-after-free trace.

advisory high CVE-2026-139131
·
← Back to Writeups