drm/amdkfd: fix potential kgd_mem UAFs
authorChia-I Wu <olvaffe@gmail.com>
Wed, 8 Mar 2023 21:37:24 +0000 (13:37 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 6 Apr 2023 10:10:39 +0000 (12:10 +0200)
commit5045360f3bb62ccd4f87202e33489f71f8bbc3fc
tree871ab9302b91daa5dcae2646b4ea3e1d9ed9659c
parentb861f0e62ae148eb5f0a48c4d6fcd5dc03b4e252
drm/amdkfd: fix potential kgd_mem UAFs

[ Upstream commit 9da050b0d9e04439d225a2ec3044af70cdfb3933 ]

kgd_mem pointers returned by kfd_process_device_translate_handle are
only guaranteed to be valid while p->mutex is held. As soon as the mutex
is unlocked, another thread can free the BO.

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Signed-off-by: Felix Kuehling <Felix.Kuehling@amd.com>
Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c