Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

drm/panthor: Fix UAF on kernel BO VA nodes

If the MMU is down, panthor_vm_unmap_range() might return an error.
We expect the page table to be updated still, and if the MMU is blocked,
the rest of the GPU should be blocked too, so no risk of accessing
physical memory returned to the system (which the current code doesn't
cover for anyway).

Proceed with the rest of the cleanup instead of bailing out and leaving
the va_node inserted in the drm_mm, which leads to UAF when other
adjacent nodes are removed from the drm_mm tree.

Reported-by: Lars-Ivar Hesselberg Simonsen <lars-ivar.simonsen@arm.com>
Closes: https://gitlab.freedesktop.org/panfrost/linux/-/issues/57
Fixes: 8a1cc07578bf ("drm/panthor: Add GEM logical block")
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Liviu Dudau <liviu.dudau@arm.com>
Link: https://patch.msgid.link/20251031154818.821054-2-boris.brezillon@collabora.com
Signed-off-by: Liviu Dudau <liviu.dudau@arm.com>

authored by

Boris Brezillon and committed by
Liviu Dudau
98dd5143 08be57e6

+3 -11
+3 -11
drivers/gpu/drm/panthor/panthor_gem.c
··· 87 87 void panthor_kernel_bo_destroy(struct panthor_kernel_bo *bo) 88 88 { 89 89 struct panthor_vm *vm; 90 - int ret; 91 90 92 91 if (IS_ERR_OR_NULL(bo)) 93 92 return; ··· 94 95 vm = bo->vm; 95 96 panthor_kernel_bo_vunmap(bo); 96 97 97 - if (drm_WARN_ON(bo->obj->dev, 98 - to_panthor_bo(bo->obj)->exclusive_vm_root_gem != panthor_vm_root_gem(vm))) 99 - goto out_free_bo; 100 - 101 - ret = panthor_vm_unmap_range(vm, bo->va_node.start, bo->va_node.size); 102 - if (ret) 103 - goto out_free_bo; 104 - 98 + drm_WARN_ON(bo->obj->dev, 99 + to_panthor_bo(bo->obj)->exclusive_vm_root_gem != panthor_vm_root_gem(vm)); 100 + panthor_vm_unmap_range(vm, bo->va_node.start, bo->va_node.size); 105 101 panthor_vm_free_va(vm, &bo->va_node); 106 102 drm_gem_object_put(bo->obj); 107 - 108 - out_free_bo: 109 103 panthor_vm_put(vm); 110 104 kfree(bo); 111 105 }