Re: [syzbot] [mm?] possible deadlock in move_pages

From: Hillf Danton
Date: Wed Mar 20 2024 - 06:46:24 EST


On Tue, 19 Mar 2024 02:52:16 -0700
> syzbot found the following issue on:
>
> HEAD commit: e5eb28f6d1af Merge tag 'mm-nonmm-stable-2024-03-14-09-36' ..
> git tree: upstream
> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=173b7ac9180000

#syz test https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git e5eb28f6d1af

--- x/mm/userfaultfd.c
+++ y/mm/userfaultfd.c
@@ -1442,9 +1442,9 @@ static int uffd_move_lock(struct mm_stru
* See comment in lock_vma() as to why not using
* vma_start_read() here.
*/
- down_read(&(*dst_vmap)->vm_lock->lock);
+ down_read_nested(&(*dst_vmap)->vm_lock->lock, 1);
if (*dst_vmap != *src_vmap)
- down_read(&(*src_vmap)->vm_lock->lock);
+ down_read_nested(&(*src_vmap)->vm_lock->lock, 2);
}
mmap_read_unlock(mm);
return err;
--