The patch titled Subject: mm/mremap: fix vma iterator initialization has been added to the -mm mm-unstable branch. Its filename is mm-change-munmap-splitting-order-and-move_vma-fix.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-change-munmap-splitting-order-and-move_vma-fix.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/mremap: fix vma iterator initialization Date: Thu, 26 Jan 2023 16:20:11 -0500 The vma iterator location is incorrect when there is a failure in the move_vma() function which alters the address being modified. Delay the initialization of the vma iterator until the address is stable. Link: https://lkml.kernel.org/r/20230126212011.980350-1-Liam.Howlett@xxxxxxxxxx Signed-off-by: Liam R. Howlett <Liam.Howlett@xxxxxxxxxx> Reported-by: Sanan Hasanov <sanan.hasanov@xxxxxxxxxxxxxxx> Link: https://lore.kernel.org/linux-mm/IA1PR07MB98306BC0F55667A760EABE91ABCE9@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/ Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/mremap.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/mm/mremap.c~mm-change-munmap-splitting-order-and-move_vma-fix +++ a/mm/mremap.c @@ -585,7 +585,7 @@ static unsigned long move_vma(struct vm_ unsigned long hiwater_vm; int err = 0; bool need_rmap_locks; - VMA_ITERATOR(vmi, mm, old_addr); + struct vma_iterator vmi; /* * We'd prefer to avoid failure later on in do_munmap: @@ -701,6 +701,7 @@ static unsigned long move_vma(struct vm_ return new_addr; } + vma_iter_init(&vmi, mm, old_addr); if (do_vmi_munmap(&vmi, mm, old_addr, old_len, uf_unmap, false) < 0) { /* OOM: unable to split vma, just get accounts right */ if (vm_flags & VM_ACCOUNT && !(flags & MREMAP_DONTUNMAP)) _ Patches currently in -mm which might be from Liam.Howlett@xxxxxxxxxx are maple_tree-fix-handle-of-invalidated-state-in-mas_wr_store_setup.patch maple_tree-fix-mas_prev-and-mas_find-state-handling.patch nommu-pass-through-vma-iterator-to-shrink_vma.patch mm-damon-vaddr-testh-stop-using-vma_mas_store-for-maple-tree-store.patch madvise-use-split_vma-instead-of-__split_vma-fix.patch mm-change-munmap-splitting-order-and-move_vma-fix.patch mm-mremap-convert-vma_adjust-to-vma_expand.patch ipc-shm-introduce-new-do_vma_munmap-to-munmap.patch