drm/ttm: fix use-after-free races in vm fault handling
commitf89d35abea21d84ed8e9df999842c223cf57f1ba
authorNicolai Hähnle <nicolai.haehnle@amd.com>
Sat, 18 Feb 2017 21:59:56 +0000 (18 22:59 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 14 May 2017 12:08:30 +0000 (14 14:08 +0200)
tree8184fd05ed1ef6b4670ef57733bc148dd75afbba
parent2f6aeeae43bbb603a47013923402150493e3ac2f
drm/ttm: fix use-after-free races in vm fault handling

commit 3089c1df10e2931b1d72d2ffa7d86431084c86b3 upstream.

The vm fault handler relies on the fact that the VMA owns a reference
to the BO. However, once mmap_sem is released, other tasks are free to
destroy the VMA, which can lead to the BO being freed. Fix two code
paths where that can happen, both related to vm fault retries.

Found via a lock debugging warning which flagged &bo->wu_mutex as
locked while being destroyed.

Fixes: cbe12e74ee4e ("drm/ttm: Allow vm fault retries")
Signed-off-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/gpu/drm/ttm/ttm_bo_vm.c