GHSL-2021-1029: Use-after-free (UaF) in Qualcomm npu driver - CVE-2021-1940
A use-after-free in the Qualcomm npu driver occurs when a network is executed asynchronously and the associated file is closed before execution completes, leaving a dangling pointer. An attacker could exploit this to gain arbitrary kernel code execution from the untrusted app domain.
Samsung Galaxy A71: SM-A715F/DS AP: A715FXXU3ATJ2 and CP: A715FXXU3ATI5, Kernel version 4.14.117-19828683 and build ID QP1A.190711.020.A715FXXU3ATJ2
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The driver frees the client structure even though a network still holds a pointer to it, because the network unload fails with -EBUSY and the cleanup is skipped.
What the attacker needed
Access to /dev/msm_npu; ability to execute async network
The fix
The fix was made publicly available in the July 2021 bulletin.
How it was found
- Open the npu device file.
- Execute a network with the async option, which returns immediately.
- Close the file associated with the client before the network finishes.
- The driver frees the client but leaves a dangling pointer in the network.
- When the network completes, the driver uses the freed pointer in npu_queue_event.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A use-after-free is a bug where a program frees memory but keeps using it, like deleting a file and still reading it. Here, the driver frees a client structure while a network is still running, so when the network finishes, the driver uses the freed memory. This can let an attacker run their own code in the kernel, the core of the operating system.
What is Memory corruption?
Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.