# CVE-2024-56592: bpf: Call free\_htab\_elem() after htab\_unlock\_bucket()

> Archived entry. Full-text search covers entries since 2026-11-10; exact IDs work for all years.

- **Severity:** MEDIUM 5.5
- **CVSS:** 5.5 (v3.1, NVD) `CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H`
- **CVSS metrics:** Attack vector: Local; Attack complexity: Low; Privileges required: Low; User interaction: None; Scope: Unchanged; Confidentiality impact: None; Integrity impact: None; Availability impact: High
- **Exploited in the wild:** Not in CISA KEV
- **Public exploit / PoC:** None known
- **Remote exploitation:** Not remotely exploitable (local or adjacent access needed)
- **EPSS:** 0.29% (percentile 15, 2026-11-26)
- **Published:** 2024-12-27T14:50:59.673Z
- **Modified:** 2026-11-05T21:17:36.097Z

## Who should check

- Anyone running Linux \>= f3f1c054c288bb6e503005e6d73611151ed20e91, \< 5b6a49b87cc73153a3ea5ae3f64b980386059dca; \>= f3f1c054c288bb6e503005e6d73611151ed20e91, \< 10e8a2dec9ff1b81de8e892b0850924038adbc6d; \>= f3f1c054c288bb6e503005e6d73611151ed20e91, \< a50b4aa3007e63a590d501341f304676ebc74b3b; \>= f3f1c054c288bb6e503005e6d73611151ed20e91, \< b9e9ed90b10c82a4e9d4d70a2890f06bfcdd3b78
- Anyone running Linux 4.13

## Description

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

bpf: Call free\_htab\_elem() after htab\_unlock\_bucket()

For htab of maps, when the map is removed from the htab, it may hold the
last reference of the map. bpf\_map\_fd\_put\_ptr() will invoke
bpf\_map\_free\_id() to free the id of the removed map element. However,
bpf\_map\_fd\_put\_ptr() is invoked while holding a bucket lock
(raw\_spin\_lock\_t), and bpf\_map\_free\_id() attempts to acquire map\_idr\_lock
(spinlock\_t), triggering the following lockdep warning:

  =============================
  \[ BUG: Invalid wait context \]
  6.11.0-rc4+ \#49 Not tainted
  -----------------------------
  test\_maps/4881 is trying to lock:
  ffffffff84884578 (map\_idr\_lock){+...}-{3:3}, at: bpf\_map\_free\_id.part.0+0x21/0x70
  other info that might help us debug this:
  context-{5:5}
  2 locks held by test\_maps/4881:
   \#0: ffffffff846caf60 (rcu\_read\_lock){....}-{1:3}, at: bpf\_fd\_htab\_map\_update\_elem+0xf9/0x270
   \#1: ffff888149ced148 (&htab-\>lockdep\_key\#2){....}-{2:2}, at: htab\_map\_update\_elem+0x178/0xa80
  stack backtrace:
  CPU: 0 UID: 0 PID: 4881 Comm: test\_maps Not tainted 6.11.0-rc4+ \#49
  Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), ...
  Call Trace:
   \<TASK\>
   dump\_stack\_lvl+0x6e/0xb0
   dump\_stack+0x10/0x20
   \_\_lock\_acquire+0x73e/0x36c0
   lock\_acquire+0x182/0x450
   \_raw\_spin\_lock\_irqsave+0x43/0x70
   bpf\_map\_free\_id.part.0+0x21/0x70
   bpf\_map\_put+0xcf/0x110
   bpf\_map\_fd\_put\_ptr+0x9a/0xb0
   free\_htab\_elem+0x69/0xe0
   htab\_map\_update\_elem+0x50f/0xa80
   bpf\_fd\_htab\_map\_update\_elem+0x131/0x270
   htab\_map\_update\_elem+0x50f/0xa80
   bpf\_fd\_htab\_map\_update\_elem+0x131/0x270
   bpf\_map\_update\_value+0x266/0x380
   \_\_sys\_bpf+0x21bb/0x36b0
   \_\_x64\_sys\_bpf+0x45/0x60
   x64\_sys\_call+0x1b2a/0x20d0
   do\_syscall\_64+0x5d/0x100
   entry\_SYSCALL\_64\_after\_hwframe+0x76/0x7e

One way to fix the lockdep warning is using raw\_spinlock\_t for
map\_idr\_lock as well. However, bpf\_map\_alloc\_id() invokes
idr\_alloc\_cyclic() after acquiring map\_idr\_lock, it will trigger a
similar lockdep warning because the slab's lock (s-\>cpu\_slab-\>lock) is
still a spinlock.

Instead of changing map\_idr\_lock's type, fix the issue by invoking
htab\_put\_fd\_value() after htab\_unlock\_bucket(). However, only deferring
the invocation of htab\_put\_fd\_value() is not enough, because the old map
pointers in htab of maps can not be saved during batched deletion.
Therefore, also defer the invocation of free\_htab\_elem(), so these
to-be-freed elements could be linked together similar to lru map.

There are four callers for -\>map\_fd\_put\_ptr:

(1) alloc\_htab\_elem() (through htab\_put\_fd\_value())
It invokes -\>map\_fd\_put\_ptr() under a raw\_spinlock\_t. The invocation of
htab\_put\_fd\_value() can not simply move after htab\_unlock\_bucket(),
because the old element has already been stashed in htab-\>extra\_elems.
It may be reused immediately after htab\_unlock\_bucket() and the
invocation of htab\_put\_fd\_value() after htab\_unlock\_bucket() may release
the newly-added element incorrectly. Therefore, saving the map pointer
of the old element for htab of maps before unlocking the bucket and
releasing the map\_ptr after unlock. Beside the map pointer in the old
element, should do the same thing for the special fields in the old
element as well.

(2) free\_htab\_elem() (through htab\_put\_fd\_value())
Its caller includes \_\_htab\_map\_lookup\_and\_delete\_elem(),
htab\_map\_delete\_elem() and \_\_htab\_map\_lookup\_and\_delete\_batch().

For htab\_map\_delete\_elem(), simply invoke free\_htab\_elem() after
htab\_unlock\_bucket(). For \_\_htab\_map\_lookup\_and\_delete\_batch(), just
like lru map, linking the to-be-freed element into node\_to\_free list
and invoking free\_htab\_elem() for these element after unlock. It is safe
to reuse batch\_flink as the link for node\_to\_free, because these
elements have been removed from the hash llist.

Because htab of maps doesn't support lookup\_and\_delete operation,
\_\_htab\_map\_lookup\_and\_delete\_elem() doesn't have the problem, so kept
it as
---truncated---

## Affected and fixed versions

- Linux: \>= f3f1c054c288bb6e503005e6d73611151ed20e91, \< 5b6a49b87cc73153a3ea5ae3f64b980386059dca; \>= f3f1c054c288bb6e503005e6d73611151ed20e91, \< 10e8a2dec9ff1b81de8e892b0850924038adbc6d; \>= f3f1c054c288bb6e503005e6d73611151ed20e91, \< a50b4aa3007e63a590d501341f304676ebc74b3b; \>= f3f1c054c288bb6e503005e6d73611151ed20e91, \< b9e9ed90b10c82a4e9d4d70a2890f06bfcdd3b78 (cvelist)
- Linux: 4.13 (cvelist)

## Mitigation

- No fix listed yet: follow the vendor advisory.

## Check your systems with an agent

Paste this into a coding agent:

```text
Check whether anything I run is affected by CVE-2024-56592. Work read-only: do not install, upgrade, delete or change anything.

Details: https://flawdb.com/CVE-2024-56592.md
Affected: Linux >= f3f1c054c288bb6e503005e6d73611151ed20e91, < 5b6a49b87cc73153a3ea5ae3f64b980386059dca; >= f3f1c054c288bb6e503005e6d73611151ed20e91, < 10e8a2dec9ff1b81de8e892b0850924038adbc6d; >= f3f1c054c288bb6e503005e6d73611151ed20e91, < a50b4aa3007e63a590d501341f304676ebc74b3b; >= f3f1c054c288bb6e503005e…
Fixed in: Linux 5b6a49b87cc73153a3ea5ae3f64b980386059dca, Linux 10e8a2dec9ff1b81de8e892b0850924038adbc6d

Steps:
1. Search this machine and project for Linux: dependency manifests and lockfiles, installed packages, container images and running services.
2. For each match, note the installed version and whether it is inside the affected range.
3. Report a table: location, installed version, affected (yes / no / unsure), evidence. If affected, say which fixed version or mitigation from the details link applies, but don't apply it.
```

## FAQ

### Is CVE-2024-56592 being exploited?

There is no confirmed exploitation: CVE-2024-56592 is not in the CISA Known Exploited Vulnerabilities catalog. No public exploit code is known. EPSS estimates a 0.29% chance of exploitation in the next 30 days (as of 2026-11-26).

### How serious is CVE-2024-56592?

Medium: CVSS 5.5 (v3.1, scored by NVD). Not remotely exploitable (local or adjacent access needed).

### Which versions are affected by CVE-2024-56592?

Linux \>= f3f1c054c288bb6e503005e6d73611151ed20e91, \< 5b6a49b87cc73153a3ea5ae3f64b980386059dca; \>= f3f1c054c288bb6e503005e6d73611151ed20e91, \< 10e8a2dec9ff1b81de8e892b0850924038adbc6d; \>= f3f1c054c288bb6e503005e6d73611151ed20e91, \< a50b4aa3007e63a590d501341f304676ebc74b3b; \>= f3f1c054c288bb6e503005e6d73611151ed20e91, \< b9e9ed90b10c82a4e9d4d70a2890f06bfcdd3b78; Linux 4.13.

### Is there a fix for CVE-2024-56592?

Yes. Fixed in Linux 5b6a49b87cc73153a3ea5ae3f64b980386059dca, Linux 10e8a2dec9ff1b81de8e892b0850924038adbc6d. No fix listed yet: follow the vendor advisory.

### How do I check if I'm affected by CVE-2024-56592?

Find where you use the affected software (dependency lockfiles, installed packages, container images, servers) and compare the installed version with the affected range above. The agent prompt on this page does this read-only.

## References

- patch: <https://git.kernel.org/stable/c/10e8a2dec9ff1b81de8e892b0850924038adbc6d>
- patch: <https://git.kernel.org/stable/c/a50b4aa3007e63a590d501341f304676ebc74b3b>
- patch: <https://git.kernel.org/stable/c/b9e9ed90b10c82a4e9d4d70a2890f06bfcdd3b78>
- other: <https://git.kernel.org/stable/c/5b6a49b87cc73153a3ea5ae3f64b980386059dca>

## Attribution

- CVE Program: CVE® is a registered trademark of The MITRE Corporation. CVE records © 1999–2026 The MITRE Corporation. <https://www.cve.org/Legal/TermsOfUse>
- NVD: This product uses data from the NVD API but is not endorsed or certified by the NVD. <https://nvd.nist.gov/vuln/detail/CVE-2024-56592>

HTML: <https://flawdb.com/CVE-2024-56592> · JSON: <https://flawdb.com/api/v1/entries/CVE-2024-56592>
