Skip to content

Commit 7057a8f

Browse files
robclarkrodrigovivi
authored andcommitted
drm/i915: Fix potential bit_17 double-free
A userspace with multiple threads racing I915_GEM_SET_TILING to set the tiling to I915_TILING_NONE could trigger a double free of the bit_17 bitmask. (Or conversely leak memory on the transition to tiled.) Move allocation/free'ing of the bitmask within the section protected by the obj lock. Signed-off-by: Rob Clark <[email protected]> Fixes: 2850748 ("drm/i915: Pull i915_vma_pin under the vm->mutex") Cc: <[email protected]> # v5.5+ [tursulin: Correct fixes tag and added cc stable.] Reviewed-by: Tvrtko Ursulin <[email protected]> Signed-off-by: Tvrtko Ursulin <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] (cherry picked from commit 10e0cba) Signed-off-by: Rodrigo Vivi <[email protected]>
1 parent 5bc4b43 commit 7057a8f

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

drivers/gpu/drm/i915/gem/i915_gem_tiling.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -305,10 +305,6 @@ i915_gem_object_set_tiling(struct drm_i915_gem_object *obj,
305305
spin_unlock(&obj->vma.lock);
306306

307307
obj->tiling_and_stride = tiling | stride;
308-
i915_gem_object_unlock(obj);
309-
310-
/* Force the fence to be reacquired for GTT access */
311-
i915_gem_object_release_mmap_gtt(obj);
312308

313309
/* Try to preallocate memory required to save swizzling on put-pages */
314310
if (i915_gem_object_needs_bit17_swizzle(obj)) {
@@ -321,6 +317,11 @@ i915_gem_object_set_tiling(struct drm_i915_gem_object *obj,
321317
obj->bit_17 = NULL;
322318
}
323319

320+
i915_gem_object_unlock(obj);
321+
322+
/* Force the fence to be reacquired for GTT access */
323+
i915_gem_object_release_mmap_gtt(obj);
324+
324325
return 0;
325326
}
326327

0 commit comments

Comments
 (0)