CVE-2021-47300: bpf: Fix tail_call_reachable rejection for interpreter when jit failed

Published May 21, 2024
·
Updated

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

bpf: Fix tailcallreachable rejection for interpreter when jit failed

During testing of f263a81451c1 ("bpf: Track subprog poke descriptors correctly and fix use-after-free") under various failure conditions, for example, when jitsubprogs() fails and tries to clean up the program to be run under the interpreter, we ran into the following freeze:

[...] #127/8 tailcallbpf2bpf3:FAIL [...] [ 92.041251] BUG: KASAN: slab-out-of-bounds in bpfprogrun+0x1b9d/0x2e20 [ 92.042408] Read of size 8 at addr ffff88800da67f68 by task testprogs/682 [ 92.043707] [ 92.044030] CPU: 1 PID: 682 Comm: testprogs Tainted: G O 5.13.0-53301-ge6c08cb33a30-dirty #87 [ 92.045542] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.13.0-1ubuntu1 04/01/2014 [ 92.046785] Call Trace: [ 92.047171] ? bpfprogrunargs64+0xc0/0xc0 [ 92.047773] ? bpfprogrunargs32+0x8b/0xb0 [ 92.048389] ? bpfprogrunargs64+0xc0/0xc0 [ 92.049019] ? ktimeget+0x117/0x130 [...] // few hundred [similar] lines more [ 92.659025] ? ktimeget+0x117/0x130 [ 92.659845] ? bpfprogrunargs64+0xc0/0xc0 [ 92.660738] ? bpfprogrunargs32+0x8b/0xb0 [ 92.661528] ? bpfprogrunargs64+0xc0/0xc0 [ 92.662378] ? printusagebug+0x50/0x50 [ 92.663221] ? printusagebug+0x50/0x50 [ 92.664077] ? bpfksymfind+0x9c/0xe0 [ 92.664887] ? ktimeget+0x117/0x130 [ 92.665624] ? kerneltextaddress+0xf5/0x100 [ 92.666529] ? kerneltextaddress+0xe/0x30 [ 92.667725] ? unwindgetreturnaddress+0x2f/0x50 [ 92.668854] ? bpfprogrun+0x15d4/0x2e20 [ 92.670185] ? ktimeget+0x117/0x130 [ 92.671130] ? bpfprogrunargs64+0xc0/0xc0 [ 92.672020] ? bpfprogrunargs32+0x8b/0xb0 [ 92.672860] ? bpfprogrunargs64+0xc0/0xc0 [ 92.675159] ? ktimeget+0x117/0x130 [ 92.677074] ? lockisheldtype+0xd5/0x130 [ 92.678662] ? bpfprogrun+0x15d4/0x2e20 [ 92.680046] ? ktimeget+0x117/0x130 [ 92.681285] ? bpfprogrun32+0x6b/0x90 [ 92.682601] ? bpfprogrun64+0x90/0x90 [ 92.683636] ? lockdowngrade+0x370/0x370 [ 92.684647] ? markheldlocks+0x44/0x90 [ 92.685652] ? ktimeget+0x117/0x130 [ 92.686752] ? lockdephardirqson+0x79/0x100 [ 92.688004] ? ktimeget+0x117/0x130 [ 92.688573] ? cantmigrate+0x2b/0x80 [ 92.689192] ? bpftestrun+0x2f4/0x510 [ 92.689869] ? bpftesttimercontinue+0x1c0/0x1c0 [ 92.690856] ? rcureadlockbhheld+0x90/0x90 [ 92.691506] ? kasanslaballoc+0x61/0x80 [ 92.692128] ? ethtypetrans+0x128/0x240 [ 92.692737] ? buildskb+0x46/0x50 [ 92.693252] ? bpfprogtestrunskb+0x65e/0xc50 [ 92.693954] ? bpfprogtestrunrawtp+0x2d0/0x2d0 [ 92.694639] ? fgetlight+0xa1/0x100 [ 92.695162] ? bpfproginc+0x23/0x30 [ 92.695685] ? sysbpf+0xb40/0x2c80 [ 92.696324] ? bpflinkgetfromfd+0x90/0x90 [ 92.697150] ? markheldlocks+0x24/0x90 [ 92.698007] ? lockdephardirqsonprepare+0x124/0x220 [ 92.699045] ? finishtaskswitch+0xe6/0x370 [ 92.700072] ? lockdephardirqson+0x79/0x100 [ 92.701233] ? finishtaskswitch+0x11d/0x370 [ 92.702264] ? switchto+0x2c0/0x740 [ 92.703148] ? markheldlocks+0x24/0x90 [ 92.704155] ? x64sysbpf+0x45/0x50 [ 92.705146] ? dosyscall64+0x35/0x80 [ 92.706953] ? entrySYSCALL64afterhwframe+0x44/0xae [...]

Turns out that the program rejection from e411901c0b77 ("bpf: allow for tailcalls in BPF subprograms for x64 JIT") is buggy since env->prog->aux->tailcallreachable is never true. Commit ebf7d1f508a7 ("bpf, x64: rework pro/epilogue and tailcall handling in JIT") added a tracker into checkmaxstackdepth() which propagates the tailcallreachable condition throughout the subprograms. This info is then assigned to the subprogram's ---truncated---

Affected Software

67 affected components
Linux Linux kernel>=5.10<5.10.54
Linux Linux kernel>=5.11<5.13.6
Linux Linux kernel=5.14-rc1
Linux Linux kernel=5.14-rc2
ubuntu/linux-hwe-edge*
ubuntu/linux-aws-5.0*
ubuntu/linux-aws-5.3*
ubuntu/linux-azure*
ubuntu/linux-azure-5.3*
ubuntu/linux-azure-edge*
ubuntu/linux-gcp*
ubuntu/linux-gcp-5.3*
ubuntu/linux-gke-4.15*
ubuntu/linux-gke-5.4*
ubuntu/linux-gkeop-5.4*
ubuntu/linux-hwe*
ubuntu/linux-hwe-edge*
ubuntu/linux-oem*
ubuntu/linux-oracle-5.0*
ubuntu/linux-oracle-5.3*
ubuntu/linux-aws-5.11*
ubuntu/linux-aws-5.13*
ubuntu/linux-aws-5.8*
ubuntu/linux-azure-5.11*
ubuntu/linux-azure-5.13*
ubuntu/linux-azure-5.8*
ubuntu/linux-azure-fde*
ubuntu/linux-gcp-5.11*
ubuntu/linux-gcp-5.13*
ubuntu/linux-gcp-5.8*
ubuntu/linux-gke*
ubuntu/linux-gke-5.15*
ubuntu/linux-hwe-5.11*
ubuntu/linux-hwe-5.13*
ubuntu/linux-hwe-5.8*
ubuntu/linux-intel-5.13*
ubuntu/linux-oem-5.10*
ubuntu/linux-oem-5.13*
ubuntu/linux-oem-5.6*
ubuntu/linux-oracle-5.11*
ubuntu/linux-oracle-5.13*
ubuntu/linux-oracle-5.8*
ubuntu/linux-raspi2*
ubuntu/linux-riscv*
ubuntu/linux-riscv-5.11*
ubuntu/linux-riscv-5.8*
ubuntu/linux-allwinner-5.19*
ubuntu/linux-aws-5.19*
ubuntu/linux-aws-6.2*
ubuntu/linux-azure-5.19*
ubuntu/linux-azure-6.2*
ubuntu/linux-azure-fde-5.19*
ubuntu/linux-azure-fde-6.2*
ubuntu/linux-gcp-5.19*
ubuntu/linux-gcp-6.2*
ubuntu/linux-hwe-5.19*
ubuntu/linux-hwe-6.2*
ubuntu/linux-lowlatency-hwe-5.19*
ubuntu/linux-lowlatency-hwe-6.2*
ubuntu/linux-nvidia-6.2*
ubuntu/linux-oem-5.17*
ubuntu/linux-oem-6.0*
ubuntu/linux-oem-6.1*
ubuntu/linux-riscv*
ubuntu/linux-riscv-5.19*
ubuntu/linux-starfive-5.19*
ubuntu/linux-starfive-6.2*

Event History

May 21, 2024
CVE Published
via MITRE·02:35 PM
Data Sourced
via MITRE·02:35 PM
Description
Data Sourced
via OSV·03:15 PM
DescriptionSeverityAffected Software
Data Sourced
via NVD·03:15 PM
Description
Dec 26, 2024
Data Sourced
via NVD·08:44 PM
RemedySeverityWeaknessAffected Software
Aug 4, 2026
Data Sourced
via MITRE·08:59 AM
Severity
Event
via MITRE·08:59 AM
Updated
via NVD·10:16 AM
SeverityAffected Software

Frequently Asked Questions

1

What is the severity of CVE-2021-47300?

CVE-2021-47300 is classified as a medium severity vulnerability in the Linux kernel.

2

How do I fix CVE-2021-47300?

To fix CVE-2021-47300, update the Linux kernel to a version that is not affected, such as versions after 5.10.54 or 5.13.6.

3

What versions of the Linux kernel are affected by CVE-2021-47300?

CVE-2021-47300 affects Linux kernel versions between 5.10 and 5.10.54, between 5.11 and 5.13.6, and specific release candidates 5.14-rc1 and 5.14-rc2.

4

What does CVE-2021-47300 affect in the Linux kernel?

CVE-2021-47300 affects the BPF (Berkeley Packet Filter) functionality in the Linux kernel, specifically related to interpreter rejection when JIT compilation fails.

5

Is CVE-2021-47300 actively exploited?

As of now, there are no reported cases of CVE-2021-47300 being actively exploited in the wild.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203