mirror of
https://github.com/torvalds/linux.git
synced 2026-09-14 16:10:02 +02:00
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:
|
||
|---|---|---|
| .. | ||
| Kconfig | ||
| Makefile | ||
| rocket_core.c | ||
| rocket_core.h | ||
| rocket_device.c | ||
| rocket_device.h | ||
| rocket_drv.c | ||
| rocket_drv.h | ||
| rocket_gem.c | ||
| rocket_gem.h | ||
| rocket_job.c | ||
| rocket_job.h | ||
| rocket_registers.h | ||