]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
accel/amdxdna: Fix locally exploitable BUG_ON in amdxdna_insert_pages()
authorLizhi Hou <lizhi.hou@amd.com>
Fri, 31 Jul 2026 18:59:55 +0000 (11:59 -0700)
committerLizhi Hou <lizhi.hou@amd.com>
Sat, 1 Aug 2026 05:40:29 +0000 (22:40 -0700)
commit4a19f7ab5972ef608b31ae921419bc3e04b3f8ad
tree90d798a9e76089c0ae97eb39abe1391e5a7bcf23
parent8d51e0fd3e698919d2adeff71936377f0c0d4aa0
accel/amdxdna: Fix locally exploitable BUG_ON in amdxdna_insert_pages()

In amdxdna_insert_pages(), vm_flags_mod() sets VM_MIXEDMAP and clears
VM_PFNMAP. If an unprivileged userspace process mmaps a non-imported GEM
object and then calls madvise(MADV_DONTNEED), the PTEs will be
successfully cleared because VM_MIXEDMAP allows this (unlike VM_PFNMAP).

When userspace subsequently accesses the memory, drm_gem_shmem_fault()
handles the page fault and attempts to map the backing shmem page via
vmf_insert_pfn() which calls vmf_insert_pfn_prot(). Because the backing
shmem page is normal system memory (pfn_valid(pfn) is true) and the VMA
now has VM_MIXEDMAP set, won't this predictably trigger the explicit
assertion BUG_ON((vma->vm_flags & VM_MIXEDMAP) && pfn_valid(pfn))

Fix by removing the vm_flags_mod() call and replacing the vm_insert_pages()
pre-population with the handle_mm_fault() loop that was already used for
the import (dma-buf) path.

Fixes: e486147c912f ("accel/amdxdna: Add BO import and export")
Reviewed-by: Max Zhen <max.zhen@amd.com>
Signed-off-by: Lizhi Hou <lizhi.hou@amd.com>
Link: https://patch.msgid.link/20260731185955.3449311-1-lizhi.hou@amd.com
drivers/accel/amdxdna/amdxdna_gem.c