# CVE-2021-47303: bpf: Track subprog poke descriptors correctly and fix use-after-free

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

- **Severity:** HIGH 7.8
- **CVSS:** 7.8 (v3.1, CNA) `CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H`
- **CVSS metrics:** Attack vector: Local; Attack complexity: Low; Privileges required: Low; User interaction: None; Scope: Unchanged; Confidentiality impact: High; Integrity impact: High; 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.32% (percentile 17, 2026-11-26)
- **CWE:** CWE-416
- **Published:** 2024-05-21T14:35:24.027Z
- **Modified:** 2026-08-05T08:47:10.333Z

## Who should check

- Anyone running Linux \>= a748c6975dea325da540610c2ba9b5f332c603e6, \< a9f36bf3613c65cb587c70fac655c775d911409b; \>= a748c6975dea325da540610c2ba9b5f332c603e6, \< 599148d40366bd5d1d504a3a8fcd65e21107e500; \>= a748c6975dea325da540610c2ba9b5f332c603e6, \< f263a81451c12da5a342d90572e317e611846f2c
- Anyone running Linux 5.10

## Description

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

bpf: Track subprog poke descriptors correctly and fix use-after-free

Subprograms are calling map\_poke\_track(), but on program release there is no
hook to call map\_poke\_untrack(). However, on program release, the aux memory
(and poke descriptor table) is freed even though we still have a reference to
it in the element list of the map aux data. When we run map\_poke\_run(), we then
end up accessing free'd memory, triggering KASAN in prog\_array\_map\_poke\_run():

  \[...\]
  \[  402.824689\] BUG: KASAN: use-after-free in prog\_array\_map\_poke\_run+0xc2/0x34e
  \[  402.824698\] Read of size 4 at addr ffff8881905a7940 by task hubble-fgs/4337
  \[  402.824705\] CPU: 1 PID: 4337 Comm: hubble-fgs Tainted: G          I       5.12.0+ \#399
  \[  402.824715\] Call Trace:
  \[  402.824719\]  dump\_stack+0x93/0xc2
  \[  402.824727\]  print\_address\_description.constprop.0+0x1a/0x140
  \[  402.824736\]  ? prog\_array\_map\_poke\_run+0xc2/0x34e
  \[  402.824740\]  ? prog\_array\_map\_poke\_run+0xc2/0x34e
  \[  402.824744\]  kasan\_report.cold+0x7c/0xd8
  \[  402.824752\]  ? prog\_array\_map\_poke\_run+0xc2/0x34e
  \[  402.824757\]  prog\_array\_map\_poke\_run+0xc2/0x34e
  \[  402.824765\]  bpf\_fd\_array\_map\_update\_elem+0x124/0x1a0
  \[...\]

The elements concerned are walked as follows:

    for (i = 0; i \< elem-\>aux-\>size\_poke\_tab; i++) {
           poke = &elem-\>aux-\>poke\_tab\[i\];
    \[...\]

The access to size\_poke\_tab is a 4 byte read, verified by checking offsets
in the KASAN dump:

  \[  402.825004\] The buggy address belongs to the object at ffff8881905a7800
                 which belongs to the cache kmalloc-1k of size 1024
  \[  402.825008\] The buggy address is located 320 bytes inside of
                 1024-byte region \[ffff8881905a7800, ffff8881905a7c00)

The pahole output of bpf\_prog\_aux:

  struct bpf\_prog\_aux {
    \[...\]
    /\* --- cacheline 5 boundary (320 bytes) --- \*/
    u32                        size\_poke\_tab;        /\*   320     4 \*/
    \[...\]

In general, subprograms do not necessarily manage their own data structures.
For example, BTF func\_info and linfo are just pointers to the main program
structure. This allows reference counting and cleanup to be done on the latter
which simplifies their management a bit. The aux-\>poke\_tab struct, however,
did not follow this logic. The initial proposed fix for this use-after-free
bug further embedded poke data tracking into the subprogram with proper
reference counting. However, Daniel and Alexei questioned why we were treating
these objects special; I agree, its unnecessary. The fix here removes the per
subprogram poke table allocation and map tracking and instead simply points
the aux-\>poke\_tab pointer at the main programs poke table. This way, map
tracking is simplified to the main program and we do not need to manage them
per subprogram.

This also means, bpf\_prog\_free\_deferred(), which unwinds the program reference
counting and kfrees objects, needs to ensure that we don't try to double free
the poke\_tab when free'ing the subprog structures. This is easily solved by
NULL'ing the poke\_tab pointer. The second detail is to ensure that per
subprogram JIT logic only does fixups on poke\_tab\[\] entries it owns. To do
this, we add a pointer in the poke structure to point at the subprogram value
so JITs can easily check while walking the poke\_tab structure if the current
entry belongs to the current program. The aux pointer is stable and therefore
suitable for such comparison. On the jit\_subprogs() error path, we omit
cleaning up the poke-\>aux field because these are only ever referenced from
the JIT side, but on error we will never make it to the JIT, so its fine to
leave them dangling. Removing these pointers would complicate the error path
for no reason. However, we do need to untrack all poke descriptors from the
main program as otherwise they could race with the freeing of JIT memory from
the subprograms. Lastly, a748c6975dea3 ("bpf: propagate poke des
---truncated---

## Affected and fixed versions

- Linux: \>= a748c6975dea325da540610c2ba9b5f332c603e6, \< a9f36bf3613c65cb587c70fac655c775d911409b; \>= a748c6975dea325da540610c2ba9b5f332c603e6, \< 599148d40366bd5d1d504a3a8fcd65e21107e500; \>= a748c6975dea325da540610c2ba9b5f332c603e6, \< f263a81451c12da5a342d90572e317e611846f2c (cvelist)
- Linux: 5.10 (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-2021-47303. Work read-only: do not install, upgrade, delete or change anything.

Details: https://flawdb.com/CVE-2021-47303.md
Affected: Linux >= a748c6975dea325da540610c2ba9b5f332c603e6, < a9f36bf3613c65cb587c70fac655c775d911409b; >= a748c6975dea325da540610c2ba9b5f332c603e6, < 599148d40366bd5d1d504a3a8fcd65e21107e500; >= a748c6975dea325da540610c2ba9b5f332c603e6, < f263a81451c12da5a342d90572e317e611846f2c; Linux 5.10
Fixed in: Linux 599148d40366bd5d1d504a3a8fcd65e21107e500

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-2021-47303 being exploited?

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

### How serious is CVE-2021-47303?

High: CVSS 7.8 (v3.1, scored by CNA). Not remotely exploitable (local or adjacent access needed).

### Which versions are affected by CVE-2021-47303?

Linux \>= a748c6975dea325da540610c2ba9b5f332c603e6, \< a9f36bf3613c65cb587c70fac655c775d911409b; \>= a748c6975dea325da540610c2ba9b5f332c603e6, \< 599148d40366bd5d1d504a3a8fcd65e21107e500; \>= a748c6975dea325da540610c2ba9b5f332c603e6, \< f263a81451c12da5a342d90572e317e611846f2c; Linux 5.10.

### Is there a fix for CVE-2021-47303?

Yes. Fixed in Linux 599148d40366bd5d1d504a3a8fcd65e21107e500. No fix listed yet: follow the vendor advisory.

### How do I check if I'm affected by CVE-2021-47303?

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/a9f36bf3613c65cb587c70fac655c775d911409b>
- patch: <https://git.kernel.org/stable/c/599148d40366bd5d1d504a3a8fcd65e21107e500>
- patch: <https://git.kernel.org/stable/c/f263a81451c12da5a342d90572e317e611846f2c>

## 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-2021-47303>

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