CVE-2024-57982 xfrm: state: fix out-of-bounds read during lookup
A race condition in the Linux kernel xfrm state lookup allows out-of-bounds reads, potentially causing crashes or leaking sensitive memory.
- Exploited in the wild
- Not known
- Login needed
- Any signed-in user
- Attackable
- Local or same network only
- Victim action needed
- Not needed
- Fix
- Available
What is CVE-2024-57982?
CVE-2024-57982 is a high-severity memory corruption vulnerability in Linux kernel, published on 27 Feb 2025. It can only be exploited from the same machine or local network, with no action from the victim.
Official description
In the Linux kernel, the following vulnerability has been resolved:
xfrm: state: fix out-of-bounds read during lookup
lookup and resize can run in parallel.
The xfrm_state_hash_generation seqlock ensures a retry, but the hash functions can observe a hmask value that is too large for the new hlist array.
rehash does: rcu_assign_pointer(net->xfrm.state_bydst, ndst) [..] net->xfrm.state_hmask = nhashmask;
While state lookup does: h = xfrm_dst_hash(net, daddr, saddr, tmpl->reqid, encap_family); hlist_for_each_entry_rcu(x, net->xfrm.state_bydst + h, bydst) {
This is only safe in case the update to state_bydst is larger than net->xfrm.xfrm_state_hmask (or if the lookup function gets serialized via state spinlock again).
Fix this by prefetching state_hmask and the associated pointers. The xfrm_state_hash_generation seqlock retry will ensure that the pointer and the hmask will be consistent.
The existing helpers, like xfrm_dst_hash(), are now unsafe for RCU side, add lockdep assertions to document that they are only safe for insert side.
xfrm_state_lookup_byaddr() uses the spinlock rather than RCU. AFAICS this is an oversight from back when state lookup was converted to RCU, this lock should be replaced with RCU in a future patch.
Weakness: CWE-125
Which versions are affected by CVE-2024-57982?
It affects 1 product.
Products include Linux kernel.
How do I fix CVE-2024-57982?
Apply the vendor's patch.
Upgrade to the fixed version. Memory-safe languages, compiler hardening and fuzzing prevent most new cases. More about Memory corruption.
Is CVE-2024-57982 being exploited?
There is no known exploitation of CVE-2024-57982 in the wild and no public exploit code.
Other vulnerabilities in Linux kernel
Sources
Also known as AZL-58000, AZL-58017, BELL-CVE-2024-57982, DEBIAN-CVE-2024-57982, GHSA-fxr5-v2qf-8828, ROOT-OS-DEBIAN-11-CVE-2024-57982 and 4 more.