{"id":"CVE-2026-139323","state":"PUBLISHED","title":"bpf: Don't hand out a linked element as extra element","description":"In the Linux kernel, the following vulnerability has been resolved:\n\nbpf: Don't hand out a linked element as extra element\n\nWhen htab_map_update_elem() replaces an element of a preallocated map,\nalloc_htab_elem() takes the spare element of this cpu and puts the old\nelement into the per-cpu slot right away, long before the old element is\nunlinked from its bucket.  The bucket lock disables interrupts, but it\ndoes not keep out an NMI, or a tracing program on the return of\nalloc_htab_elem().  bpf_prog_active only helps if both programs are\nkprobe, tracepoint or perf_event programs.  A program that updates an\nexisting key in another bucket of the same map gets to use the slot:\n\n  htab_map_update_elem(k1)              tc, xdp, fentry, raw_tp, ...\n    alloc_htab_elem()\n      l_new = *pl_new\n      *pl_new = l_old                   still linked in bucket 1\n      <NMI>\n        htab_map_update_elem(k2)        perf_event program\n          l_new = *pl_new               the l_old of the outer update\n          hlist_nulls_add_head_rcu(l_new, bucket 2)\n          hlist_nulls_del_rcu(k2's old element)\n      </NMI>\n    hlist_nulls_add_head_rcu(l_new, bucket 1)\n    hlist_nulls_del_rcu(l_old)\n\nIf l_old was the first element of bucket 1, the outer add points its pprev\nat l_new, and the delete takes it out of bucket 1 only.  l_new->next now\nleads into bucket 2, where l_old stays with a poisoned pprev, on which a\ndelete of k2 crashes.  If it was not the first, the delete takes it out of\nbucket 2: k2 is gone from the map, and the chain of bucket 1 still contains\nl_old, whose next pointer leads into bucket 2.\n\nEither way a walk of bucket 1 ends on the nulls value of bucket 2.\nlookup_nulls_elem_raw() restarts whenever that happens, so every lookup in\nbucket 1 which does not find its key spins forever:\n\n  rcu: INFO: rcu_preempt detected stalls on CPUs/tasks:\n   __htab_map_lookup_elem+0x354/0x4d0\n\n  BUG: KASAN: wild-memory-access in htab_map_delete_elem+0x30c/0x670\n  Write of size 8 at addr dead000000000122 by task extra/102\n\nAn NMI between the load and the store of the slot makes both updates use\nthe same element, with much the same result.\n\nEmpty the slot when the spare element is taken, in a way that is atomic\non this cpu, and put the old element in only after it has been unlinked\nand its timers and the like have been cancelled.  A nested update that\nfinds the slot empty, which is the case that corrupted the map, fails with\n-EBUSY.","publishedAt":"2026-11-30T13:33:42.100Z","updatedAt":"2026-11-30T13:33:42.100Z","severity":null,"assigner":"Linux","products":["Linux Linux"],"affected":[{"vendor":"Linux","product":"Linux","defaultStatus":"unaffected","versions":[{"version":"8c290e60fa2a51806159522331c9ed41252a8fb3","status":"affected","lessThan":"45dfd3617c74ffff6633d136815f193597a817cd","versionType":"git"},{"version":"8c290e60fa2a51806159522331c9ed41252a8fb3","status":"affected","lessThan":"00ea598142f5bdf6c4f3da2f8e66cbbd2ec2c60d","versionType":"git"},{"version":"8c290e60fa2a51806159522331c9ed41252a8fb3","status":"affected","lessThan":"103d8a81021b1d7dbec91c339d5b5b7a4184aa89","versionType":"git"},{"version":"8c290e60fa2a51806159522331c9ed41252a8fb3","status":"affected","lessThan":"ccb88db8dac8fabde58656d5d4a33711e89c480a","versionType":"git"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["kernel/bpf/hashtab.c"]},{"vendor":"Linux","product":"Linux","defaultStatus":"affected","versions":[{"version":"4.11","status":"affected"},{"version":"0","status":"unaffected","lessThan":"4.11","versionType":"semver"},{"version":"6.12.120","status":"unaffected","lessThanOrEqual":"6.12.*","versionType":"semver"},{"version":"6.18.66","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":["kernel/bpf/hashtab.c"]}],"references":["https://git.kernel.org/stable/c/45dfd3617c74ffff6633d136815f193597a817cd","https://git.kernel.org/stable/c/00ea598142f5bdf6c4f3da2f8e66cbbd2ec2c60d","https://git.kernel.org/stable/c/103d8a81021b1d7dbec91c339d5b5b7a4184aa89","https://git.kernel.org/stable/c/ccb88db8dac8fabde58656d5d4a33711e89c480a"],"weaknesses":[],"ingestedAt":"2026-11-30T13:46:04.484Z","source":{"repository":"CVEProject/cvelistV5","path":"cves/2026/139xxx/CVE-2026-139323.json","commit":"8c2c22940a0de21d18737df980299c0488d5dc73","baselineCommit":"556c9d3a8cd17e218bb8e452ba7cd619a384ff47"},"raw":{"dataType":"CVE_RECORD","dataVersion":"5.2","cveMetadata":{"cveId":"CVE-2026-139323","state":"PUBLISHED","datePublished":"2026-11-30T13:33:42.100Z","dateUpdated":"2026-11-30T13:33:42.100Z","assignerShortName":"Linux","assignerOrgId":"416baaa9-dc9f-4396-8d5f-8c081fb06d67","dateReserved":"2026-11-30T13:22:15.927Z"},"containers":{"cna":{"title":"bpf: Don't hand out a linked element as extra element","descriptions":[{"lang":"en","value":"In the Linux kernel, the following vulnerability has been resolved:\n\nbpf: Don't hand out a linked element as extra element\n\nWhen htab_map_update_elem() replaces an element of a preallocated map,\nalloc_htab_elem() takes the spare element of this cpu and puts the old\nelement into the per-cpu slot right away, long before the old element is\nunlinked from its bucket.  The bucket lock disables interrupts, but it\ndoes not keep out an NMI, or a tracing program on the return of\nalloc_htab_elem().  bpf_prog_active only helps if both programs are\nkprobe, tracepoint or perf_event programs.  A program that updates an\nexisting key in another bucket of the same map gets to use the slot:\n\n  htab_map_update_elem(k1)              tc, xdp, fentry, raw_tp, ...\n    alloc_htab_elem()\n      l_new = *pl_new\n      *pl_new = l_old                   still linked in bucket 1\n      <NMI>\n        htab_map_update_elem(k2)        perf_event program\n          l_new = *pl_new               the l_old of the outer update\n          hlist_nulls_add_head_rcu(l_new, bucket 2)\n          hlist_nulls_del_rcu(k2's old element)\n      </NMI>\n    hlist_nulls_add_head_rcu(l_new, bucket 1)\n    hlist_nulls_del_rcu(l_old)\n\nIf l_old was the first element of bucket 1, the outer add points its pprev\nat l_new, and the delete takes it out of bucket 1 only.  l_new->next now\nleads into bucket 2, where l_old stays with a poisoned pprev, on which a\ndelete of k2 crashes.  If it was not the first, the delete takes it out of\nbucket 2: k2 is gone from the map, and the chain of bucket 1 still contains\nl_old, whose next pointer leads into bucket 2.\n\nEither way a walk of bucket 1 ends on the nulls value of bucket 2.\nlookup_nulls_elem_raw() restarts whenever that happens, so every lookup in\nbucket 1 which does not find its key spins forever:\n\n  rcu: INFO: rcu_preempt detected stalls on CPUs/tasks:\n   __htab_map_lookup_elem+0x354/0x4d0\n\n  BUG: KASAN: wild-memory-access in htab_map_delete_elem+0x30c/0x670\n  Write of size 8 at addr dead000000000122 by task extra/102\n\nAn NMI between the load and the store of the slot makes both updates use\nthe same element, with much the same result.\n\nEmpty the slot when the spare element is taken, in a way that is atomic\non this cpu, and put the old element in only after it has been unlinked\nand its timers and the like have been cancelled.  A nested update that\nfinds the slot empty, which is the case that corrupted the map, fails with\n-EBUSY."}],"affected":[{"vendor":"Linux","product":"Linux","defaultStatus":"unaffected","versions":[{"version":"8c290e60fa2a51806159522331c9ed41252a8fb3","status":"affected","lessThan":"45dfd3617c74ffff6633d136815f193597a817cd","versionType":"git"},{"version":"8c290e60fa2a51806159522331c9ed41252a8fb3","status":"affected","lessThan":"00ea598142f5bdf6c4f3da2f8e66cbbd2ec2c60d","versionType":"git"},{"version":"8c290e60fa2a51806159522331c9ed41252a8fb3","status":"affected","lessThan":"103d8a81021b1d7dbec91c339d5b5b7a4184aa89","versionType":"git"},{"version":"8c290e60fa2a51806159522331c9ed41252a8fb3","status":"affected","lessThan":"ccb88db8dac8fabde58656d5d4a33711e89c480a","versionType":"git"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["kernel/bpf/hashtab.c"]},{"vendor":"Linux","product":"Linux","defaultStatus":"affected","versions":[{"version":"4.11","status":"affected"},{"version":"0","status":"unaffected","lessThan":"4.11","versionType":"semver"},{"version":"6.12.120","status":"unaffected","lessThanOrEqual":"6.12.*","versionType":"semver"},{"version":"6.18.66","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":["kernel/bpf/hashtab.c"]}],"references":[{"url":"https://git.kernel.org/stable/c/45dfd3617c74ffff6633d136815f193597a817cd"},{"url":"https://git.kernel.org/stable/c/00ea598142f5bdf6c4f3da2f8e66cbbd2ec2c60d"},{"url":"https://git.kernel.org/stable/c/103d8a81021b1d7dbec91c339d5b5b7a4184aa89"},{"url":"https://git.kernel.org/stable/c/ccb88db8dac8fabde58656d5d4a33711e89c480a"}],"providerMetadata":{"shortName":"Linux","orgId":"416baaa9-dc9f-4396-8d5f-8c081fb06d67","dateUpdated":"2026-11-30T13:33:42.100Z"},"cpeApplicability":[{"nodes":[{"operator":"OR","negate":false,"cpeMatch":[{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"4.11","versionEndExcluding":"6.12.120"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"4.11","versionEndExcluding":"6.18.66"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"4.11","versionEndExcluding":"7.3.6"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"4.11","versionEndExcluding":"7.4-rc1"}]}]}],"x_generator":{"engine":"bippy-1.2.0"}}}}}