Skip to content
Memory corruption Advisory Advanced CVE-2020-11239

GHSL-2020-375: Use-after-free (UaF) in Qualcomm kgsl driver - CVE-2020-11239

A use-after-free flaw in the Qualcomm kgsl driver allows an attacker to free an sg_table while it remains referenced by a dma_buf attachment, leading to arbitrary kernel code execution from the application sandbox.

m-y-mo Follow

Originally disclosed on GitHub Security Lab

Use-after-free in kgslioctlgpuobjimport and kgslioctlmapusermem of the Qualcomm kgsl driver

m-y-mo, on GitHub Security Lab

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

Likely the error path in kgsl_ioctl_gpuobj_import frees the sg_table without detaching the dma_buf attachment that still references it.

Impact

Can be exploited from the application sandbox to achieve arbitrary kernel code execution in many devices.

What the attacker needed

Access to the kgsl driver; ability to call ioctl on a dma_buf

How it was found

  1. Call the kgsl_ioctl_gpuobj_import ioctl with parameter type KGSL_USER_MEM_TYPE_ADDR to create a mapping.
  2. Cause the ioctl to fail at the kgsl_mem_entry_attach_process call, leading to the unmap error path.
  3. The unmap path frees the sg_table via kgsl_sharedmem_free while the dma_buf attachment still references it.
  4. Trigger the use-after-free by calling DMA_BUF_IOCTL_SYNC on the dma_buf.

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 happens when a program frees memory but keeps a pointer to it, so later use of that pointer can corrupt data or run attacker code. Here, a driver error leaves a freed memory table still linked to a buffer, and an attacker can trigger its use to run code in the kernel.

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.

More by m-y-mo

View all

64 more disclosed reports, best first.

More from GitHub Security Lab

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Memory corruption

The lesson behind this report.

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.