{"id":"CVE-2026-139313","state":"PUBLISHED","title":"bpf: Clear sk_refcnt of a clone before its storage is linked","description":"In the Linux kernel, the following vulnerability has been resolved:\n\nbpf: Clear sk_refcnt of a clone before its storage is linked\n\nsk_clone() sets sk_refcnt of the new socket some lines behind\nbpf_sk_storage_clone(). But the elements which that function copies are\nlinked to their maps at once, and an element leads to its owner: the\niterator over a sk_storage map hands the owner to its program.\nbpf_sk_storage_get() with BPF_SK_STORAGE_GET_F_CREATE and\nbpf_sk_storage_delete() rely on refcount_inc_not_zero() to tell whether\nthey may touch the socket.\n\nsk_refcnt is in the part of struct sock which sock_copy() leaves out, and\nsk_prot_alloc() does not clear a clone unless init_on_alloc is on. It is\nzero in an object which has been a socket before, and anything in one\nwhich has not. If it is not zero, a helper gets a reference which\nrefcount_set() wipes out, and the helper's sock_put() then drops one of\nthe two references of the new socket, which is freed too early:\n\n  IPv4: Attempt to release TCP socket in state 1\n  BUG: KASAN: slab-use-after-free in __raw_spin_lock_init+0x47/0x90\n\nIn the meantime the helper changes a storage which bpf_sk_storage_clone()\nfills without taking its lock.\n\nNothing else can find the clone at this point. Say that it is not alive\nyet, before the first element is linked. Sockets whose parent has no\nstorage are left alone.","publishedAt":"2026-11-30T13:33:35.937Z","updatedAt":"2026-11-30T13:33:35.937Z","severity":null,"assigner":"Linux","products":["Linux Linux"],"affected":[{"vendor":"Linux","product":"Linux","defaultStatus":"unaffected","versions":[{"version":"a50a85e40c59cf27ca3b324a5aa4c7f35314f251","status":"affected","lessThan":"fc6d7288e0521de69b6e130278563138551e5c7e","versionType":"git"},{"version":"a50a85e40c59cf27ca3b324a5aa4c7f35314f251","status":"affected","lessThan":"856649a34a66e1e485ecfee12d0f9e7f02896d52","versionType":"git"},{"version":"a50a85e40c59cf27ca3b324a5aa4c7f35314f251","status":"affected","lessThan":"1e49688900d8bddc0cf626ba5cc780c34b58ef58","versionType":"git"},{"version":"a50a85e40c59cf27ca3b324a5aa4c7f35314f251","status":"affected","lessThan":"a5b2375d755a6f7841ef25301bc824e089060454","versionType":"git"},{"version":"a50a85e40c59cf27ca3b324a5aa4c7f35314f251","status":"affected","lessThan":"28051395df6e8829f7f168c6eef4a4e411cbbc37","versionType":"git"},{"version":"a50a85e40c59cf27ca3b324a5aa4c7f35314f251","status":"affected","lessThan":"e43a39cdd14639bba5c7b66d1e99ea4948cec04c","versionType":"git"},{"version":"a50a85e40c59cf27ca3b324a5aa4c7f35314f251","status":"affected","lessThan":"22f100bd013458836c3d0eaf8050b854d7534a66","versionType":"git"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["net/core/bpf_sk_storage.c"]},{"vendor":"Linux","product":"Linux","defaultStatus":"affected","versions":[{"version":"5.11","status":"affected"},{"version":"0","status":"unaffected","lessThan":"5.11","versionType":"semver"},{"version":"5.15.226","status":"unaffected","lessThanOrEqual":"5.15.*","versionType":"semver"},{"version":"6.1.193","status":"unaffected","lessThanOrEqual":"6.1.*","versionType":"semver"},{"version":"6.6.163","status":"unaffected","lessThanOrEqual":"6.6.*","versionType":"semver"},{"version":"6.12.119","status":"unaffected","lessThanOrEqual":"6.12.*","versionType":"semver"},{"version":"6.18.65","status":"unaffected","lessThanOrEqual":"6.18.*","versionType":"semver"},{"version":"7.3.6","status":"unaffected","lessThanOrEqual":"7.3.*","versionType":"semver"},{"version":"7.4-rc1","status":"unaffected","lessThanOrEqual":"*","versionType":"original_commit_for_fix"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["net/core/bpf_sk_storage.c"]}],"references":["https://git.kernel.org/stable/c/fc6d7288e0521de69b6e130278563138551e5c7e","https://git.kernel.org/stable/c/856649a34a66e1e485ecfee12d0f9e7f02896d52","https://git.kernel.org/stable/c/1e49688900d8bddc0cf626ba5cc780c34b58ef58","https://git.kernel.org/stable/c/a5b2375d755a6f7841ef25301bc824e089060454","https://git.kernel.org/stable/c/28051395df6e8829f7f168c6eef4a4e411cbbc37","https://git.kernel.org/stable/c/e43a39cdd14639bba5c7b66d1e99ea4948cec04c","https://git.kernel.org/stable/c/22f100bd013458836c3d0eaf8050b854d7534a66"],"weaknesses":[],"ingestedAt":"2026-11-30T13:46:04.484Z","source":{"repository":"CVEProject/cvelistV5","path":"cves/2026/139xxx/CVE-2026-139313.json","commit":"8c2c22940a0de21d18737df980299c0488d5dc73","baselineCommit":"556c9d3a8cd17e218bb8e452ba7cd619a384ff47"},"raw":{"dataType":"CVE_RECORD","dataVersion":"5.2","cveMetadata":{"cveId":"CVE-2026-139313","state":"PUBLISHED","datePublished":"2026-11-30T13:33:35.937Z","dateUpdated":"2026-11-30T13:33:35.937Z","assignerShortName":"Linux","assignerOrgId":"416baaa9-dc9f-4396-8d5f-8c081fb06d67","dateReserved":"2026-11-30T13:22:15.926Z"},"containers":{"cna":{"title":"bpf: Clear sk_refcnt of a clone before its storage is linked","descriptions":[{"lang":"en","value":"In the Linux kernel, the following vulnerability has been resolved:\n\nbpf: Clear sk_refcnt of a clone before its storage is linked\n\nsk_clone() sets sk_refcnt of the new socket some lines behind\nbpf_sk_storage_clone(). But the elements which that function copies are\nlinked to their maps at once, and an element leads to its owner: the\niterator over a sk_storage map hands the owner to its program.\nbpf_sk_storage_get() with BPF_SK_STORAGE_GET_F_CREATE and\nbpf_sk_storage_delete() rely on refcount_inc_not_zero() to tell whether\nthey may touch the socket.\n\nsk_refcnt is in the part of struct sock which sock_copy() leaves out, and\nsk_prot_alloc() does not clear a clone unless init_on_alloc is on. It is\nzero in an object which has been a socket before, and anything in one\nwhich has not. If it is not zero, a helper gets a reference which\nrefcount_set() wipes out, and the helper's sock_put() then drops one of\nthe two references of the new socket, which is freed too early:\n\n  IPv4: Attempt to release TCP socket in state 1\n  BUG: KASAN: slab-use-after-free in __raw_spin_lock_init+0x47/0x90\n\nIn the meantime the helper changes a storage which bpf_sk_storage_clone()\nfills without taking its lock.\n\nNothing else can find the clone at this point. Say that it is not alive\nyet, before the first element is linked. Sockets whose parent has no\nstorage are left alone."}],"affected":[{"vendor":"Linux","product":"Linux","defaultStatus":"unaffected","versions":[{"version":"a50a85e40c59cf27ca3b324a5aa4c7f35314f251","status":"affected","lessThan":"fc6d7288e0521de69b6e130278563138551e5c7e","versionType":"git"},{"version":"a50a85e40c59cf27ca3b324a5aa4c7f35314f251","status":"affected","lessThan":"856649a34a66e1e485ecfee12d0f9e7f02896d52","versionType":"git"},{"version":"a50a85e40c59cf27ca3b324a5aa4c7f35314f251","status":"affected","lessThan":"1e49688900d8bddc0cf626ba5cc780c34b58ef58","versionType":"git"},{"version":"a50a85e40c59cf27ca3b324a5aa4c7f35314f251","status":"affected","lessThan":"a5b2375d755a6f7841ef25301bc824e089060454","versionType":"git"},{"version":"a50a85e40c59cf27ca3b324a5aa4c7f35314f251","status":"affected","lessThan":"28051395df6e8829f7f168c6eef4a4e411cbbc37","versionType":"git"},{"version":"a50a85e40c59cf27ca3b324a5aa4c7f35314f251","status":"affected","lessThan":"e43a39cdd14639bba5c7b66d1e99ea4948cec04c","versionType":"git"},{"version":"a50a85e40c59cf27ca3b324a5aa4c7f35314f251","status":"affected","lessThan":"22f100bd013458836c3d0eaf8050b854d7534a66","versionType":"git"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["net/core/bpf_sk_storage.c"]},{"vendor":"Linux","product":"Linux","defaultStatus":"affected","versions":[{"version":"5.11","status":"affected"},{"version":"0","status":"unaffected","lessThan":"5.11","versionType":"semver"},{"version":"5.15.226","status":"unaffected","lessThanOrEqual":"5.15.*","versionType":"semver"},{"version":"6.1.193","status":"unaffected","lessThanOrEqual":"6.1.*","versionType":"semver"},{"version":"6.6.163","status":"unaffected","lessThanOrEqual":"6.6.*","versionType":"semver"},{"version":"6.12.119","status":"unaffected","lessThanOrEqual":"6.12.*","versionType":"semver"},{"version":"6.18.65","status":"unaffected","lessThanOrEqual":"6.18.*","versionType":"semver"},{"version":"7.3.6","status":"unaffected","lessThanOrEqual":"7.3.*","versionType":"semver"},{"version":"7.4-rc1","status":"unaffected","lessThanOrEqual":"*","versionType":"original_commit_for_fix"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["net/core/bpf_sk_storage.c"]}],"references":[{"url":"https://git.kernel.org/stable/c/fc6d7288e0521de69b6e130278563138551e5c7e"},{"url":"https://git.kernel.org/stable/c/856649a34a66e1e485ecfee12d0f9e7f02896d52"},{"url":"https://git.kernel.org/stable/c/1e49688900d8bddc0cf626ba5cc780c34b58ef58"},{"url":"https://git.kernel.org/stable/c/a5b2375d755a6f7841ef25301bc824e089060454"},{"url":"https://git.kernel.org/stable/c/28051395df6e8829f7f168c6eef4a4e411cbbc37"},{"url":"https://git.kernel.org/stable/c/e43a39cdd14639bba5c7b66d1e99ea4948cec04c"},{"url":"https://git.kernel.org/stable/c/22f100bd013458836c3d0eaf8050b854d7534a66"}],"providerMetadata":{"shortName":"Linux","orgId":"416baaa9-dc9f-4396-8d5f-8c081fb06d67","dateUpdated":"2026-11-30T13:33:35.937Z"},"cpeApplicability":[{"nodes":[{"operator":"OR","negate":false,"cpeMatch":[{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"5.11","versionEndExcluding":"5.15.226"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"5.11","versionEndExcluding":"6.1.193"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"5.11","versionEndExcluding":"6.6.163"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"5.11","versionEndExcluding":"6.12.119"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"5.11","versionEndExcluding":"6.18.65"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"5.11","versionEndExcluding":"7.3.6"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"5.11","versionEndExcluding":"7.4-rc1"}]}]}],"x_generator":{"engine":"bippy-1.2.0"}}}}}