Re: [PATCH] userfaultfd: fix deadlock warning when locking src and dst VMAs
From: Andrew Morton
Date: Thu Mar 21 2024 - 20:47:50 EST
On Thu, 21 Mar 2024 16:58:18 -0700 Lokesh Gidra <lokeshgidra@xxxxxxxxxx> wrote:
> Use down_read_nested() to avoid the warning.
>
> --- a/mm/userfaultfd.c
> +++ b/mm/userfaultfd.c
> @@ -1444,7 +1444,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;
Thanks, I added
Fixes: 867a43a34ff8a ("userfaultfd: use per-vma locks in userfaultfd operations")