CVE-2026-139322

bpf: Reject sleepable programs for task_vma iterator

Published Nov 30, 2026 CVSS n/a EPSS n/a KEV · Not listed
Description
In the Linux kernel, the following vulnerability has been resolved:

bpf: Reject sleepable programs for task_vma iterator

A sleepable "iter.s/task_vma" program can be attached, but its ->show()
callback runs with the mmap_lock of the iterated mm held for read. As soon
as the program runs, bpf_iter_run_prog() calls might_fault(), and any
bpf_copy_from_user() or bpf_copy_from_user_task() it does may really fault
or take mmap_lock again. With lockdep this is reported as recursive
locking of mmap_lock. Without lockdep, a fault on the reader's own mm, or
access_process_vm() on the iterated mm, has to take mmap_lock for read
again. If a writer queued up in the meantime that blocks behind the
writer, which in turn waits for the read lock the iterator already holds,
and the read() hangs:

reader (iter.s/task_vma) other thread of the same mm
task_vma_seq_get_next()
mmap_read_lock(mm)
mmap_write_lock(mm) <- waits
bpf prog: copy_from_user()
page fault
mmap_read_lock(mm) <- queued behind the writer

The reader waits killable, so the hang lasts until it gets a fatal signal.

bpf_iter_link_attach() allows sleepable programs for the targets that set
BPF_ITER_RESCHED, and task_vma sets it because cond_resched() between VMAs
is fine with mmap_lock held. Rescheduling between objects and running a
sleepable program inside ->show() are different properties, though, and
task_vma only has the first one. The open-coded task_vma iterator does not
have this problem since it hands out a snapshot of the VMA and holds no
lock when it returns to the program.

The vma handed to the program is only stable under mmap_lock, so the lock
can't be dropped around ->show(). Add a feature flag BPF_ITER_NOSLEEP for
targets which can't run sleepable programs although they can reschedule,
and set it for task_vma.

The check at attach time is not enough. BPF_LINK_UPDATE replaces the
program of a link, and bpf_iter_link_replace() only compares the type, the
attach type and the BTF id of the two programs, which are the same for a
sleepable and a non-sleepable one. Do the check there as well. That also
closes this way around the existing rule: so far a sleepable program could
be put on a link of a target that doesn't set BPF_ITER_RESCHED, like the
hash map element iterator, which runs it under rcu_read_lock().

BPF_LINK_CREATE of a sleepable program for the task_vma target, and
BPF_LINK_UPDATE to one, now fail with -EINVAL, also for programs that
don't touch user memory and have been working since sleepable iterator
programs exist. The programs can still be loaded. They have to be
loaded as non-sleepable programs, or use the open-coded iterator.

Analysis

AI-generated

Technical impact

A BPF program that is marked sleepable may be loaded into the task vma iterator; when the program’s show callback runs it holds the mmap lock for reading and then executes code that can fault or copy data from user space. The faulting path can attempt to re‑acquire the mmap lock for reading, resulting in a recursive lock situation. The kernel lock‑dependency checker reports a deadlock, and without it the reader may block indefinitely until it receives a fatal signal. The effect is a loss of service: the process that owns the iterator is stuck and system responsiveness can degrade or stall. This flaw does not provide code‑execution or privilege escalation, but it can be leveraged for denial of service if an attacker can inject a BPF program and maintain a mapping that triggers the bug.

Affected Systems

All Linux kernel versions that support attached BPF programs for the task vma iterator and allow sleepable programs belong to the affected set. The patch now disallows sleepable programs on this target. No specific version numbers are listed, so any kernel before the fix is potentially vulnerable.

Risk and Exploitability

The CVSS score is not provided and the EPSS score is unavailable, so the quantitative assessment is lacking. The bug is listed as not in the CISA KEV catalog. Exploitation requires ability to load or update a BPF program, so the attack vector is likely local privileged or root access. The vulnerability can be abused to create a deadlock, holding both a reader and a writer lock on the same memory map and preventing further operations until a killable signal terminates the reader. The risk therefore is a potential denial of service that could affect small or large workloads depending on where the iterator is used.

Remediation

No solution or workaround provided in the CVE record.

OpenCVE Recommended Actions

  • Update the Linux kernel to a version that includes the BPF_ITER_NOSLEEP flag and rejects sleepable programs for the task vma target
  • Do not attach sleepable BPF programs to the task vma iterator; use non‐sleepable programs or the open‑coded iterator implementation instead
  • Verify that any existing BPF links to the task vma target have been updated to non‑sleepable programs or that BPF_LINK_UPDATE operations reject sleepable variants

Generated by OpenCVE AI on November 30, 2026 at 21:39 UTC.

Tracking

Sign in to view the affected projects.

Advisories

No advisories available
History
Type Values Removed Values Added
Weaknesses CWE-667
Type Values Removed Values Added
Description In the Linux kernel, the following vulnerability has been resolved: bpf: Reject sleepable programs for task_vma iterator A sleepable "iter.s/task_vma" program can be attached, but its ->show() callback runs with the mmap_lock of the iterated mm held for read. As soon as the program runs, bpf_iter_run_prog() calls might_fault(), and any bpf_copy_from_user() or bpf_copy_from_user_task() it does may really fault or take mmap_lock again. With lockdep this is reported as recursive locking of mmap_lock. Without lockdep, a fault on the reader's own mm, or access_process_vm() on the iterated mm, has to take mmap_lock for read again. If a writer queued up in the meantime that blocks behind the writer, which in turn waits for the read lock the iterator already holds, and the read() hangs: reader (iter.s/task_vma) other thread of the same mm task_vma_seq_get_next() mmap_read_lock(mm) mmap_write_lock(mm) <- waits bpf prog: copy_from_user() page fault mmap_read_lock(mm) <- queued behind the writer The reader waits killable, so the hang lasts until it gets a fatal signal. bpf_iter_link_attach() allows sleepable programs for the targets that set BPF_ITER_RESCHED, and task_vma sets it because cond_resched() between VMAs is fine with mmap_lock held. Rescheduling between objects and running a sleepable program inside ->show() are different properties, though, and task_vma only has the first one. The open-coded task_vma iterator does not have this problem since it hands out a snapshot of the VMA and holds no lock when it returns to the program. The vma handed to the program is only stable under mmap_lock, so the lock can't be dropped around ->show(). Add a feature flag BPF_ITER_NOSLEEP for targets which can't run sleepable programs although they can reschedule, and set it for task_vma. The check at attach time is not enough. BPF_LINK_UPDATE replaces the program of a link, and bpf_iter_link_replace() only compares the type, the attach type and the BTF id of the two programs, which are the same for a sleepable and a non-sleepable one. Do the check there as well. That also closes this way around the existing rule: so far a sleepable program could be put on a link of a target that doesn't set BPF_ITER_RESCHED, like the hash map element iterator, which runs it under rcu_read_lock(). BPF_LINK_CREATE of a sleepable program for the task_vma target, and BPF_LINK_UPDATE to one, now fail with -EINVAL, also for programs that don't touch user memory and have been working since sleepable iterator programs exist. The programs can still be loaded. They have to be loaded as non-sleepable programs, or use the open-coded iterator.
Title bpf: Reject sleepable programs for task_vma iterator
First Time appeared Linux
Linux linux Kernel
CPEs cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
Vendors & Products Linux
Linux linux Kernel
References
Weaknesses

Sources

Status
PUBLISHED
Assigner
Linux
Published
Updated
Nov 30, 2026, 1:33 PM
Reserved
Nov 30, 2026, 1:22 PM
Status
Received
Published
Nov 30, 2026, 2:18 PM
Modified
Nov 30, 2026, 2:18 PM