UPSTREAM: mm: write-lock VMAs before removing them from VMA tree

Write-locking VMAs before isolating them ensures that page fault handlers
don't operate on isolated VMAs.

[surenb@google.com: mm/nommu: remove unnecessary VMA locking]
  Link: https://lkml.kernel.org/r/20230301190457.1498985-1-surenb@google.com
  Link: https://lore.kernel.org/all/Y%2F8CJQGNuMUTdLwP@localhost/
Link: https://lkml.kernel.org/r/20230227173632.3292573-19-surenb@google.com
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: Hyeonggon Yoo <42.hyeyoo@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

(cherry picked from commit 73046fd00b069ffd198eda099dae966e152fae39)

Bug: 161210518
Change-Id: Ia742da40896e6bc4e8150911596f80dca5ef3e12
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
This commit is contained in:
Suren Baghdasaryan 2023-02-27 09:36:17 -08:00 committed by Carlos Llamas
parent 24ecdbc5e2
commit 5f1e1ab919

View file

@ -2317,6 +2317,7 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
static inline int munmap_sidetree(struct vm_area_struct *vma, int count,
struct ma_state *mas_detach)
{
vma_start_write(vma);
mas_set(mas_detach, count);
if (mas_store_gfp(mas_detach, vma, GFP_KERNEL))
return -ENOMEM;