Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mm: don't do validate_mm() unnecessarily and without mmap locking

This is an addition to commit ae80b4041984 ("mm: validate the mm before
dropping the mmap lock"), because it turns out there were two problems,
but lockdep just stopped complaining after finding the first one.

The do_vmi_align_munmap() function now drops the mmap lock after doing
the validate_mm() call, but it turns out that one of the callers then
immediately calls validate_mm() again.

That's both a bit silly, and now (again) happens without the mmap lock
held.

So just remove that validate_mm() call from the caller, but make sure to
not lose any coverage by doing that mm sanity checking in the error path
of do_vmi_align_munmap() too.

Reported-and-tested-by: kernel test robot <oliver.sang@intel.com>
Link: https://lore.kernel.org/lkml/ZKN6CdkKyxBShPHi@xsang-OptiPlex-9020/
Fixes: 408579cd627a ("mm: Update do_vmi_align_munmap() return semantics")
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

+2 -4
+2 -4
mm/mmap.c
··· 2571 2571 __mt_destroy(&mt_detach); 2572 2572 start_split_failed: 2573 2573 map_count_exceeded: 2574 + validate_mm(mm); 2574 2575 return error; 2575 2576 } 2576 2577 ··· 3020 3019 bool unlock) 3021 3020 { 3022 3021 struct mm_struct *mm = vma->vm_mm; 3023 - int ret; 3024 3022 3025 3023 arch_unmap(mm, start, end); 3026 - ret = do_vmi_align_munmap(vmi, vma, mm, start, end, uf, unlock); 3027 - validate_mm(mm); 3028 - return ret; 3024 + return do_vmi_align_munmap(vmi, vma, mm, start, end, uf, unlock); 3029 3025 } 3030 3026 3031 3027 /*