CVE-2026-139317: bpf: Don't saturate owner_refcnt on the last unpin
In the Linux kernel, the following vulnerability has been resolved:
bpf: Don't saturate ownerrefcnt on the last unpin
bpflocalstoragemapfree() pins the owner with refcountincnotzero() while it uncharges an element. The pin counts when bpflocalstoragedestroy() could not get localstorage->lock: destroy() then goes on, drops the owner's reference and spins until the count is zero. So the pin is the last reference whenever it is needed, and refcountdec() takes that for a bug: it warns "decrement hit 0; leaking memory" and saturates the count. Unless destroy() happens to read the count between the two stores it spins for ever, under rcureadlock().
Drop the pin with refcountdecandtest().
Affected Software
Event History
Frequently Asked Questions
What condition is required to trigger the issue?
The issue requires bpf_local_storage_map_free() to pin an owner while uncharging an element after bpf_local_storage_destroy() could not acquire local_storage->lock. In that path, the pin is the last reference and a refcount decrement can saturate the count.
What is the operational impact?
The destroy path can spin indefinitely waiting for the owner reference count to reach zero. The spin occurs under rcu_read_lock(), potentially leaving the affected kernel execution path stuck.
How can the corrected behavior be identified in a patch?
The fix drops the temporary pin with refcount_dec_and_test() rather than refcount_dec(). The provided stable kernel references identify commits containing the correction.