lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <1538687672-17795-2-git-send-email-yang.shi@linux.alibaba.com>
Date:   Fri,  5 Oct 2018 05:14:32 +0800
From:   Yang Shi <yang.shi@...ux.alibaba.com>
To:     vbabka@...e.cz, kirill.shutemov@...ux.intel.com, mhocko@...nel.org,
        willy@...radead.org, ldufour@...ux.vnet.ibm.com,
        colin.king@...onical.com, akpm@...ux-foundation.org
Cc:     yang.shi@...ux.alibaba.com, linux-mm@...ck.org,
        linux-kernel@...r.kernel.org
Subject: [PATCH 2/2 -mm] mm: mremap: fix unsigned compare against 0 issue

Static analysis reported unsigned compare against 0 issue according to
Colin Ian King.

Defined an int temp variable to check the return value of __do_munmap().

Reported-by: Colin Ian King <colin.king@...onical.com>
Cc: Vlastimil Babka <vbabka@...e.cz>
Cc: Kirill A. Shutemov <kirill.shutemov@...ux.intel.com>
Cc: Michal Hocko <mhocko@...nel.org>
Cc: Matthew Wilcox <willy@...radead.org>
Cc: Laurent Dufour <ldufour@...ux.vnet.ibm.com>
Cc: Andrew Morton <akpm@...ux-foundation.org>
Signed-off-by: Yang Shi <yang.shi@...ux.alibaba.com>
---
Andrew, this should be able to be folded into the original patch.

 mm/mremap.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/mm/mremap.c b/mm/mremap.c
index 3524d16..f9d5d1f 100644
--- a/mm/mremap.c
+++ b/mm/mremap.c
@@ -566,12 +566,14 @@ static int vma_expandable(struct vm_area_struct *vma, unsigned long delta)
 	 * downgrade mmap_sem to read.
 	 */
 	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;
-- 
1.8.3.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ