CVE-2026-138850: misc: fastrpc: fix double-free in fastrpc_map_attach() error path
In the Linux kernel, the following vulnerability has been resolved:
misc: fastrpc: fix double-free in fastrpcmapattach() error path
map->table is assigned right after dmabufmapattachmentunlocked() succeeds. The two failure checks that follow, the len > map->size test and, where subsystem VMIDs are configured, a failed qcomscmassignmem(), jump to maperr with map->table already set.
maperr manually calls dmabufdetach() and dmabufput() and then falls through to fastrpcmapput(). Since that change the error path tail is fastrpcmapput() -> fastrpcfreemap(), and fastrpcfreemap() already unmaps, detaches and puts the dma-buf whenever map->table is set. The two operations therefore run twice: the second dmabufput() drops an extra reference on map->buf, and dmabufunmapattachmentunlocked() dereferences the map->attach already freed by the manual dmabufdetach(). krefinit() sets the refcount to 1 with no intervening get, so the final fastrpcmapput() frees the map synchronously and the redundant cleanup is deterministic.
The len > map->size branch is reachable by an unprivileged process via FASTRPCIOCTLMEMMAP with an fd whose dma-buf is smaller than the requested length, before any DSP invocation.
Route both map->table-is-set failure branches to geterr instead of maperr, so fastrpcfreemap() is the single owner of the unmap/detach/put sequence. maperr is retained for the dmabufmapattachmentunlocked() failure, which is reached with map->table still NULL and an attachment that fastrpcfreemap() will not clean up, so its dmabufdetach()/dmabufput() must still run manually.
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.6.163 - 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.4 - Upgrade
Upgrade
debian/linuxto a version that resolves this vulnerability.Fixed in 6.12.118-1 - Upgrade
Upgrade
debian/linuxto a version that resolves this vulnerability.Fixed in 7.3.4-1 - Upgrade
Upgrade
debian/linuxto a version that resolves this vulnerability.Fixed in 6.12.118-1Fixed in 7.3.4-1 - Compensating control
In fastrpc_map_attach(), route both map->table-is-set failure branches to get_err instead of map_err, so fastrpc_free_map() remains the sole owner of the dma-buf unmap/detach/put cleanup.
Event History
Frequently Asked Questions
Can an unprivileged local process trigger this issue?
Yes. An unprivileged process can reach the affected length-check error path through FASTRPC_IOCTL_MEM_MAP by supplying an fd whose dma-buf is smaller than the requested mapping length.
Does exploitation depend on subsystem VMID configuration?
No for the dma-buf length-check path. The length-greater-than-map-size failure path is independent of subsystem VMID configuration; configured VMIDs add another affected path if qcom_scm_assign_mem() fails.
What happens when the affected error path is reached?
Cleanup runs twice after the mapping table has been set. This drops an extra dma-buf reference and can dereference an attachment that was already freed; the map object is then freed synchronously because its reference count was initialized to one without an intervening reference acquisition.