# CVE-2021-47607: bpf: Fix kernel address leakage in atomic cmpxchg's r0 aux reg

- Severity: Medium 5.5 (CVSS:3.1, scored by NVD) `CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N`
- Known to be exploited: not in CISA's catalogue, which lists only what CISA has confirmed
- Likelihood of exploitation in the next 30 days (EPSS): 0.29%, higher than 14% of CVEs (2026-11-30)
- Published: 2024-06-19T14:54:05.700Z
- Modified: 2026-06-17T04:18:09.170Z
- SSVC (CISA-ADP): exploitation none, automatable no, technical impact partial
- Assigned by: Linux

## Description

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

bpf: Fix kernel address leakage in atomic cmpxchg's r0 aux reg

The implementation of BPF_CMPXCHG on a high level has the following parameters:

  .-[old-val]                                          .-[new-val]
  BPF_R0 = cmpxchg{32,64}(DST_REG + insn->off, BPF_R0, SRC_REG)
                          `-[mem-loc]          `-[old-val]

Given a BPF insn can only have two registers (dst, src), the R0 is fixed and
used as an auxilliary register for input (old value) as well as output (returning
old value from memory location). While the verifier performs a number of safety
checks, it misses to reject unprivileged programs where R0 contains a pointer as
old value.

Through brute-forcing it takes about ~16sec on my machine to leak a kernel pointer
with BPF_CMPXCHG. The PoC is basically probing for kernel addresses by storing the
guessed address into the map slot as a scalar, and using the map value pointer as
R0 while SRC_REG has a canary value to detect a matching address.

Fix it by checking R0 for pointers, and reject if that's the case for unprivileged
programs.

(As written by CVE List.)

## Affected

- Linux Linux: from 5ffa25502b5ab3d639829a2d1e316cff7f59a41e before f87a6c160ecc8c7b417d25f508d3f076fe346136; from 5ffa25502b5ab3d639829a2d1e316cff7f59a41e before a82fe085f344ef20b452cd5f481010ff96b5c4cd; 5.12 (not affected: before 5.12; from 5.15.11 up to 5.15.*; from 5.16 up to *)
- linux linux_kernel: from 5.12 before 5.15.11; 5.16

## References

- <https://git.kernel.org/stable/c/f87a6c160ecc8c7b417d25f508d3f076fe346136> (patch)
- <https://git.kernel.org/stable/c/a82fe085f344ef20b452cd5f481010ff96b5c4cd> (patch)

## Sources

- CVE List: [CVE-2021-47607](https://www.cve.org/CVERecord?id=CVE-2021-47607), CVE Terms of Use, modified 2026-05-11
- NVD: [CVE-2021-47607](https://nvd.nist.gov/vuln/detail/CVE-2021-47607), Public domain, modified 2026-06-17

---

Page: https://cve.day/CVE-2021-47607 · Whole record: https://cve.day/CVE-2021-47607.json · Rebuilt by cve.day 2026-11-25T22:58:08.940Z
