Skip to main content

CVE-2021-47607: Vulnerability in Linux Linux

High
VulnerabilityCVE-2021-47607cvecve-2021-47607
Published: Wed Jun 19 2024 (06/19/2024, 14:54:05 UTC)
Source: CVE
Vendor/Project: Linux
Product: 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.

AI-Powered Analysis

AILast updated: 06/30/2025, 15:25:42 UTC

Technical Analysis

CVE-2021-47607 is a vulnerability in the Linux kernel's implementation of the BPF (Berkeley Packet Filter) subsystem, specifically in the atomic compare-and-exchange (cmpxchg) operation used by BPF programs. The vulnerability arises because the kernel verifier fails to reject unprivileged BPF programs where the R0 register contains a pointer as the 'old value' parameter in the BPF_CMPXCHG instruction. Normally, BPF_CMPXCHG compares a memory location's current value with an expected old value and, if they match, swaps it with a new value. The R0 register is used both as an input (old value) and output (returning the old value from memory). However, the verifier does not properly check that R0 does not hold a pointer in unprivileged programs, allowing attackers to leak kernel memory addresses by brute forcing. The proof-of-concept (PoC) demonstrates that an attacker can leak kernel pointers by probing addresses and using map slots to detect matches, taking approximately 16 seconds on the author's machine. This kernel address leakage can facilitate further attacks such as kernel address space layout randomization (KASLR) bypass, which is a critical step in privilege escalation exploits. The vulnerability was fixed by adding checks to reject unprivileged programs where R0 contains pointers during the cmpxchg operation. No known exploits are reported in the wild at the time of publication, and no CVSS score has been assigned yet.

Potential Impact

For European organizations, this vulnerability poses a significant risk primarily to systems running vulnerable Linux kernel versions that support unprivileged BPF programs. The ability to leak kernel pointers undermines kernel address space layout randomization (KASLR), a key security mechanism designed to prevent attackers from reliably exploiting kernel vulnerabilities. By bypassing KASLR, attackers can more easily develop and execute privilege escalation exploits, potentially gaining root-level access to affected systems. This can lead to full system compromise, data breaches, disruption of critical services, and lateral movement within networks. Organizations relying on Linux servers for critical infrastructure, cloud services, or internal operations could face increased risk of targeted attacks, especially if attackers combine this vulnerability with other kernel bugs. The lack of requirement for user interaction and the relatively fast brute force time (~16 seconds) increase the threat's practicality. Although no exploits are currently known in the wild, the vulnerability's nature and ease of exploitation make it a high-value target for attackers aiming to escalate privileges on Linux hosts.

Mitigation Recommendations

European organizations should prioritize updating their Linux kernels to versions that include the patch for CVE-2021-47607. Since the vulnerability involves unprivileged BPF programs, organizations should audit and restrict the use of unprivileged BPF where possible, using kernel lockdown features or security modules like SELinux or AppArmor to limit BPF program loading and execution. Additionally, system administrators should monitor for unusual BPF activity or kernel pointer leaks using advanced kernel auditing tools and intrusion detection systems. For environments where immediate patching is not feasible, consider disabling unprivileged BPF program loading via sysctl settings (e.g., setting /proc/sys/kernel/unprivileged_bpf_disabled to 1) to reduce attack surface. Regularly review and harden kernel security configurations and ensure that only trusted users have the capability to load BPF programs. Finally, maintain comprehensive logging and alerting to detect potential exploitation attempts early.

Need more detailed analysis?Get Pro

Technical Details

Data Version
5.1
Assigner Short Name
Linux
Date Reserved
2024-05-24T15:11:00.737Z
Cisa Enriched
true
Cvss Version
null
State
PUBLISHED

Threat ID: 682d9834c4522896dcbe959f

Added to database: 5/21/2025, 9:09:08 AM

Last enriched: 6/30/2025, 3:25:42 PM

Last updated: 8/13/2025, 3:50:58 PM

Views: 14

Actions

PRO

Updates to AI analysis are available only with a Pro account. Contact root@offseq.com for access.

Please log in to the Console to use AI analysis features.

Need enhanced features?

Contact root@offseq.com for Pro access with improved analysis and higher rate limits.

Latest Threats