mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-05 18:41:58 +09:00
UPSTREAM: userfaultfd: fix deadlock warning when locking src and dst VMAs
Use down_read_nested() to avoid the warning. Link: https://lkml.kernel.org/r/20240321235818.125118-1-lokeshgidra@google.com Fixes: 867a43a34ff8 ("userfaultfd: use per-vma locks in userfaultfd operations") Reported-by: syzbot+49056626fe41e01f2ba7@syzkaller.appspotmail.com Signed-off-by: Lokesh Gidra <lokeshgidra@google.com> Cc: Andrea Arcangeli <aarcange@redhat.com> Cc: Axel Rasmussen <axelrasmussen@google.com> Cc: Brian Geffon <bgeffon@google.com> Cc: David Hildenbrand <david@redhat.com> Cc: Hillf Danton <hdanton@sina.com> Cc: Jann Horn <jannh@google.com> [Bug #2] Cc: Kalesh Singh <kaleshsingh@google.com> Cc: Lokesh Gidra <lokeshgidra@google.com> Cc: Mike Rapoport (IBM) <rppt@kernel.org> Cc: Nicolas Geoffray <ngeoffray@google.com> Cc: Peter Xu <peterx@redhat.com> Cc: Suren Baghdasaryan <surenb@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> (cherry picked from commit 30af24facf0aed12dec23bdf6eac6a907f88306a) Bug: 320478828 Change-Id: I56d7e33878d6248bba28e1e4204e2b9005d87e4d Signed-off-by: Lokesh Gidra <lokeshgidra@google.com>
This commit is contained in:
@@ -1383,7 +1383,8 @@ static int uffd_move_lock(struct mm_struct *mm,
|
||||
*/
|
||||
down_read(&(*dst_vmap)->vm_lock->lock);
|
||||
if (*dst_vmap != *src_vmap)
|
||||
down_read(&(*src_vmap)->vm_lock->lock);
|
||||
down_read_nested(&(*src_vmap)->vm_lock->lock,
|
||||
SINGLE_DEPTH_NESTING);
|
||||
}
|
||||
mmap_read_unlock(mm);
|
||||
return err;
|
||||
|
||||
Reference in New Issue
Block a user