CVE-2026-139204: bpf: Track borrowed iterator results by default
In the Linux kernel, the following vulnerability has been resolved:
bpf: Track borrowed iterator results by default
An open-coded iterator can return a struct pointer borrowed from its current element. The verifier has not tied such results to iterator state since the taskvma iterator was introduced, so a saved result can still be used after destroy. Commit bee9ef4a40a27 ("bpf: switch taskvma iterator from mmaplock to per-VMA locks") also made next release the protection of the prior element. A later snapshot conversion made vmfile explicitly borrowed from that element.
Associate non-RCU, non-acquired struct results with the iterator reference by default. Invalidate dependents before next forks its NULL and non-NULL paths, while retaining the iterator itself. Let destroy propagate child-reference errors. Add KFITERRETINDEPENDENT for results that outlive the current element, preserving existing RCU and acquired-reference rules.
Trusted pointer field loads also need to preserve the source lifetime. Loading a trusted field does not acquire a reference to the pointed-to object. Set the field pointer's parentid to the source's reference ID if the source is referenced, or inherit its parentid if it is borrowed. This is a generic rule, including accesses unrelated to iterators. For example, the following access is now rejected:
file = bpfgettaskexefile(task); if (!file) return 0; inode = file->finode; bpfputfile(file); ino = inode->iino;
The inode pointer borrows the file's lifetime. Releasing the acquired file reference removes that lifetime guarantee, so the verifier must invalidate the derived inode pointer as well. This does not imply that bpfputfile() immediately frees the file or inode. Reading the inode while the file reference is held remains valid. Fields with independent RCU protection retain their existing lifetime rules.
For an iterator result, the same propagation keeps trusted fields such as vmfile and finode tied to the current element. Propagate the backing object's lifetime through dynptr construction too, so its descendants remain in the invalidation graph. Share the invalidation traversal between next and release, so advancing the iterator preserves its own reference.
Affected Software
Event History
Frequently Asked Questions
Are iterator results that outlive the current element affected by the new lifetime tracking?
Results explicitly marked with KF_ITER_RET_INDEPENDENT are excluded because they are intended to outlive the current element. Existing handling for RCU and acquired references is also preserved.
Does loading a trusted pointer field acquire a reference to the pointed-to object?
No. A trusted field load does not acquire a reference; when its source is referenced, the loaded field pointer inherits the source reference lifetime.
When are dependent iterator results invalidated?
Dependents are invalidated before the iterator's next operation branches into its NULL and non-NULL paths. The iterator itself is retained, while destroy propagates child-reference errors.