# CVE-2024-58070: bpf: bpf_local_storage: Always use bpf_mem_alloc in PREEMPT_RT

- Severity: High 7.8 (CVSS:3.1, scored by Linux) `CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H`
- Known to be exploited: not in CISA's catalogue, which lists only what CISA has confirmed
- Likelihood of exploitation in the next 30 days (EPSS): 0.15%, higher than 4% of CVEs (2026-12-01)
- Published: 2025-03-06T15:54:10.166Z
- Modified: 2026-08-05T11:47:33.069Z
- Weaknesses: CWE-667
- SSVC (CISA-ADP): exploitation none, automatable no, technical impact partial
- Assigned by: Linux

## Description

In the Linux kernel, the following vulnerability has been resolved:

bpf: bpf_local_storage: Always use bpf_mem_alloc in PREEMPT_RT

In PREEMPT_RT, kmalloc(GFP_ATOMIC) is still not safe in non preemptible
context. bpf_mem_alloc must be used in PREEMPT_RT. This patch is
to enforce bpf_mem_alloc in the bpf_local_storage when CONFIG_PREEMPT_RT
is enabled.

[   35.118559] BUG: sleeping function called from invalid context at kernel/locking/spinlock_rt.c:48
[   35.118566] in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 1832, name: test_progs
[   35.118569] preempt_count: 1, expected: 0
[   35.118571] RCU nest depth: 1, expected: 1
[   35.118577] INFO: lockdep is turned off.
    ...
[   35.118647]  __might_resched+0x433/0x5b0
[   35.118677]  rt_spin_lock+0xc3/0x290
[   35.118700]  ___slab_alloc+0x72/0xc40
[   35.118723]  __kmalloc_noprof+0x13f/0x4e0
[   35.118732]  bpf_map_kzalloc+0xe5/0x220
[   35.118740]  bpf_selem_alloc+0x1d2/0x7b0
[   35.118755]  bpf_local_storage_update+0x2fa/0x8b0
[   35.118784]  bpf_sk_storage_get_tracing+0x15a/0x1d0
[   35.118791]  bpf_prog_9a118d86fca78ebb_trace_inet_sock_set_state+0x44/0x66
[   35.118795]  bpf_trace_run3+0x222/0x400
[   35.118820]  __bpf_trace_inet_sock_set_state+0x11/0x20
[   35.118824]  trace_inet_sock_set_state+0x112/0x130
[   35.118830]  inet_sk_state_store+0x41/0x90
[   35.118836]  tcp_set_state+0x3b3/0x640

There is no need to adjust the gfp_flags passing to the
bpf_mem_cache_alloc_flags() which only honors the GFP_KERNEL.
The verifier has ensured GFP_KERNEL is passed only in sleepable context.

It has been an old issue since the first introduction of the
bpf_local_storage ~5 years ago, so this patch targets the bpf-next.

bpf_mem_alloc is needed to solve it, so the Fixes tag is set
to the commit when bpf_mem_alloc was first used in the bpf_local_storage.

(As written by CVE List.)

## Affected

- Linux Linux: from 08a7ce384e33e53e0732c500a8af67a73f8fceca before 3392fa605d7c5708c5fbe02e4fbdac547c3b7352; from 08a7ce384e33e53e0732c500a8af67a73f8fceca before b0027500000dfcb8ee952557d565064cea22c43e; from 08a7ce384e33e53e0732c500a8af67a73f8fceca before c1d398a3af7e59d7fef351c84fed7ebb575d1f1a; from 08a7ce384e33e53e0732c500a8af67a73f8fceca before 8eef6ac4d70eb1f0099fff93321d90ce8fa49ee1; 6.4 (not affected: before 6.4; from 6.6.76 up to 6.6.*; from 6.12.13 up to 6.12.*; from 6.13.2 up to 6.13.*; from 6.14 up to *)
- linux linux_kernel: from 6.4 before 6.6.76; from 6.7 before 6.12.13; from 6.13 before 6.13.2

## Every score

- Linux: CVSS:3.1 7.8 High `CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H`
- CISA-ADP: CVSS:3.1 5.5 Medium `CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H`
- NVD: CVSS:3.1 5.5 Medium `CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H`

## References

- <https://git.kernel.org/stable/c/3392fa605d7c5708c5fbe02e4fbdac547c3b7352> (patch)
- <https://git.kernel.org/stable/c/b0027500000dfcb8ee952557d565064cea22c43e> (patch)
- <https://git.kernel.org/stable/c/c1d398a3af7e59d7fef351c84fed7ebb575d1f1a> (patch)
- <https://git.kernel.org/stable/c/8eef6ac4d70eb1f0099fff93321d90ce8fa49ee1> (patch)

## Sources

- CVE List: [CVE-2024-58070](https://www.cve.org/CVERecord?id=CVE-2024-58070), CVE Terms of Use, modified 2026-08-05
- NVD: [CVE-2024-58070](https://nvd.nist.gov/vuln/detail/CVE-2024-58070), Public domain, modified 2026-08-04

---

Page: https://cve.day/CVE-2024-58070 · Whole record: https://cve.day/CVE-2024-58070.json · Rebuilt by cve.day 2026-11-25T22:58:52.216Z
