]> www.infradead.org Git - users/jedix/linux-maple.git/commit
drm/xe/client: add missing bo locking in show_meminfo()
authorMatthew Auld <matthew.auld@intel.com>
Wed, 11 Sep 2024 15:55:28 +0000 (16:55 +0100)
committerLucas De Marchi <lucas.demarchi@intel.com>
Wed, 18 Sep 2024 04:30:02 +0000 (23:30 -0500)
commit69bbe3adf36de47315498c9384f99a1ff9171694
tree5cba6f417432347df2f326c657c0148b5f4f0928
parent99b1f7493bfa757b03d41ee6d7f7d00f81fcba5d
drm/xe/client: add missing bo locking in show_meminfo()

bo_meminfo() wants to inspect bo state like tt and the ttm resource,
however this state can change at any point leading to stuff like NPD and
UAF, if the bo lock is not held. Grab the bo lock when calling
bo_meminfo(), ensuring we drop any spinlocks first. In the case of
object_idr we now also need to hold a ref.

v2 (MattB)
  - Also add xe_bo_assert_held()

Fixes: 0845233388f8 ("drm/xe: Implement fdinfo memory stats printing")
Signed-off-by: Matthew Auld <matthew.auld@intel.com>
Cc: Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>
Cc: Tejas Upadhyay <tejas.upadhyay@intel.com>
Cc: "Thomas Hellström" <thomas.hellstrom@linux.intel.com>
Cc: <stable@vger.kernel.org> # v6.8+
Reviewed-by: Matthew Brost <matthew.brost@intel.com>
Reviewed-by: Tejas Upadhyay <tejas.upadhyay@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240911155527.178910-6-matthew.auld@intel.com
(cherry picked from commit 4f63d712fa104c3ebefcb289d1e733e86d8698c7)
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
drivers/gpu/drm/xe/xe_drm_client.c