Skip to content

Commit b5641a5

Browse files
committed
mm: don't do validate_mm() unnecessarily and without mmap locking
This is an addition to commit ae80b40 ("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: 408579c ("mm: Update do_vmi_align_munmap() return semantics") Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 24be4d0 commit b5641a5

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

mm/mmap.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2571,6 +2571,7 @@ do_vmi_align_munmap(struct vma_iterator *vmi, struct vm_area_struct *vma,
25712571
__mt_destroy(&mt_detach);
25722572
start_split_failed:
25732573
map_count_exceeded:
2574+
validate_mm(mm);
25742575
return error;
25752576
}
25762577

@@ -3019,12 +3020,9 @@ int do_vma_munmap(struct vma_iterator *vmi, struct vm_area_struct *vma,
30193020
bool unlock)
30203021
{
30213022
struct mm_struct *mm = vma->vm_mm;
3022-
int ret;
30233023

30243024
arch_unmap(mm, start, end);
3025-
ret = do_vmi_align_munmap(vmi, vma, mm, start, end, uf, unlock);
3026-
validate_mm(mm);
3027-
return ret;
3025+
return do_vmi_align_munmap(vmi, vma, mm, start, end, uf, unlock);
30283026
}
30293027

30303028
/*

0 commit comments

Comments
 (0)