CVE-2026-139312: bpf: Fix NULL deref in the sk_storage map iterator
In the Linux kernel, the following vulnerability has been resolved:
bpf: Fix NULL deref in the skstorage map iterator
bpfskstoragemapseqfindnext() hands out an element only if its localstorage pointer is set. bpfskstoragemapseqshow() then reads the pointer a second time and dereferences it without a test.
Since bpflocalstoragedestroy() unlinks the elements with bpfselemunlinknofail(), the pointer is reset to NULL when the socket which owns the element is destroyed, so it can change between the two reads. Reading the iterator while sockets with an element in the map are closed ends in a NULL pointer dereference. The sockets need not belong to the reader: where a program gives every new socket an element, an unprivileged user who opens and closes sockets is enough.
Skip such an element, as the TCP and UDP iterators skip a socket which has been unhashed.
Affected Software
Event History
Frequently Asked Questions
Who can trigger this issue in practice?
An unprivileged user can trigger the race by opening and closing sockets, but only where a BPF program assigns a storage-map element to every new socket. The sockets being closed do not need to belong to the process reading the iterator.
What activity is required for exploitation?
The sk_storage map iterator must be read while sockets that have elements in the map are being closed. Socket destruction can clear an element's local_storage pointer between the iterator's initial check and its later dereference, causing a NULL pointer dereference.
Are systems affected by default?
The described trigger depends on a BPF program using socket storage and attaching an element to new sockets. The provided information does not indicate that this configuration is present by default.