{"id":"CVE-2026-143377","state":"PUBLISHED","title":"bpf: Drop percpu_counter from the htab element count","description":"In the Linux kernel, the following vulnerability has been resolved:\n\nbpf: Drop percpu_counter from the htab element count\n\nThe element count of a large non-preallocated hash map is a\npercpu_counter, whose slow path takes fbc->lock with\nraw_spin_lock_irqsave(). That is not safe against BPF programs that run\nwhile the lock is held or contended: NMI programs and, as\nqueued_spin_lock_slowpath() calls trace_contention_end() with the lock\nalready held, programs attached to the contention_end tracepoint. If such\na program updates the same map it spins on the lock its own CPU holds:\n\n  WARNING: possible recursive locking detected\n  cend/250 is trying to acquire lock:\n  (key#5){....}-{2:2}, at: _raw_spin_lock_irqsave+0x18/0x30\n  but task is already holding lock:\n  (key#5){....}-{2:2}, at: _raw_spin_lock_irqsave+0x18/0x30\n    percpu_counter_add_batch+0xd8/0x160\n    alloc_htab_elem+0x408/0x480\n    htab_map_update_elem+0x1e8/0x6a0\n    bpf_prog_7a29a1ae68aedf07_cend+0x14c/0x1f8\n    __bpf_trace_contention_end+0x14/0x20\n    queued_spin_lock_slowpath+0x2e8/0x468\n    percpu_counter_add_batch+0xd8/0x160\n    alloc_htab_elem+0x408/0x480\n    htab_map_update_elem+0x1e8/0x6a0\n\nis_map_full() is affected too, as __percpu_counter_compare() falls back\nto percpu_counter_sum(), which takes the same lock.\n\nmap.elem_count already is a lockless per-cpu count of the same elements.\nMake htab->count follow it in steps of PERCPU_COUNTER_BATCH and let\nis_map_full() sum elem_count once count is within nr_cpu_ids * batch of\nmax_entries. Each cpu's elem_count is ahead of count by less than the\nbatch, so that is exact, in NMI as well.","publishedAt":"2026-12-03T09:22:25.137Z","updatedAt":"2026-12-03T09:22:25.137Z","severity":null,"assigner":"Linux","products":["Linux Linux"],"affected":[{"vendor":"Linux","product":"Linux","defaultStatus":"unaffected","versions":[{"version":"86fe28f7692d96d20232af0fc6d7632d5cc89a01","status":"affected","lessThan":"6ddc16d58b40bc3276dcd3f4027df5e9e846d26a","versionType":"git"},{"version":"86fe28f7692d96d20232af0fc6d7632d5cc89a01","status":"affected","lessThan":"d7c38cf0acd70e1d6fe99a59b0b2afc235a9f7de","versionType":"git"},{"version":"86fe28f7692d96d20232af0fc6d7632d5cc89a01","status":"affected","lessThan":"1cd28b5354ab77c727ed87255bf289a87178b415","versionType":"git"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["include/linux/bpf.h","kernel/bpf/hashtab.c"]},{"vendor":"Linux","product":"Linux","defaultStatus":"affected","versions":[{"version":"6.1","status":"affected"},{"version":"0","status":"unaffected","lessThan":"6.1","versionType":"semver"},{"version":"6.18.66","status":"unaffected","lessThanOrEqual":"6.18.*","versionType":"semver"},{"version":"7.3.7","status":"unaffected","lessThanOrEqual":"7.3.*","versionType":"semver"},{"version":"7.4-rc2","status":"unaffected","lessThanOrEqual":"*","versionType":"original_commit_for_fix"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["include/linux/bpf.h","kernel/bpf/hashtab.c"]}],"references":["https://git.kernel.org/stable/c/6ddc16d58b40bc3276dcd3f4027df5e9e846d26a","https://git.kernel.org/stable/c/d7c38cf0acd70e1d6fe99a59b0b2afc235a9f7de","https://git.kernel.org/stable/c/1cd28b5354ab77c727ed87255bf289a87178b415"],"weaknesses":[],"ingestedAt":"2026-12-03T09:44:04.436Z","source":{"repository":"CVEProject/cvelistV5","path":"cves/2026/143xxx/CVE-2026-143377.json","commit":"9e309c7c0f08856e2558a1df33f75dca027fab70","baselineCommit":"556c9d3a8cd17e218bb8e452ba7cd619a384ff47"},"raw":{"dataType":"CVE_RECORD","dataVersion":"5.2","cveMetadata":{"cveId":"CVE-2026-143377","state":"PUBLISHED","datePublished":"2026-12-03T09:22:25.137Z","dateUpdated":"2026-12-03T09:22:25.137Z","assignerShortName":"Linux","assignerOrgId":"416baaa9-dc9f-4396-8d5f-8c081fb06d67","dateReserved":"2026-12-03T03:10:28.372Z"},"containers":{"cna":{"title":"bpf: Drop percpu_counter from the htab element count","descriptions":[{"lang":"en","value":"In the Linux kernel, the following vulnerability has been resolved:\n\nbpf: Drop percpu_counter from the htab element count\n\nThe element count of a large non-preallocated hash map is a\npercpu_counter, whose slow path takes fbc->lock with\nraw_spin_lock_irqsave(). That is not safe against BPF programs that run\nwhile the lock is held or contended: NMI programs and, as\nqueued_spin_lock_slowpath() calls trace_contention_end() with the lock\nalready held, programs attached to the contention_end tracepoint. If such\na program updates the same map it spins on the lock its own CPU holds:\n\n  WARNING: possible recursive locking detected\n  cend/250 is trying to acquire lock:\n  (key#5){....}-{2:2}, at: _raw_spin_lock_irqsave+0x18/0x30\n  but task is already holding lock:\n  (key#5){....}-{2:2}, at: _raw_spin_lock_irqsave+0x18/0x30\n    percpu_counter_add_batch+0xd8/0x160\n    alloc_htab_elem+0x408/0x480\n    htab_map_update_elem+0x1e8/0x6a0\n    bpf_prog_7a29a1ae68aedf07_cend+0x14c/0x1f8\n    __bpf_trace_contention_end+0x14/0x20\n    queued_spin_lock_slowpath+0x2e8/0x468\n    percpu_counter_add_batch+0xd8/0x160\n    alloc_htab_elem+0x408/0x480\n    htab_map_update_elem+0x1e8/0x6a0\n\nis_map_full() is affected too, as __percpu_counter_compare() falls back\nto percpu_counter_sum(), which takes the same lock.\n\nmap.elem_count already is a lockless per-cpu count of the same elements.\nMake htab->count follow it in steps of PERCPU_COUNTER_BATCH and let\nis_map_full() sum elem_count once count is within nr_cpu_ids * batch of\nmax_entries. Each cpu's elem_count is ahead of count by less than the\nbatch, so that is exact, in NMI as well."}],"affected":[{"vendor":"Linux","product":"Linux","defaultStatus":"unaffected","versions":[{"version":"86fe28f7692d96d20232af0fc6d7632d5cc89a01","status":"affected","lessThan":"6ddc16d58b40bc3276dcd3f4027df5e9e846d26a","versionType":"git"},{"version":"86fe28f7692d96d20232af0fc6d7632d5cc89a01","status":"affected","lessThan":"d7c38cf0acd70e1d6fe99a59b0b2afc235a9f7de","versionType":"git"},{"version":"86fe28f7692d96d20232af0fc6d7632d5cc89a01","status":"affected","lessThan":"1cd28b5354ab77c727ed87255bf289a87178b415","versionType":"git"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["include/linux/bpf.h","kernel/bpf/hashtab.c"]},{"vendor":"Linux","product":"Linux","defaultStatus":"affected","versions":[{"version":"6.1","status":"affected"},{"version":"0","status":"unaffected","lessThan":"6.1","versionType":"semver"},{"version":"6.18.66","status":"unaffected","lessThanOrEqual":"6.18.*","versionType":"semver"},{"version":"7.3.7","status":"unaffected","lessThanOrEqual":"7.3.*","versionType":"semver"},{"version":"7.4-rc2","status":"unaffected","lessThanOrEqual":"*","versionType":"original_commit_for_fix"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["include/linux/bpf.h","kernel/bpf/hashtab.c"]}],"references":[{"url":"https://git.kernel.org/stable/c/6ddc16d58b40bc3276dcd3f4027df5e9e846d26a"},{"url":"https://git.kernel.org/stable/c/d7c38cf0acd70e1d6fe99a59b0b2afc235a9f7de"},{"url":"https://git.kernel.org/stable/c/1cd28b5354ab77c727ed87255bf289a87178b415"}],"providerMetadata":{"shortName":"Linux","orgId":"416baaa9-dc9f-4396-8d5f-8c081fb06d67","dateUpdated":"2026-12-03T09:22:25.137Z"},"cpeApplicability":[{"nodes":[{"operator":"OR","negate":false,"cpeMatch":[{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"6.1","versionEndExcluding":"6.18.66"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"6.1","versionEndExcluding":"7.3.7"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"6.1","versionEndExcluding":"7.4-rc2"}]}]}],"x_generator":{"engine":"bippy-1.2.0"}}}}}