CVE-2026-139313

bpf: Clear sk_refcnt of a clone before its storage is linked

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: Clear sk_refcnt of a clone before its storage is linked

sk_clone() sets sk_refcnt of the new socket some lines behind
bpf_sk_storage_clone(). But the elements which that function copies are
linked to their maps at once, and an element leads to its owner: the
iterator over a sk_storage map hands the owner to its program.
bpf_sk_storage_get() with BPF_SK_STORAGE_GET_F_CREATE and
bpf_sk_storage_delete() rely on refcount_inc_not_zero() to tell whether
they may touch the socket.

sk_refcnt is in the part of struct sock which sock_copy() leaves out, and
sk_prot_alloc() does not clear a clone unless init_on_alloc is on. It is
zero in an object which has been a socket before, and anything in one
which has not. If it is not zero, a helper gets a reference which
refcount_set() wipes out, and the helper's sock_put() then drops one of
the two references of the new socket, which is freed too early:

IPv4: Attempt to release TCP socket in state 1
BUG: KASAN: slab-use-after-free in __raw_spin_lock_init+0x47/0x90

In the meantime the helper changes a storage which bpf_sk_storage_clone()
fills without taking its lock.

Nothing else can find the clone at this point. Say that it is not alive
yet, before the first element is linked. Sockets whose parent has no
storage are left alone.

Analysis

AI-generated

Technical impact

The flaw occurs when the kernel clones a socket for BPF storage and fails to clear the reference counter before the clone is linked. As a result, a helper can obtain a reference that is later wiped out, and the socket is freed prematurely. The premature free triggers a kernel memory corruption and a KASAN use‑after‑free error, which can lead to a kernel panic and allows an attacker to gain elevated privileges if the fault is exploited during privileged code execution.

Affected Systems

This defect exists in all Linux kernel implementations that expose the BPF socket storage interface. The impact applies to systems running any Linux kernel version that has not applied the commit referenced in the supplied URLs. The vendor product is Linux kernel itself, affecting all distributions that ship unpatched kernels.

Risk and Exploitability

The CVSS score is not provided, but a use‑after‑free in kernel space is high severity and could be exploited via a malicious BPF program. The EPSS score is unavailable, and the vulnerability is not listed in the CISA KEV catalog. Likely exploitation requires a BPF payload that creates and operates on a socket clone before the storage is linked, which is difficult but possible for a user with permission to load BPF programs. The vulnerability is local in nature and would likely need elevated privileges or an environment where BPF programs can run unrestrained.

Remediation

No solution or workaround provided in the CVE record.

OpenCVE Recommended Actions

  • Upgrade the Linux kernel to a fixed version that incorporates the bpf socket storage reference‑count fix, ensuring the relevant commit identifiers are applied in your distribution's kernel package.
  • Restrict the ability to load BPF programs for unprivileged users, or enforce CAP_BPF limits so that only trusted code can trigger the vulnerable path.
  • Monitor kernel logs for KASAN or use‑after‑free messages such as "slab-use-after-free in __raw_spin_lock_init" and consider enabling kernel memory protection options (CONFIG_KASAN, CONFIG_DEBUG_SPINLOCK) to catch similar issues early.

Generated by OpenCVE AI on November 30, 2026 at 21:45 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: Clear sk_refcnt of a clone before its storage is linked sk_clone() sets sk_refcnt of the new socket some lines behind bpf_sk_storage_clone(). But the elements which that function copies are linked to their maps at once, and an element leads to its owner: the iterator over a sk_storage map hands the owner to its program. bpf_sk_storage_get() with BPF_SK_STORAGE_GET_F_CREATE and bpf_sk_storage_delete() rely on refcount_inc_not_zero() to tell whether they may touch the socket. sk_refcnt is in the part of struct sock which sock_copy() leaves out, and sk_prot_alloc() does not clear a clone unless init_on_alloc is on. It is zero in an object which has been a socket before, and anything in one which has not. If it is not zero, a helper gets a reference which refcount_set() wipes out, and the helper's sock_put() then drops one of the two references of the new socket, which is freed too early: IPv4: Attempt to release TCP socket in state 1 BUG: KASAN: slab-use-after-free in __raw_spin_lock_init+0x47/0x90 In the meantime the helper changes a storage which bpf_sk_storage_clone() fills without taking its lock. Nothing else can find the clone at this point. Say that it is not alive yet, before the first element is linked. Sockets whose parent has no storage are left alone.
Title bpf: Clear sk_refcnt of a clone before its storage is linked
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