CVE-2024-58070: bpf: bpf_local_storage: Always use bpf_mem_alloc in PREEMPT_RT
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.
Security readout for executives and security teams
Plain-English summary
This Linux kernel issue can crash or destabilize affected real-time kernels when BPF local storage allocates memory in a context where sleeping is unsafe. The impact is availability only: the sources do not indicate data theft, privilege escalation, or active exploitation.
Executive priority
Treat as a moderate availability risk. Prioritize real-time Linux hosts where downtime matters, especially systems allowing local users or BPF-based monitoring. No evidence in the bundle supports emergency response for active exploitation.
Technical view
In CONFIG_PREEMPT_RT kernels, bpf_local_storage could use kmalloc(GFP_ATOMIC) in non-preemptible context, triggering a sleeping-function-in-invalid-context bug. The fix enforces bpf_mem_alloc for BPF local storage when PREEMPT_RT is enabled. CVSS is 5.5 with local, low-complexity, low-privilege availability impact.
Likely exposure
Exposure is most likely on Linux systems running PREEMPT_RT kernels with BPF local storage activity. Source version data identifies Linux as affected and references stable kernel fixes, but does not provide distribution-specific package status or CPEs.
Exploitation context
The bundle does not show CISA KEV listing or active exploitation. The CVSS vector requires local low-privilege access and no user interaction. Practical risk depends on local BPF permissions, real-time kernel usage, and vendor backport status.
Researcher notes
The kernel report attributes the bug to PREEMPT_RT allocation semantics in BPF local storage and notes it is an old issue. Evidence is sufficient for root cause and fix direction, but incomplete for distribution impact, exploitability in hardened environments, and real-world abuse.
Mitigation direction
Apply vendor kernel updates that include the referenced stable fixes.
Check Linux distribution advisories for package-specific fixed versions.
Restrict untrusted local access on affected real-time kernel systems.
Review and harden local BPF loading permissions where operationally feasible.
Prioritize patching systems using PREEMPT_RT and BPF observability workloads.
Validation and detection
Identify systems running Linux kernels with CONFIG_PREEMPT_RT enabled.
Compare installed kernel builds against vendor advisories and referenced stable commits.
Inventory systems using BPF local storage or tracing programs.
Review kernel logs for sleeping-function or bpf_local_storage related warnings.
Confirm patched kernels are deployed after maintenance.
Generated from the cited source records. This long-tail analysis has not been individually reviewed by a named human.
Potential ATT&CK relevance
Conservative CVE-to-ATT&CK context
These mappings and lookup hints may be relevant to the vulnerability behavior, CWE, affected product, or exposure path. Glexia-inferred context is not an official MITRE, ATT&CK, CWE, or CVE Program mapping.
ATT&CK lookup starting points
Use these exact CWE pages and searches to review the Glexia ATT&CK library from this CVE's weakness and description context.
cwe · low confidence lookup
CWE-667: Exact CWE lookup
Use the exact CWE identifier as the starting point before reviewing related ATT&CK behavior. Open the exact CWE lookup page first, then review the ATT&CK searches from that MITRE weakness context. This is a Glexia lookup hint, not an official ATT&CK mapping.
These fields come from the CVE record and ADP containers, not from Glexia's Take. They preserve time-varying source decisions such as CISA SSVC, KEV status, CVSS metrics, and provider references.
We collect every scored CVSS vector available in the official CNA and ADP containers. When more than one version is present, the table keeps the source vectors side by side instead of collapsing them into the highest score.
CWE links open Glexia weakness intelligence pages with official CWE context, developer remediation guidance, and related CVE mappings.
CWE-667 · source CWE mapping
Improper Locking
Improper Locking represents a recurring weakness pattern that can create exploitable paths when design, validation, or implementation controls are missing.