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-next>] [day] [month] [year] [list]
Message-ID: <alpine.LNX.2.00.1012192305260.6486@swampdragon.chaosbits.net>
Date:	Sun, 19 Dec 2010 23:10:20 +0100 (CET)
From:	Jesper Juhl <jj@...osbits.net>
To:	linux-mm@...ck.org
cc:	linux-kernel@...r.kernel.org,
	Andrew Morton <akpm@...ux-foundation.org>
Subject: [PATCH] Close mem leak in error path in
 mm/hugetlb.c::nr_hugepages_store_common()

Hi,

The NODEMASK_ALLOC macro dynamically allocates memory for its second 
argument ('nodes_allowed' in this context).
In nr_hugepages_store_common() we may abort early if strict_strtoul() 
fails, but in that case we do not free the memory already allocated to 
'nodes_allowed', causing a memory leak.
This patch closes the leak by freeing the memory in the error path.


Signed-off-by: Jesper Juhl <jj@...osbits.net>
---
 hugetlb.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

  compile tested only

diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 8585524..9fdcc35 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -1439,8 +1439,10 @@ static ssize_t nr_hugepages_store_common(bool obey_mempolicy,
 	NODEMASK_ALLOC(nodemask_t, nodes_allowed, GFP_KERNEL | __GFP_NORETRY);
 
 	err = strict_strtoul(buf, 10, &count);
-	if (err)
+	if (err) {
+		kfree(nodes_allowed);
 		return 0;
+	}
 
 	h = kobj_to_hstate(kobj, &nid);
 	if (nid == NUMA_NO_NODE) {



-- 
Jesper Juhl <jj@...osbits.net>            http://www.chaosbits.net/
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ