CVE-2026-139310

bpf: Hold the socket in the sk_storage map 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: Hold the socket in the sk_storage map iterator

The iterator over a sk_storage map passes the owner of an element to its
program as ctx->sk, without a reference. All that it holds is the RCU read
lock, which keeps the element and the storage, not the socket.

An element is unlinked by bpf_sk_storage_free(), which __sk_destruct()
calls right before it frees the socket. That is no better for a socket
with SOCK_RCU_FREE: the grace period comes in front of __sk_destruct(),
so a reader which starts behind call_rcu() still finds the element. The
program and the helpers it hands ctx->sk to, such as
bpf_sk_storage_get() or bpf_sk_storage_delete(), use a socket which is
being freed on another CPU. It takes nothing but reading the iterator
while sockets with an element in the map are closed, by whomever.

Take a reference for the time of the program, and skip the element if
there is none to be had. To look at the owner at all, do what
bpf_selem_unlink_nofail() does for bpf_local_storage_map_free(): as long
as the element is linked under the lock of the storage,
bpf_local_storage_destroy() has not got past it, unless it has given up
on the lock, and then it waits for owner_refcnt.

The last reference may now be dropped by the iterator. The end of a socket
may want process context: rfcomm_sock_destruct() takes a mutex. So only
drop the reference under RCU, and free a socket whose last one it was when
the RCU read lock has been released, which is at the end of a bucket and
of every read() at the latest.

Analysis

AI-generated

Technical impact

The Linux kernel BPF sk_storage map iterator hands a socket pointer to a BPF program without increasing its reference count, causing the pointer to refer to a socket that may already be in the process of being freed. If a BPF program or helper uses or deletes the socket during this window, the kernel may access invalid memory, resulting in a use‑after‑free condition that can be exploited to corrupt kernel data structures and gain elevated privileges on the host.

Affected Systems

All installations of the Linux kernel that include the BPF sk_storage map functionality are potentially exposed. The vendor list specifies Linux:Linux, but the specific kernel versions impacted are not enumerated in the available data.

Risk and Exploitability

The vulnerability poses a high risk because a kernel use‑after‑free can lead to privilege escalation. No CVSS score or EPSS value is supplied, and the defect is not listed in CISA KEV, which suggests limited public exploitation data at present. The likely attack vector is local; a malicious user with the ability to load a BPF program that iterates over a sk_storage map that contains sockets in the process of being closed could trigger the flaw. Without an official patch, the situation remains a critical kernel flaw that should be addressed promptly.

Remediation

No solution or workaround provided in the CVE record.

OpenCVE Recommended Actions

  • Apply the latest Linux kernel update that fixes the BPF sk_storage map iterator use‑after‑free.
  • If a patch is not yet available, restrict or disable the use of BPF programs that access the sk_storage map or configure the kernel to block unverified BPF programs from iterating over socket storage.
  • Audit kernel logs for BPF-related errors and consider enabling kernel memory protection features such as KASLR and CONFIG_BPF_SYSCALL to reduce the impact of kernel memory corruption.

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

Tracking

Sign in to view the affected projects.

Advisories

No advisories available
History
Type Values Removed Values Added
Weaknesses CWE-416
Type Values Removed Values Added
Description In the Linux kernel, the following vulnerability has been resolved: bpf: Hold the socket in the sk_storage map iterator The iterator over a sk_storage map passes the owner of an element to its program as ctx->sk, without a reference. All that it holds is the RCU read lock, which keeps the element and the storage, not the socket. An element is unlinked by bpf_sk_storage_free(), which __sk_destruct() calls right before it frees the socket. That is no better for a socket with SOCK_RCU_FREE: the grace period comes in front of __sk_destruct(), so a reader which starts behind call_rcu() still finds the element. The program and the helpers it hands ctx->sk to, such as bpf_sk_storage_get() or bpf_sk_storage_delete(), use a socket which is being freed on another CPU. It takes nothing but reading the iterator while sockets with an element in the map are closed, by whomever. Take a reference for the time of the program, and skip the element if there is none to be had. To look at the owner at all, do what bpf_selem_unlink_nofail() does for bpf_local_storage_map_free(): as long as the element is linked under the lock of the storage, bpf_local_storage_destroy() has not got past it, unless it has given up on the lock, and then it waits for owner_refcnt. The last reference may now be dropped by the iterator. The end of a socket may want process context: rfcomm_sock_destruct() takes a mutex. So only drop the reference under RCU, and free a socket whose last one it was when the RCU read lock has been released, which is at the end of a bucket and of every read() at the latest.
Title bpf: Hold the socket in the sk_storage map 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