CVE-2023-52446: bpf: Fix a race condition between btf_put() and map_free()

Published Feb 22, 2024
·
Updated

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

bpf: Fix a race condition between btfput() and mapfree()

When running ./testprogs -j in my local vm with latest kernel, I once hit a kasan error like below:

[ 1887.184724] BUG: KASAN: slab-use-after-free in bpfrbrootfree+0x1f8/0x2b0 [ 1887.185599] Read of size 4 at addr ffff888106806910 by task kworker/u12:2/2830 [ 1887.186498] [ 1887.186712] CPU: 3 PID: 2830 Comm: kworker/u12:2 Tainted: G OEL 6.7.0-rc3-00699-g90679706d486-dirty #494 [ 1887.188034] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.14.0-0-g155821a1990b-prebuilt.qemu.org 04/01/2014 [ 1887.189618] Workqueue: eventsunbound bpfmapfreedeferred [ 1887.190341] Call Trace: [ 1887.190666] <TASK> [ 1887.190949] dumpstacklvl+0xac/0xe0 [ 1887.191423] ? nftcphandleinvalid+0x1b0/0x1b0 [ 1887.192019] ? panic+0x3c0/0x3c0 [ 1887.192449] printreport+0x14f/0x720 [ 1887.192930] ? preemptcountsub+0x1c/0xd0 [ 1887.193459] ? virtaddrvalid+0xac/0x120 [ 1887.194004] ? bpfrbrootfree+0x1f8/0x2b0 [ 1887.194572] kasanreport+0xc3/0x100 [ 1887.195085] ? bpfrbrootfree+0x1f8/0x2b0 [ 1887.195668] bpfrbrootfree+0x1f8/0x2b0 [ 1887.196183] ? bpfobjdropimpl+0xb0/0xb0 [ 1887.196736] ? preemptcountsub+0x1c/0xd0 [ 1887.197270] ? preemptcountsub+0x1c/0xd0 [ 1887.197802] ? rawspinunlock+0x1f/0x40 [ 1887.198319] bpfobjfreefields+0x1d4/0x260 [ 1887.198883] arraymapfree+0x1a3/0x260 [ 1887.199380] bpfmapfreedeferred+0x7b/0xe0 [ 1887.199943] processscheduledworks+0x3a2/0x6c0 [ 1887.200549] workerthread+0x633/0x890 [ 1887.201047] ? kthreadparkme+0xd7/0xf0 [ 1887.201574] ? kthread+0x102/0x1d0 [ 1887.202020] kthread+0x1ab/0x1d0 [ 1887.202447] ? prcontwork+0x270/0x270 [ 1887.202954] ? kthreadblkcg+0x50/0x50 [ 1887.203444] retfromfork+0x34/0x50 [ 1887.203914] ? kthreadblkcg+0x50/0x50 [ 1887.204397] retfromforkasm+0x11/0x20 [ 1887.204913] </TASK> [ 1887.204913] </TASK> [ 1887.205209] [ 1887.205416] Allocated by task 2197: [ 1887.205881] kasansettrack+0x3f/0x60 [ 1887.206366] kasankmalloc+0x6e/0x80 [ 1887.206856] kmalloc+0xac/0x1a0 [ 1887.207293] btfparsefields+0xa15/0x1480 [ 1887.207836] btfparsestructmetas+0x566/0x670 [ 1887.208387] btfnewfd+0x294/0x4d0 [ 1887.208851] sysbpf+0x4ba/0x600 [ 1887.209292] x64sysbpf+0x41/0x50 [ 1887.209762] dosyscall64+0x4c/0xf0 [ 1887.210222] entrySYSCALL64afterhwframe+0x63/0x6b [ 1887.210868] [ 1887.211074] Freed by task 36: [ 1887.211460] kasansettrack+0x3f/0x60 [ 1887.211951] kasansavefreeinfo+0x28/0x40 [ 1887.212485] kasanslabfree+0x101/0x180 [ 1887.213027] kmemcachefree+0xe4/0x210 [ 1887.213514] btffree+0x5b/0x130 [ 1887.213918] rcucore+0x638/0xcc0 [ 1887.214347] dosoftirq+0x114/0x37e

The error happens at bpfrbrootfree+0x1f8/0x2b0:

00000000000034c0 <bpfrbrootfree>: ; { 34c0: f3 0f 1e fa endbr64 34c4: e8 00 00 00 00 callq 0x34c9 <bpfrbrootfree+0x9> 34c9: 55 pushq %rbp 34ca: 48 89 e5 movq %rsp, %rbp ... ; if (rec && rec->refcountoff >= 0 && 36aa: 4d 85 ed testq %r13, %r13 36ad: 74 a9 je 0x3658 <bpfrbrootfree+0x198> 36af: 49 8d 7d 10 leaq 0x10(%r13), %rdi 36b3: e8 00 00 00 00 callq 0x36b8 <bpfrbrootfree+0x1f8> <==== kasan function 36b8: 45 8b 7d 10 movl 0x10(%r13), %r15d <==== use-after-free load 36bc: 45 85 ff testl %r15d, %r15d 36bf: 78 8c js 0x364d <bpfrbrootfree+0x18d>

So the problem ---truncated---

Affected Software

3 affected componentsFixes available
Linux Linux kernel>=6.2.0<6.6.14
Linux Linux kernel>=6.7.0<6.7.2
debian/linux
5.10.223-15.10.234-16.1.129-16.1.135-16.12.22-16.12.25-1

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade debian/linux to a version that resolves this vulnerability.

    Fixed in 5.10.223-1Fixed in 5.10.234-1Fixed in 6.1.129-1Fixed in 6.1.135-1Fixed in 6.12.22-1Fixed in 6.12.25-1

Event History

Feb 22, 2024
CVE Published
via MITRE·04:21 PM
Data Sourced
via MITRE·04:21 PM
Description

Frequently Asked Questions

1

What is the severity of CVE-2023-52446?

CVE-2023-52446 has a severity rating that necessitates prompt attention due to the potential for exploitable race conditions.

2

How do I fix CVE-2023-52446?

To fix CVE-2023-52446, update your Linux kernel to a patched version specifically addressing this vulnerability.

3

Which Linux kernel versions are affected by CVE-2023-52446?

CVE-2023-52446 affects versions from 6.2.0 to 6.6.14 and versions from 6.7.0 to 6.7.2 of the Linux kernel.

4

What is the nature of the vulnerability described in CVE-2023-52446?

CVE-2023-52446 is a race condition vulnerability occurring between the functions btf_put() and map_free() in the Linux kernel.

5

Can I check if my system is vulnerable to CVE-2023-52446?

Yes, you can check your kernel version against the affected ranges for CVE-2023-52446 to determine vulnerability.

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