{"id":"CVE-2026-139310","summary":"bpf: Hold the socket in the sk_storage map iterator","details":"In the Linux kernel, the following vulnerability has been resolved:\n\nbpf: Hold the socket in the sk_storage map iterator\n\nThe iterator over a sk_storage map passes the owner of an element to its\nprogram as ctx-\u003esk, without a reference. All that it holds is the RCU read\nlock, which keeps the element and the storage, not the socket.\n\nAn element is unlinked by bpf_sk_storage_free(), which __sk_destruct()\ncalls right before it frees the socket. That is no better for a socket\nwith SOCK_RCU_FREE: the grace period comes in front of __sk_destruct(),\nso a reader which starts behind call_rcu() still finds the element. The\nprogram and the helpers it hands ctx-\u003esk to, such as\nbpf_sk_storage_get() or bpf_sk_storage_delete(), use a socket which is\nbeing freed on another CPU. It takes nothing but reading the iterator\nwhile sockets with an element in the map are closed, by whomever.\n\nTake a reference for the time of the program, and skip the element if\nthere is none to be had. To look at the owner at all, do what\nbpf_selem_unlink_nofail() does for bpf_local_storage_map_free(): as long\nas the element is linked under the lock of the storage,\nbpf_local_storage_destroy() has not got past it, unless it has given up\non the lock, and then it waits for owner_refcnt.\n\nThe last reference may now be dropped by the iterator. The end of a socket\nmay want process context: rfcomm_sock_destruct() takes a mutex. So only\ndrop the reference under RCU, and free a socket whose last one it was when\nthe RCU read lock has been released, which is at the end of a bucket and\nof every read() at the latest.","modified":"2026-12-01T21:02:37.501412003Z","published":"2026-11-30T13:33:34.331Z","database_specific":{"cna_assigner":"Linux","osv_generated_from":"https://github.com/CVEProject/cvelistV5/tree/main/cves/2026/139xxx/CVE-2026-139310.json"},"references":[{"type":"WEB","url":"https://git.kernel.org/stable/c/070a96b2a98f66087797d8a31d53126de7a5208f"},{"type":"WEB","url":"https://git.kernel.org/stable/c/32370eec7c35c3d03df48e42b2bd35834d1af604"},{"type":"ADVISORY","url":"https://github.com/CVEProject/cvelistV5/tree/main/cves/2026/139xxx/CVE-2026-139310.json"},{"type":"ADVISORY","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-139310"},{"type":"PACKAGE","url":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git"}],"affected":[{"ranges":[{"type":"GIT","repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","events":[{"introduced":"c69d2ddb2072eb7ffca1a31ee5ddc16dcd414ed9"},{"fixed":"32370eec7c35c3d03df48e42b2bd35834d1af604"},{"fixed":"070a96b2a98f66087797d8a31d53126de7a5208f"}]}],"database_specific":{"source":"https://storage.googleapis.com/cve-osv-conversion/osv-output/CVE-2026-139310.json"}},{"package":{"name":"Kernel","ecosystem":"Linux"},"ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"5.10.0"},{"fixed":"7.3.6"}]}],"database_specific":{"source":"https://storage.googleapis.com/cve-osv-conversion/osv-output/CVE-2026-139310.json"}}],"schema_version":"1.9.2"}