Commit f4b32b7f authored by Suren Baghdasaryan's avatar Suren Baghdasaryan
Browse files

FROMGIT: mm: fix a lockdep issue in vma_assert_write_locked

__is_vma_write_locked() can be used only when mmap_lock is write-locked to
guarantee vm_lock_seq and mm_lock_seq stability during the check.
Therefore it asserts this condition before further checks.  Because of
that it can't be used unless the user expects the mmap_lock to be
write-locked.  vma_assert_locked() can't assume this before ensuring that
VMA is not read-locked.

Change the order of the checks in vma_assert_locked() to check if the VMA
is read-locked first and only then assert if it's not write-locked.

Link: https://lkml.kernel.org/r/20230712195652.969194-1-surenb@google.com


Fixes: 50b88b63e3e4 ("mm: handle userfaults under VMA lock")
Signed-off-by: default avatarSuren Baghdasaryan <surenb@google.com>
Reported-by: default avatarLiam R. Howlett <liam.howlett@oracle.com>
Closes: https://lore.kernel.org/all/20230712022620.3yytbdh24b7i4zrn@revolver/


Reported-by: default avatar <syzbot+339b02f826caafd5f7a8@syzkaller.appspotmail.com>
Closes: https://lore.kernel.org/all/0000000000002db68f05ffb791bc@google.com/


Cc: Christian Brauner <brauner@kernel.org>
Cc: Laurent Dufour <ldufour@linux.ibm.com>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Michel Lespinasse <michel@lespinasse.org>
Cc: Paul E. McKenney <paulmck@kernel.org>
Cc: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>

(cherry picked from commit 781537884e9905f2df812c8b754165dd606ae300
https: //git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-unstable)
Bug: 161210518
Change-Id: Ida7831576918000bb73850e639aae0d82f0c9fca
Signed-off-by: default avatarSuren Baghdasaryan <surenb@google.com>
parent 250f1977
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment