Skip to content

Commit 30af24f

Browse files
SENSEIIIIIakpm00
authored andcommitted
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: 867a43a ("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>
1 parent 0a69b6b commit 30af24f

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

mm/userfaultfd.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1444,7 +1444,8 @@ static int uffd_move_lock(struct mm_struct *mm,
14441444
*/
14451445
down_read(&(*dst_vmap)->vm_lock->lock);
14461446
if (*dst_vmap != *src_vmap)
1447-
down_read(&(*src_vmap)->vm_lock->lock);
1447+
down_read_nested(&(*src_vmap)->vm_lock->lock,
1448+
SINGLE_DEPTH_NESTING);
14481449
}
14491450
mmap_read_unlock(mm);
14501451
return err;

0 commit comments

Comments
 (0)