The patch titled Subject: mm/mremap.c: mremap: fix unsigned compare against 0 issue has been added to the -mm tree. Its filename is mm-mremap-downgrade-mmap_sem-to-read-when-shrinking-fix-2.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/mm-mremap-downgrade-mmap_sem-to-read-when-shrinking-fix-2.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/mm-mremap-downgrade-mmap_sem-to-read-when-shrinking-fix-2.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/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Yang Shi <yang.shi@xxxxxxxxxxxxxxxxx> Subject: mm/mremap.c: mremap: fix unsigned compare against 0 issue Static analysis reported an unsigned compare against 0 issue Define an int temp variable to check the return value of __do_munmap(). Link: http://lkml.kernel.org/r/1538687672-17795-2-git-send-email-yang.shi@xxxxxxxxxxxxxxxxx Reported-by: Colin Ian King <colin.king@xxxxxxxxxxxxx> Signed-off-by: Yang Shi <yang.shi@xxxxxxxxxxxxxxxxx> Cc: Vlastimil Babka <vbabka@xxxxxxx> Cc: Kirill A. Shutemov <kirill.shutemov@xxxxxxxxxxxxxxx> Cc: Michal Hocko <mhocko@xxxxxxxxxx> Cc: Matthew Wilcox <willy@xxxxxxxxxxxxx> Cc: Laurent Dufour <ldufour@xxxxxxxxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/mremap.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) --- a/mm/mremap.c~mm-mremap-downgrade-mmap_sem-to-read-when-shrinking-fix-2 +++ a/mm/mremap.c @@ -566,12 +566,14 @@ SYSCALL_DEFINE5(mremap, unsigned long, a * downgrades mmap_sem to read if so directed. */ if (old_len >= new_len) { - ret = __do_munmap(mm, addr+new_len, old_len - new_len, + int retval; + retval = __do_munmap(mm, addr+new_len, old_len - new_len, &uf_unmap, true); - if (ret < 0 && old_len != new_len) + if (retval < 0 && old_len != new_len) { + ret = retval; goto out; /* Returning 1 indicates mmap_sem is downgraded to read. */ - else if (ret == 1) + } else if (retval == 1) downgraded = true; ret = addr; goto out; _ Patches currently in -mm which might be from yang.shi@xxxxxxxxxxxxxxxxx are mm-mmap-zap-pages-with-read-mmap_sem-in-munmap.patch mm-unmap-vm_hugetlb-mappings-with-optimized-path.patch mm-unmap-vm_pfnmap-mappings-with-optimized-path.patch mm-mremap-downgrade-mmap_sem-to-read-when-shrinking.patch mm-mremap-downgrade-mmap_sem-to-read-when-shrinking-fix-2.patch mm-brk-downgrade-mmap_sem-to-read-when-shrinking.patch mm-brk-downgrade-mmap_sem-to-read-when-shrinking-fix-2.patch mm-dax-add-comment-for-pfn_special.patch