CVE-2023-52446

Source
https://nvd.nist.gov/vuln/detail/CVE-2023-52446
Import Source
https://storage.googleapis.com/cve-osv-conversion/osv-output/CVE-2023-52446.json
JSON Data
https://api.osv.dev/v1/vulns/CVE-2023-52446
Downstream
Related
Published
2024-02-22T16:21:38Z
Modified
2025-10-15T03:09:48.308766Z
Severity
  • 7.8 (High) CVSS_V3 - CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H CVSS Calculator
Summary
bpf: Fix a race condition between btf_put() and map_free()
Details

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

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

When running ./test_progs -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] _do_softirq+0x114/0x37e

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

00000000000034c0 <bpf_rb_root_free>: ; { 34c0: f3 0f 1e fa endbr64 34c4: e8 00 00 00 00 callq 0x34c9 <bpf_rb_root_free+0x9> 34c9: 55 pushq %rbp 34ca: 48 89 e5 movq %rsp, %rbp ... ; if (rec && rec->refcount_off >= 0 && 36aa: 4d 85 ed testq %r13, %r13 36ad: 74 a9 je 0x3658 <bpf_rb_root_free+0x198> 36af: 49 8d 7d 10 leaq 0x10(%r13), %rdi 36b3: e8 00 00 00 00 callq 0x36b8 <bpf_rb_root_free+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 <bpf_rb_root_free+0x18d>

So the problem ---truncated---

References

Affected packages

Git / git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git

Affected ranges

Type
GIT
Repo
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
Events
Introduced
958cf2e273f0929c66169e0788031310e8118722
Fixed
d048dced8ea5eac6723ae873a40567e6f101ea42
Type
GIT
Repo
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
Events
Introduced
958cf2e273f0929c66169e0788031310e8118722
Fixed
f9ff6ef1c73cd9e1a6bb1ab3e57c5d141a536306
Type
GIT
Repo
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
Events
Introduced
958cf2e273f0929c66169e0788031310e8118722
Fixed
59e5791f59dd83e8aa72a4e74217eabb6e8cfd90

Affected versions

v6.*

v6.1
v6.1-rc5
v6.1-rc6
v6.1-rc7
v6.1-rc8
v6.2
v6.2-rc1
v6.2-rc2
v6.2-rc3
v6.2-rc4
v6.2-rc5
v6.2-rc6
v6.2-rc7
v6.2-rc8
v6.3
v6.3-rc1
v6.3-rc2
v6.3-rc3
v6.3-rc4
v6.3-rc5
v6.3-rc6
v6.3-rc7
v6.4
v6.4-rc1
v6.4-rc2
v6.4-rc3
v6.4-rc4
v6.4-rc5
v6.4-rc6
v6.4-rc7
v6.5
v6.5-rc1
v6.5-rc2
v6.5-rc3
v6.5-rc4
v6.5-rc5
v6.5-rc6
v6.5-rc7
v6.6
v6.6-rc1
v6.6-rc2
v6.6-rc3
v6.6-rc4
v6.6-rc5
v6.6-rc6
v6.6-rc7
v6.6.1
v6.6.10
v6.6.11
v6.6.12
v6.6.13
v6.6.2
v6.6.3
v6.6.4
v6.6.5
v6.6.6
v6.6.7
v6.6.8
v6.6.9
v6.7
v6.7-rc1
v6.7-rc2
v6.7-rc3
v6.7-rc4
v6.7-rc5
v6.7-rc6
v6.7-rc7
v6.7-rc8
v6.7.1

Database specific

vanir_signatures

[
    {
        "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@59e5791f59dd83e8aa72a4e74217eabb6e8cfd90",
        "signature_version": "v1",
        "target": {
            "file": "kernel/bpf/syscall.c",
            "function": "bpf_map_free_deferred"
        },
        "digest": {
            "length": 236.0,
            "function_hash": "63630895269764179794033254804868366919"
        },
        "deprecated": false,
        "signature_type": "Function",
        "id": "CVE-2023-52446-0606804a"
    },
    {
        "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@d048dced8ea5eac6723ae873a40567e6f101ea42",
        "signature_version": "v1",
        "target": {
            "file": "kernel/bpf/syscall.c"
        },
        "digest": {
            "threshold": 0.9,
            "line_hashes": [
                "219516769881429113818121250430137602170",
                "58553212658106913265130658643044078975",
                "257087548709937952704941081990534523942",
                "51697939611876321177848649427603767230",
                "122618632972784274721426026051734071905",
                "2929993839968839482790879847973247006",
                "283774286262208318826936963515974312364",
                "216956642352608830879849539451662773107",
                "188062311945380406403065356255554697270",
                "201601561127257016594483965936333308554",
                "269470435188652312490652532222974658367",
                "250928121395684182581044357138415608843"
            ]
        },
        "deprecated": false,
        "signature_type": "Line",
        "id": "CVE-2023-52446-238b837c"
    },
    {
        "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@f9ff6ef1c73cd9e1a6bb1ab3e57c5d141a536306",
        "signature_version": "v1",
        "target": {
            "file": "kernel/bpf/syscall.c"
        },
        "digest": {
            "threshold": 0.9,
            "line_hashes": [
                "219516769881429113818121250430137602170",
                "58553212658106913265130658643044078975",
                "257087548709937952704941081990534523942",
                "51697939611876321177848649427603767230",
                "122618632972784274721426026051734071905",
                "2929993839968839482790879847973247006",
                "283774286262208318826936963515974312364",
                "216956642352608830879849539451662773107",
                "188062311945380406403065356255554697270",
                "201601561127257016594483965936333308554",
                "269470435188652312490652532222974658367",
                "250928121395684182581044357138415608843"
            ]
        },
        "deprecated": false,
        "signature_type": "Line",
        "id": "CVE-2023-52446-675ae430"
    },
    {
        "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@59e5791f59dd83e8aa72a4e74217eabb6e8cfd90",
        "signature_version": "v1",
        "target": {
            "file": "kernel/bpf/syscall.c",
            "function": "bpf_map_put"
        },
        "digest": {
            "length": 422.0,
            "function_hash": "73388353423682381574958402004164894745"
        },
        "deprecated": false,
        "signature_type": "Function",
        "id": "CVE-2023-52446-728946ee"
    },
    {
        "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@d048dced8ea5eac6723ae873a40567e6f101ea42",
        "signature_version": "v1",
        "target": {
            "file": "kernel/bpf/syscall.c",
            "function": "bpf_map_free_deferred"
        },
        "digest": {
            "length": 236.0,
            "function_hash": "63630895269764179794033254804868366919"
        },
        "deprecated": false,
        "signature_type": "Function",
        "id": "CVE-2023-52446-7b327aa9"
    },
    {
        "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@d048dced8ea5eac6723ae873a40567e6f101ea42",
        "signature_version": "v1",
        "target": {
            "file": "kernel/bpf/syscall.c",
            "function": "bpf_map_put"
        },
        "digest": {
            "length": 262.0,
            "function_hash": "88130448974672540229920588488880962972"
        },
        "deprecated": false,
        "signature_type": "Function",
        "id": "CVE-2023-52446-89d12427"
    },
    {
        "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@f9ff6ef1c73cd9e1a6bb1ab3e57c5d141a536306",
        "signature_version": "v1",
        "target": {
            "file": "kernel/bpf/syscall.c",
            "function": "bpf_map_free_deferred"
        },
        "digest": {
            "length": 236.0,
            "function_hash": "63630895269764179794033254804868366919"
        },
        "deprecated": false,
        "signature_type": "Function",
        "id": "CVE-2023-52446-d62f0c74"
    },
    {
        "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@59e5791f59dd83e8aa72a4e74217eabb6e8cfd90",
        "signature_version": "v1",
        "target": {
            "file": "kernel/bpf/syscall.c"
        },
        "digest": {
            "threshold": 0.9,
            "line_hashes": [
                "219516769881429113818121250430137602170",
                "58553212658106913265130658643044078975",
                "257087548709937952704941081990534523942",
                "51697939611876321177848649427603767230",
                "122618632972784274721426026051734071905",
                "2929993839968839482790879847973247006",
                "283774286262208318826936963515974312364",
                "216956642352608830879849539451662773107",
                "188062311945380406403065356255554697270",
                "91770631602046146833172355655467148595",
                "300397069530062721683540124708400238900",
                "317545264882717528347711132018438813227"
            ]
        },
        "deprecated": false,
        "signature_type": "Line",
        "id": "CVE-2023-52446-f5e2c0fa"
    },
    {
        "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@f9ff6ef1c73cd9e1a6bb1ab3e57c5d141a536306",
        "signature_version": "v1",
        "target": {
            "file": "kernel/bpf/syscall.c",
            "function": "bpf_map_put"
        },
        "digest": {
            "length": 262.0,
            "function_hash": "88130448974672540229920588488880962972"
        },
        "deprecated": false,
        "signature_type": "Function",
        "id": "CVE-2023-52446-f6af862c"
    }
]

Linux / Kernel

Package

Name
Kernel

Affected ranges

Type
ECOSYSTEM
Events
Introduced
6.2.0
Fixed
6.6.14
Type
ECOSYSTEM
Events
Introduced
6.7.0
Fixed
6.7.2