Skip to main content
Vulnerability Database/CVE-2025-21842

CVE-2025-21842: Linux Kernel Use-After-Free Vulnerability

CVE-2025-21842 is a use-after-free vulnerability in the Linux kernel affecting the amdkfd driver during user queue initialization. This article covers the technical details, affected versions, security impact, and mitigation strategies.

Published:

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Sources: National Vulnerability Database, CISA KEV, Exploit-DB

CVE-2025-21842 Overview

CVE-2025-21842 is a Linux kernel vulnerability in the AMD Kernel Fusion Driver (amdkfd) component. The flaw stems from improper handling of the gang_ctx_bo graphics translation table (GTT) buffer object cleanup when user queue initialization fails. The destructor function amdgpu_amdkfd_free_gtt_mem expects a void** parameter, but the calling code passes a void* instead. The implicit cast is accepted at compile time but produces incorrect pointer dereferencing at runtime. Local, authenticated users of affected systems can trigger the condition, resulting in kernel-level availability impact on the AMD GPU subsystem.

Critical Impact

Local users with access to the AMD KFD interface can trigger kernel-level errors leading to denial of service on systems using AMD GPUs with Linux kernel 6.14-rc1 or 6.14-rc2.

Affected Products

  • Linux kernel 6.14-rc1
  • Linux kernel 6.14-rc2
  • Systems using the amdkfd driver on AMD GPUs

Discovery Timeline

  • 2025-03-07 - CVE-2025-21842 published to NVD
  • 2026-07-30 - Last updated in NVD database

Technical Details for CVE-2025-21842

Vulnerability Analysis

The vulnerability resides in the AMD Kernel Fusion Driver (amdkfd), which manages compute workload scheduling on AMD GPUs. When user queue initialization fails, the cleanup path for the gang_ctx_bo buffer object invokes amdgpu_amdkfd_free_gtt_mem with the wrong pointer level.

The destructor signature declares the second argument as void **mem_obj. The caller passes a void * value. GCC accepts the mismatch because void * can implicitly convert to any pointer type, including void **. At runtime the function dereferences the parameter as a double pointer, producing an invalid memory access against an arbitrary value treated as an address.

The result is a kernel error path that affects availability on the local system. According to the CVSS vector, the attacker requires local access and low privileges, and the impact is restricted to availability on affected AMD GPU hosts. No confidentiality or integrity impact is reported.

Root Cause

The root cause is a type-level API misuse in the amdkfd error-handling path [CWE-noinfo]. The function contract requires the caller to pass the address of the pointer so the destructor can free the buffer object and clear the caller's reference. Passing a bare void * causes the destructor to dereference the pointer value itself as if it were the address of a pointer, leading to memory corruption or an invalid access during cleanup.

Attack Vector

Exploitation requires local access and the ability to interact with the KFD interface, typically through /dev/kfd. A local user initiates user queue creation operations against the amdkfd driver that fail during initialization. The failure drives execution into the faulty cleanup path, triggering the kernel-level fault. The vulnerability is not remotely reachable and does not permit code execution based on available data; the documented impact is denial of service on the AMD GPU subsystem or host.

No public exploit code or proof of concept is published for CVE-2025-21842. The fix is distributed through the stable kernel Git tree in commits 091a68c58c1b, a33f7f966070, and ae5ab1c1ae50.

Detection Methods for CVE-2025-21842

Indicators of Compromise

  • Kernel oops or warning entries in dmesg referencing amdgpu_amdkfd_free_gtt_mem or gang_ctx_bo during user queue initialization failures.
  • Repeated process crashes or GPU reset events on hosts running Linux kernel 6.14-rc1 or 6.14-rc2 with AMD GPUs.
  • Unexpected failures of KFD-dependent workloads such as ROCm, HIP, or OpenCL applications.

Detection Strategies

  • Inventory Linux hosts and identify systems running kernel versions 6.14-rc1 or 6.14-rc2 with AMD GPUs attached.
  • Monitor kernel ring buffers and journalctl -k output for faults originating in the amdkfd or amdgpu modules.
  • Correlate /dev/kfd open events with subsequent kernel errors to identify local processes exercising the vulnerable code path.

Monitoring Recommendations

  • Collect kernel logs centrally and alert on new oops or BUG entries referencing AMD GPU driver symbols.
  • Track GPU reset counters exposed through sysfs under /sys/class/drm/card*/device/.
  • Audit which local accounts and container workloads have access to /dev/kfd and restrict where possible.

How to Mitigate CVE-2025-21842

Immediate Actions Required

  • Upgrade to a Linux kernel version that includes the upstream fix for the amdkfd cleanup path.
  • Restrict local access to the AMD KFD device node /dev/kfd to trusted users and workloads only.
  • Review container and sandbox configurations to ensure untrusted workloads cannot reach the KFD interface.

Patch Information

The fix was committed to the stable Linux kernel tree. Reference commits: Kernel Git Commit 091a68c, Kernel Git Commit a33f7f9, and Kernel Git Commit ae5ab1c. The patch corrects the caller to pass the address of the pointer so the destructor receives a valid void ** and properly frees the gang_ctx_bo buffer object.

Workarounds

  • If patching is not immediately feasible, downgrade to a stable Linux kernel release that predates the affected 6.14 release candidates.
  • Unload the amdkfd module on hosts that do not require GPU compute functionality: modprobe -r amdkfd.
  • Enforce strict file permissions on /dev/kfd to limit the local attack surface.
bash
# Verify current kernel version and AMD KFD module status
uname -r
lsmod | grep amdkfd

# Restrict access to the KFD device node
ls -l /dev/kfd
chmod 0660 /dev/kfd
chown root:video /dev/kfd

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Sources: National Vulnerability Database, CISA KEV, Exploit-DB

Experience the Most Advanced Cybersecurity Platform

See how the world’s most intelligent, autonomous cybersecurity platform can protect your organization today and into the future.