CVE-2026-99752: drm/loongson: Handle buffer mapping failures when clearing a BO
In the Linux kernel, the following vulnerability has been resolved:
drm/loongson: Handle buffer mapping failures when clearing a BO
lsdcboclear() ignores the return value from lsdcbokmap() and writes to lbo->kptr unconditionally. When the first mapping of a newly allocated buffer fails, kptr is still NULL and the subsequent memset accesses it.
Return the mapping error without touching the buffer and propagate it from lsdcgemobjectcreate(). Install the GEM object functions before clearing so that drmgemobjectput() can release the buffer correctly on failure. Do not add the failed object to the tracking list or return an uncleared buffer to the caller.
Imported buffers still skip clearing, and successfully mapped buffers are cleared and unmapped as before.
Tested on LS7A2000 with a one-shot range error in ttmbokmap(). Its -EINVAL return reached userspace, the object was destroyed once, and no GEM handle was published. Normal create/map/zero/write/read/close cycles passed, with the tracked BO count and VRAM usage unchanged.
AI assistance was used for the lifetime analysis, fix, fault-injection tools, build and test execution.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 6.12.118 - Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 6.18.64 - Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 7.3.5 - Compensating control
In the Loongson DRM GEM buffer creation path, have lsdc_bo_clear() return the lsdc_bo_kmap() error without touching the buffer, propagate the error from lsdc_gem_object_create(), and ensure the failed object is not added to the tracking list or returned to the caller; install the GEM object functions before clearing so drm_gem_object_put() can release it correctly.
Frequently Asked Questions
What conditions are required to trigger the issue?
The failure occurs when a newly allocated, non-imported Loongson DRM buffer object is being cleared and its first kernel mapping attempt fails. The vulnerable path then writes through a NULL buffer pointer.
What is the observable impact of a mapping failure?
Before the fix, the unconditional memset could access a NULL pointer after lsdc_bo_kmap() failed. With the fix, the mapping error is returned to userspace, no GEM handle is published, and the failed object is released.
Are imported buffers affected by the clearing path?
No. Imported buffers skip clearing, so they do not enter the buffer-clearing path described here.
How can a system be checked for this failure mode?
A mapping failure during creation of a Loongson DRM buffer object is the relevant indicator. In the tested fixed behavior, an injected ttm_bo_kmap() range error returned -EINVAL to userspace, destroyed the object once, and did not publish a GEM handle.