CVE-2021-47303·Kernel vulnerability
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---
- Severity
- high
- Software
- Kernel
- Fixed in
- 5.13.5
- Published
How likely is exploitation
FIRST's Exploit Prediction Scoring System puts the probability of this CVE being exploited in the next 30 days at 0.10% — higher than 27% of all published CVEs. EPSS is an independent forecast of exploitation, not a severity rating: it says nothing about how much damage a successful attack does, which is what a CVSS score measures.
Read the two together. CVE-2021-47303 scores 7.8 on CVSS, so a successful attack would be serious — but at 0.10%, almost nobody is currently attempting it. That is a different situation from a flaw under mass exploitation, and it is usually the difference between patching on your next maintenance window and patching tonight.
Affected versions
From: 5.11
Until: 5.13.5
Fixed in: 5.13.5
How to fix this CVE
Update your Linux kernel to version 5.13.5 or later to remediate this use-after-free vulnerability in eBPF subprogram handling. Systems running kernel versions 5.11 through 5.13.4 should prioritize this patch, as the flaw allows memory corruption when eBPF programs with subprograms are unloaded while map poke operations reference freed auxiliary data structures.
sudo dnf update kernel && sudo rebootDefensia detects this vulnerability
How to check if you are affected
- Check kernel version: uname -r; compare against 5.13.5 baseline
- Verify eBPF subsystem is enabled: cat /boot/config-$(uname -r) | grep CONFIG_BPF
- Search kernel logs for KASAN errors: sudo dmesg | grep -i 'use-after-free\|prog_array_map_poke_run'
- After patching, confirm new version: uname -r should report 5.13.5 or newer
FAQ
What is CVE-2021-47303?
CVE-2021-47303 is a use-after-free vulnerability in the Linux kernel's eBPF subsystem where subprogram poke descriptor tables are freed while still referenced by map tracking structures, leading to memory corruption when the kernel attempts to execute map poke operations.
Is CVE-2021-47303 being actively exploited?
No, this vulnerability is not listed on CISA's Known Exploited Vulnerabilities catalog and no public exploits are currently available.
What versions of Kernel are affected by CVE-2021-47303?
Linux kernel versions 5.11 through 5.13.4 are vulnerable; versions 5.13.5 and later include the fix.
How do I check if my server is vulnerable to CVE-2021-47303?
Run `uname -r` to display your kernel version; if it shows 5.11.x, 5.12.x, or 5.13.0-5.13.4, your system is vulnerable.
Does Defensia detect CVE-2021-47303?
Yes — Defensia's CVE advisory scanner compares installed kernel package versions against the NVD database. If Linux kernel is installed on a monitored server, CVE-2021-47303 will appear in your dashboard with remediation steps.
Related Kernel CVEs
References
- https://git.kernel.org/stable/c/599148d40366bd5d1d504a3a8fcd65e21107e500
- https://git.kernel.org/stable/c/a9f36bf3613c65cb587c70fac655c775d911409b
- https://git.kernel.org/stable/c/f263a81451c12da5a342d90572e317e611846f2c
- https://git.kernel.org/stable/c/599148d40366bd5d1d504a3a8fcd65e21107e500
- https://git.kernel.org/stable/c/a9f36bf3613c65cb587c70fac655c775d911409b
Track CVEs across your fleet automatically
Defensia scans your Linux servers and tells you exactly which ones are running vulnerable versions — including CVE-2021-47303. Free for 1 server.
Get started free