xfrm: state: fix out-of-bounds read during lookup
Linux kernel xfrm state lookups can read out of bounds during a concurrent hash table resize. Affected kernel ranges run from 4.9.0 up to 6.6.120, 6.7.0 up to 6.12.13, and 6.13.0 up to 6.13.2.
- Published
- Last modified
- Where the record stands: published, rejected by its publisher, or superseded by another id.What do these mean? →
- published
- Whether CISA lists it in its Known Exploited Vulnerabilities catalog: proof that attackers are using it.What do these mean? →
- Not listed in CISA KEV
- How many real-world setups can hit the bug, from the vendor's advisory and CISA data. It does not know your setup.What do these mean? →
- Specific setups only
- Fix
- Fixed in 6.6.120, 6.12.13, 6.13.2
- Whether working attack code is public (Exploit-DB, Metasploit, Nuclei or GitHub). Public code makes attacks easier.What do these mean? →
- None on Exploit-DB, Metasploit or GitHub
- Exploitation: none
- Automatable: no
- Technical impact: partial
Summary
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.
Timeline
- CVE published
- CISA SSVC assessment
Exploitation: none · Automatable: no · Technical impact: partial
- Record last updated
Affected versions
- Linux Linux
Version range not reported
- Linux Linux
4.9
- KernelLinux
From 4.9.0 · fixed in 6.6.120; From 6.7.0 · fixed in 6.12.13; From 6.13.0 · fixed in 6.13.2
References 5
Questions about CVE-2024-57982
What does this mean?
During a hash table resize, a lookup in the xfrm state code can read a hash mask value that is too large for the new array. This makes the lookup read past the end of the array.Source: git.kernel.org
Am I affected, and how do I check?
Affected Linux kernel ranges are 4.9.0 to before 6.6.120, 6.7.0 to before 6.12.13, and 6.13.0 to before 6.13.2. To check a system, run uname -r and compare the version with these ranges.Source: git.kernel.org
What should I do about it?
Upgrade to a fixed kernel for your branch: 6.6.120 or later, 6.12.13 or later, or 6.13.2 or later.Source: git.kernel.org
Is it being exploited?
It is not in CISA's Known Exploited Vulnerabilities catalog, and CISA's SSVC assessment does not mark exploitation as active. That does not mean it has not been attacked: vendors and researchers can report attacks before CISA lists them. No public exploit code is tracked.Source: cve.now feed data