The patch titled Subject: mremap: simplify the "overlap" check in mremap_to() has been added to the -mm tree. Its filename is mremap-simplify-the-overlap-check-in-mremap_to.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/mremap-simplify-the-overlap-check-in-mremap_to.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/mremap-simplify-the-overlap-check-in-mremap_to.patch 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/SubmitChecklist when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Oleg Nesterov <oleg@xxxxxxxxxx> Subject: mremap: simplify the "overlap" check in mremap_to() Minor, but this check is overcomplicated. Two half-intervals do NOT overlap if END1 <= START2 || END2 <= START1, mremap_to() just needs to negate this check. Signed-off-by: Oleg Nesterov <oleg@xxxxxxxxxx> Acked-by: David Rientjes <rientjes@xxxxxxxxxx> Cc: Benjamin LaHaise <bcrl@xxxxxxxxx> Cc: Hugh Dickins <hughd@xxxxxxxxxx> Cc: Jeff Moyer <jmoyer@xxxxxxxxxx> Cc: Kirill A. Shutemov <kirill.shutemov@xxxxxxxxxxxxxxx> Cc: Laurent Dufour <ldufour@xxxxxxxxxxxxxxxxxx> Cc: Pavel Emelyanov <xemul@xxxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/mremap.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff -puN mm/mremap.c~mremap-simplify-the-overlap-check-in-mremap_to mm/mremap.c --- a/mm/mremap.c~mremap-simplify-the-overlap-check-in-mremap_to +++ a/mm/mremap.c @@ -407,13 +407,8 @@ static unsigned long mremap_to(unsigned if (new_len > TASK_SIZE || new_addr > TASK_SIZE - new_len) goto out; - /* Check if the location we're moving into overlaps the - * old location at all, and fail if it does. - */ - if ((new_addr <= addr) && (new_addr+new_len) > addr) - goto out; - - if ((addr <= new_addr) && (addr+old_len) > new_addr) + /* Ensure the old/new locations do not overlap */ + if (addr + old_len > new_addr && new_addr + new_len > addr) goto out; ret = do_munmap(mm, new_addr, new_len); _ Patches currently in -mm which might be from oleg@xxxxxxxxxx are mremap-dont-leak-new_vma-if-f_op-mremap-fails.patch mm-move-mremap-from-file_operations-to-vm_operations_struct.patch mremap-dont-do-mm_populatenew_addr-on-failure.patch mremap-dont-do-uneccesary-checks-if-new_len-==-old_len.patch mremap-simplify-the-overlap-check-in-mremap_to.patch kmod-bunch-of-internal-functions-renames.patch kmod-add-up-to-date-explanations-on-the-purpose-of-each-asynchronous-levels.patch kmod-remove-unecessary-explicit-wide-cpu-affinity-setting.patch linux-next.patch -- To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html