mirror-linux/drivers/accel/rocket
Dhabaleshwar Das f706e6a4ce accel/rocket: fix UAF via dangling GEM handle in create_bo
rocket_ioctl_create_bo() inserts a GEM handle into the file's IDR via
drm_gem_handle_create() early on, then performs several operations that
can fail (sgt allocation, drm_mm insert, iommu_map). If any fail after
the handle is live, the error path calls drm_gem_shmem_object_free()
which kfree's the object without removing the handle from the IDR.

This leaves a dangling handle pointing to freed slab memory. Any
subsequent ioctl using that handle (PREP_BO, FINI_BO, SUBMIT) calls
drm_gem_object_lookup() and dereferences freed memory (UAF).

Fix by moving drm_gem_handle_create() to after all fallible operations
succeed, matching the pattern used by panfrost, lima, and etnaviv.

Also fix drm_mm_insert_node_generic() whose return value was silently
overwritten by iommu_map_sgtable() on the next line. Add the missing
error check.

[tomeu: Move handle creation to the very end]

Fixes: 658ebeac33 ("accel/rocket: Add IOCTL for BO creation")
Reported-by: Dhabaleshwar Das <dhabal123@gmail.com>
Signed-off-by: Dhabaleshwar Das <dhabal123@gmail.com>
Reviewed-by: Tomeu Vizoso <tomeu@tomeuvizoso.net>
Link: https://patch.msgid.link/20260521165720.2113571-1-tomeu@tomeuvizoso.net
Signed-off-by: Tomeu Vizoso <tomeu@tomeuvizoso.net>
2026-05-21 19:01:23 +02:00
..
Kconfig accel/rocket: Depend on DRM_ACCEL not just DRM 2025-09-01 12:11:28 +02:00
Makefile accel/rocket: Add job submission IOCTL 2025-07-25 10:02:27 -06:00
rocket_core.c accel/rocket: fix unwinding in error path in rocket_core_init 2026-01-10 17:49:14 +01:00
rocket_core.h accel/rocket: Add job submission IOCTL 2025-07-25 10:02:27 -06:00
rocket_device.c accel/rocket: Add job submission IOCTL 2025-07-25 10:02:27 -06:00
rocket_device.h accel/rocket: Add job submission IOCTL 2025-07-25 10:02:27 -06:00
rocket_drv.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
rocket_drv.h accel/rocket: Fix undeclared const rocket_pm_ops 2025-08-03 17:40:23 +02:00
rocket_gem.c accel/rocket: fix UAF via dangling GEM handle in create_bo 2026-05-21 19:01:23 +02:00
rocket_gem.h accel/rocket: Add IOCTLs for synchronizing memory accesses 2025-07-25 10:04:46 -06:00
rocket_job.c Convert remaining multi-line kmalloc_obj/flex GFP_KERNEL uses 2026-02-22 08:26:33 -08:00
rocket_job.h accel/rocket: Add job submission IOCTL 2025-07-25 10:02:27 -06:00
rocket_registers.h