The patch titled Subject: mm/mmap: extract validate_mm() from vma_complete() has been added to the -mm mm-unstable branch. Its filename is mm-mmap-extract-validate_mm-from-vma_complete.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-mmap-extract-validate_mm-from-vma_complete.patch This patch will later appear in the mm-unstable branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via the mm-everything branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there every 2-3 working days ------------------------------------------------------ From: "Liam R. Howlett" <Liam.Howlett@xxxxxxxxxx> Subject: mm/mmap: extract validate_mm() from vma_complete() Date: Tue, 11 Jun 2024 14:01:59 -0400 vma_complete() will need to be called during an unsafe time to call validate_mm(). Extract the call in all places now so that only one location can be modified in the next change. Link: https://lkml.kernel.org/r/20240611180200.711239-8-Liam.Howlett@xxxxxxxxxx Signed-off-by: Liam R. Howlett <Liam.Howlett@xxxxxxxxxx> Cc: Lorenzo Stoakes <lstoakes@xxxxxxxxx> Cc: Suren Baghdasaryan <surenb@xxxxxxxxxx> Cc: Vlastimil Babka <vbabka@xxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/mmap.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) --- a/mm/mmap.c~mm-mmap-extract-validate_mm-from-vma_complete +++ a/mm/mmap.c @@ -646,7 +646,6 @@ again: } if (vp->insert && vp->file) uprobe_mmap(vp->insert); - validate_mm(mm); } /* @@ -734,6 +733,7 @@ int vma_expand(struct vma_iterator *vmi, vma_iter_store(vmi, vma); vma_complete(&vp, vmi, vma->vm_mm); + validate_mm(vma->vm_mm); return 0; nomem: @@ -775,6 +775,7 @@ int vma_shrink(struct vma_iterator *vmi, vma_iter_clear(vmi); vma_set_range(vma, start, end, pgoff); vma_complete(&vp, vmi, vma->vm_mm); + validate_mm(vma->vm_mm); return 0; } @@ -1103,6 +1104,7 @@ static struct vm_area_struct } vma_complete(&vp, vmi, mm); + validate_mm(mm); khugepaged_enter_vma(res, vm_flags); return res; @@ -2481,6 +2483,7 @@ static int __split_vma(struct vma_iterat /* vma_complete stores the new vma */ vma_complete(&vp, vmi, vma->vm_mm); + validate_mm(vma->vm_mm); /* Success. */ if (new_below) @@ -3349,6 +3352,7 @@ static int do_brk_flags(struct vma_itera vma_iter_store(vmi, vma); vma_complete(&vp, vmi, mm); + validate_mm(mm); khugepaged_enter_vma(vma, flags); goto out; } _ Patches currently in -mm which might be from Liam.Howlett@xxxxxxxxxx are mm-mmap-correctly-position-vma_iterator-in-__split_vma.patch mm-mmap-introduce-abort_munmap_vmas.patch mm-mmap-introduce-vmi_complete_munmap_vmas.patch mm-mmap-extract-the-gathering-of-vmas-from-do_vmi_align_munmap.patch mm-mmap-introduce-vma_munmap_struct-for-use-in-munmap-operations.patch mm-mmap-change-munmap-to-use-vma_munmap_struct-for-accounting-and-surrounding-vmas.patch mm-mmap-extract-validate_mm-from-vma_complete.patch mm-mmap-use-split-munmap-calls-for-map_fixed.patch