Files
linux/drivers/gpu/drm/amd/amdgpu
Sunil Khatri 65b5c326ce drm/amdgpu/userq: refcount userqueues to avoid any race conditions
To avoid race condition and avoid UAF cases, implement kref
based queues and protect the below operations using xa lock
a. Getting a queue from xarray
b. Increment/Decrement it's refcount

Every time some one want to access a queue, always get via
amdgpu_userq_get to make sure we have locks in place and get
the object if active.

A userqueue is destroyed on the last refcount is dropped which
typically would be via IOCTL or during fini.

v2: Add the missing drop in one the condition in the signal ioclt [Alex]

v3: remove the queue from the xarray first in the free queue ioctl path
    [Christian]

- Pass queue to the amdgpu_userq_put directly.
- make amdgpu_userq_put xa_lock free since we are doing put for each get
  only and final put is done via destroy and we remove the queue from xa
  with lock.
- use userq_put in fini too so cleanup is done fully.

v4: Use xa_erase directly rather than doing load and erase in free
    ioctl. Also remove some of the error logs which could be exploited
    by the user to flood the logs [Christian]

Signed-off-by: Sunil Khatri <sunil.khatri@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit 4952189b284d4d847f92636bb42dd747747129c0)
Cc: <stable@vger.kernel.org> # 048c1c4e51: drm/amdgpu/userq: Consolidate wait ioctl exit path
Cc: <stable@vger.kernel.org>
2026-03-04 13:15:00 -05:00
..
2024-07-24 17:30:23 -04:00
2026-01-20 17:25:53 -05:00
2025-10-13 14:14:15 -04:00
2024-11-03 01:28:06 -05:00
2026-01-05 16:59:55 -05:00
2024-07-24 17:30:23 -04:00
2024-07-24 17:30:23 -04:00
2026-01-05 16:59:55 -05:00
2026-01-05 16:59:55 -05:00
2026-01-05 16:59:55 -05:00
2026-01-08 11:41:34 -05:00
2026-01-05 16:59:55 -05:00
2025-12-08 13:56:42 -05:00
2026-01-05 16:59:55 -05:00
2026-01-05 16:59:55 -05:00
2026-01-05 16:59:55 -05:00
2026-02-12 15:23:39 -05:00
2026-01-05 16:59:55 -05:00
2026-01-05 16:59:55 -05:00
2026-01-05 16:59:55 -05:00
2026-01-05 16:59:55 -05:00
2026-01-05 16:59:55 -05:00
2026-01-05 16:59:55 -05:00
2026-01-05 16:59:55 -05:00
2025-12-08 13:56:42 -05:00