mesa/src/amd
xueyuli2 da7ed1c576 amd/virtio: fix bo use-after-free race condition in amdvgpu_bo_free
In amdvgpu_bo_free(), when the reference count drops to 0, vdrm_flush()
is called before removing the bo from the handle_to_vbo hash table.

Since vdrm_flush() is a time-consuming operation and is executed outside
of the handle_to_vbo_mutex lock, another thread calling amdvgpu_bo_import()
can concurrently find this bo in the hash table, increment its refcount,
and attempt to use it. Once vdrm_flush() finishes, amdvgpu_bo_free()
proceeds to remove the bo and call free(), leaving the importing thread
with a dangling pointer, which leads to a use-after-free or double free
crash.

To fix this race condition, we must remove the bo from the hash table
under the lock first. After the bo is safely unlinked and the lock is
released, we can then perform the time-consuming vdrm_flush() and the
actual memory release.

Signed-off-by: zhaqian <zhaqian@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41146>
2026-04-30 08:41:50 +00:00
..
addrlib amd: allow addrlib to enable SIMD if possible 2026-04-21 10:14:42 +00:00
ci radv/ci: bump timeouts for radv-{navi21,gfx1201}-vkcts-full 2026-04-30 07:56:04 +00:00
common amd/virtio: fix bo use-after-free race condition in amdvgpu_bo_free 2026-04-30 08:41:50 +00:00
compiler ac/nir: add ac_nir_assign_fs_input_locations to set PS input locations in stone 2026-04-27 21:05:53 +00:00
drm-shim amd: remove unnecessary and transitive #includes 2026-04-24 21:53:07 +00:00
gmlib amd/gmlib: add tm_generate_formatted_3DLut 2026-04-29 07:46:28 +00:00
lanczoslib meson: Relax -Wmaybe-uninitialized errors 2025-09-16 06:16:20 +00:00
llvm ac/nir: add ac_nir_assign_fs_input_locations to set PS input locations in stone 2026-04-27 21:05:53 +00:00
packets amd: remove unnecessary and transitive #includes 2026-04-24 21:53:07 +00:00
registers amd: switch to new packet definitions for all packets 2026-04-10 03:42:45 +00:00
vpelib amd/vpelib: Support vpe 2.0 2026-04-27 03:06:42 +00:00
vulkan radv: re-organize radv_cmd_state slightly 2026-04-30 06:18:29 +00:00
meson.build radv/tests: require drm-shim and use it instead of RADV_FORCE_FAMILY 2025-11-19 07:11:05 +00:00