From: Liam Howlett Date: Tue, 25 Oct 2022 16:12:49 +0000 (+0000) Subject: mmap: fix remap_file_pages() regression X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=1db43d3f3733351849ddca4b573c037c7821bfd8;p=linux.git mmap: fix remap_file_pages() regression When using the VMA iterator, the final execution will set the variable 'next' to NULL which causes the function to fail out. Restore the break in the loop to exit the VMA iterator early without clearing NULL fixes the issue. Link: https://lore.kernel.org/lkml/29344.1666681759@jrobl/ Link: https://lkml.kernel.org/r/20221025161222.2634030-1-Liam.Howlett@oracle.com Fixes: 763ecb035029 (mm: remove the vma linked list) Signed-off-by: Liam R. Howlett Reported-by: "J. R. Okajima" Tested-by: "J. R. Okajima" Signed-off-by: Andrew Morton --- diff --git a/mm/mmap.c b/mm/mmap.c index e270057ed04eb..2def55555e05f 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -2852,6 +2852,9 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size, if (next->vm_flags != vma->vm_flags) goto out; + if (start + size <= next->vm_end) + break; + prev = next; }