]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
mm: mark VMA as being written when changing vm_flags
authorSuren Baghdasaryan <surenb@google.com>
Mon, 27 Feb 2023 17:36:12 +0000 (09:36 -0800)
committerAndrew Morton <akpm@linux-foundation.org>
Wed, 5 Apr 2023 23:02:07 +0000 (16:02 -0700)
Updates to vm_flags have to be done with VMA marked as being written for
preventing concurrent page faults or other modifications.

Link: https://lkml.kernel.org/r/20230227173632.3292573-14-surenb@google.com
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
include/linux/mm.h

index bbad5d4fa81b488999fba7d2cdaadd42fbc28e6b..3d5e8666892daf5edb3fdd5bfbb30590ece99a7a 100644 (file)
@@ -726,28 +726,28 @@ static inline void vm_flags_init(struct vm_area_struct *vma,
 static inline void vm_flags_reset(struct vm_area_struct *vma,
                                  vm_flags_t flags)
 {
-       mmap_assert_write_locked(vma->vm_mm);
+       vma_start_write(vma);
        vm_flags_init(vma, flags);
 }
 
 static inline void vm_flags_reset_once(struct vm_area_struct *vma,
                                       vm_flags_t flags)
 {
-       mmap_assert_write_locked(vma->vm_mm);
+       vma_start_write(vma);
        WRITE_ONCE(ACCESS_PRIVATE(vma, __vm_flags), flags);
 }
 
 static inline void vm_flags_set(struct vm_area_struct *vma,
                                vm_flags_t flags)
 {
-       mmap_assert_write_locked(vma->vm_mm);
+       vma_start_write(vma);
        ACCESS_PRIVATE(vma, __vm_flags) |= flags;
 }
 
 static inline void vm_flags_clear(struct vm_area_struct *vma,
                                  vm_flags_t flags)
 {
-       mmap_assert_write_locked(vma->vm_mm);
+       vma_start_write(vma);
        ACCESS_PRIVATE(vma, __vm_flags) &= ~flags;
 }
 
@@ -768,7 +768,7 @@ static inline void __vm_flags_mod(struct vm_area_struct *vma,
 static inline void vm_flags_mod(struct vm_area_struct *vma,
                                vm_flags_t set, vm_flags_t clear)
 {
-       mmap_assert_write_locked(vma->vm_mm);
+       vma_start_write(vma);
        __vm_flags_mod(vma, set, clear);
 }