drm/xe/vm: move xa_alloc to prevent UAF
authorMatthew Auld <matthew.auld@intel.com>
Wed, 25 Sep 2024 07:14:27 +0000 (08:14 +0100)
committerLucas De Marchi <lucas.demarchi@intel.com>
Thu, 3 Oct 2024 06:22:05 +0000 (01:22 -0500)
commit74231870cf4976f69e83aa24f48edb16619f652f
treeffbaeb8fc1c74f6d368f30b957e54cd694174e6f
parent9e3c85ddea7a473ed57b6cdfef2dfd468356fc91
drm/xe/vm: move xa_alloc to prevent UAF

Evil user can guess the next id of the vm before the ioctl completes and
then call vm destroy ioctl to trigger UAF since create ioctl is still
referencing the same vm. Move the xa_alloc all the way to the end to
prevent this.

v2:
 - Rebase

Fixes: dd08ebf6c352 ("drm/xe: Introduce a new DRM driver for Intel GPUs")
Signed-off-by: Matthew Auld <matthew.auld@intel.com>
Cc: Matthew Brost <matthew.brost@intel.com>
Cc: <stable@vger.kernel.org> # v6.8+
Reviewed-by: Nirmoy Das <nirmoy.das@intel.com>
Reviewed-by: Matthew Brost <matthew.brost@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240925071426.144015-3-matthew.auld@intel.com
(cherry picked from commit dcfd3971327f3ee92765154baebbaece833d3ca9)
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
drivers/gpu/drm/xe/xe_vm.c