Commit 48da0f6
drm/i915: Fix vm use-after-free in vma destruction
In vma destruction, the following race may occur:
Thread 1: Thread 2:
i915_vma_destroy();
...
list_del_init(vma->vm_link);
...
mutex_unlock(vma->vm->mutex);
__i915_vm_release();
release_references();
And in release_reference() we dereference vma->vm to get to the
vm gt pointer, leading to a use-after free.
However, __i915_vm_release() grabs the vm->mutex so the vm won't be
destroyed before vma->vm->mutex is released, so extract the gt pointer
under the vm->mutex to avoid the vma->vm dereference in
release_references().
v2: Fix a typo in the commit message (Andi Shyti)
Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/5944
Fixes: e1a7ab4 ("drm/i915: Remove the vm open count")
Cc: Niranjana Vishwanathapura <niranjana.vishwanathapura@intel.com>
Cc: Matthew Auld <matthew.auld@intel.com>
Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Acked-by: Nirmoy Das <nirmoy.das@intel.con>
Reviewed-by: Andrzej Hajda <andrzej.hajda@intel.com>
Reviewed-by: Matthew Auld <matthew.auld@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20220620123659.381772-1-thomas.hellstrom@linux.intel.com
(cherry picked from commit 1926a6b)
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>1 parent 1391b9c commit 48da0f6
1 file changed
Lines changed: 8 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1637 | 1637 | | |
1638 | 1638 | | |
1639 | 1639 | | |
1640 | | - | |
| 1640 | + | |
| 1641 | + | |
1641 | 1642 | | |
1642 | 1643 | | |
1643 | | - | |
1644 | 1644 | | |
1645 | 1645 | | |
1646 | 1646 | | |
| |||
1695 | 1695 | | |
1696 | 1696 | | |
1697 | 1697 | | |
1698 | | - | |
| 1698 | + | |
1699 | 1699 | | |
1700 | 1700 | | |
1701 | 1701 | | |
1702 | 1702 | | |
| 1703 | + | |
1703 | 1704 | | |
1704 | 1705 | | |
1705 | 1706 | | |
1706 | 1707 | | |
1707 | 1708 | | |
1708 | 1709 | | |
1709 | 1710 | | |
| 1711 | + | |
| 1712 | + | |
| 1713 | + | |
1710 | 1714 | | |
1711 | | - | |
| 1715 | + | |
1712 | 1716 | | |
1713 | 1717 | | |
1714 | 1718 | | |
| |||
0 commit comments