CVE-2021-47608

Source
https://cve.org/CVERecord?id=CVE-2021-47608
Import Source
https://storage.googleapis.com/osv-test-cve-osv-conversion/osv-output/CVE-2021-47608.json
JSON Data
https://api.test.osv.dev/v1/vulns/CVE-2021-47608
Downstream
Related
Published
2024-06-19T15:15:55.360Z
Modified
2026-03-13T05:16:33.267564Z
Severity
  • 5.5 (Medium) CVSS_V3 - CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N CVSS Calculator
Summary
[none]
Details

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

bpf: Fix kernel address leakage in atomic fetch

The change in commit 37086bfdc737 ("bpf: Propagate stack bounds to registers in atomics w/ BPFFETCH") around checkmem_access() handling is buggy since this would allow for unprivileged users to leak kernel pointers. For example, an atomic fetch/and with -1 on a stack destination which holds a spilled pointer will migrate the spilled register type into a scalar, which can then be exported out of the program (since scalar != pointer) by dumping it into a map value.

The original implementation of XADD was preventing this situation by using a double call to checkmemaccess() one with BPFREAD and a subsequent one with BPFWRITE, in both cases passing -1 as a placeholder value instead of register as per XADD semantics since it didn't contain a value fetch. The BPFREAD also included a check in checkstackreadfixed_off() which rejects the program if the stack slot is of _ispointervalue() if dstregno < 0. The latter is to distinguish whether we're dealing with a regular stack spill/ fill or some arithmetical operation which is disallowed on non-scalars, see also 6e7e63cbb023 ("bpf: Forbid XADD on spilled pointers for unprivileged users") for more context on checkmemaccess() and its handling of placeholder value -1.

One minimally intrusive option to fix the leak is for the BPFFETCH case to initially check the BPFREAD case via checkmemaccess() with -1 as register, followed by the actual load case with non-negative load_reg to propagate stack bounds to registers.

References

Affected packages

Git /

Affected ranges

Database specific

unresolved_ranges
[
    {
        "events": [
            {
                "introduced": "5.12"
            },
            {
                "fixed": "5.15.11"
            }
        ]
    },
    {
        "events": [
            {
                "introduced": "0"
            },
            {
                "last_affected": "5.16-rc1"
            }
        ]
    },
    {
        "events": [
            {
                "introduced": "0"
            },
            {
                "last_affected": "5.16-rc2"
            }
        ]
    },
    {
        "events": [
            {
                "introduced": "0"
            },
            {
                "last_affected": "5.16-rc3"
            }
        ]
    },
    {
        "events": [
            {
                "introduced": "0"
            },
            {
                "last_affected": "5.16-rc4"
            }
        ]
    },
    {
        "events": [
            {
                "introduced": "0"
            },
            {
                "last_affected": "5.16-rc5"
            }
        ]
    }
]
source
"https://storage.googleapis.com/osv-test-cve-osv-conversion/osv-output/CVE-2021-47608.json"