CVE-2026-53085: bpf: fix mm lifecycle in open-coded task_vma iterator
In the Linux kernel, the following vulnerability has been resolved:
bpf: fix mm lifecycle in open-coded taskvma iterator
The open-coded taskvma iterator reads task->mm locklessly and acquires mmapreadtrylock() but never calls mmget(). If the task exits concurrently, the mmstruct can be freed as it is not SLABTYPESAFEBYRCU, resulting in a use-after-free.
Safely read task->mm with a trylock on alloclock and acquire an mm reference. Drop the reference via bpfitermmputasync() in destroy() and error paths. bpfitermmputasync() is a local wrapper around mmputasync() with a fallback to mmput() on !CONFIGMMU.
Reject irqs-disabled contexts (including NMI) up front. Operations used by next() and destroy() (mmapreadunlock, bpfitermmputasync) take spinlocks with IRQs disabled (pool->lock, pilock). Running from NMI or from a tracepoint that fires with those locks held could deadlock.
A trylock on alloclock is used instead of the blocking tasklock() (gettaskmm) to avoid a deadlock when a softirq BPF program iterates a task that already holds its alloclock on the same CPU.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Compensating control
In the open-coded task_vma iterator, reject IRQs-disabled contexts, including NMI, before taking locks; use a trylock on alloc_lock instead of blocking task_lock() when reading task->mm.
- Operational
Ensure the open-coded task_vma iterator drops its mm reference through bpf_iter_mmput_async() in _destroy(), including the mmput() fallback on !CONFIG_MMU, and cover both normal and error paths.