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>] [day] [month] [year] [list]
Date:	Wed, 09 Nov 2011 19:37:30 +0800
From:	Wang Sheng-Hui <shhuiw@...il.com>
To:	yinghai@...nel.org, linux-mm@...ck.org,
	linux-kernel@...r.kernel.org
Subject: [PATCH 3/3] mm/memblock.c: eliminate potential memleak in memblock_double_array

In memblock_double_array, we don't deal with old_array if we use
slab for new_array. So the memory used by old_array may be lost.
Add logic to try to free old_array when using slab for new_array.

Signed-off-by: Wang Sheng-Hui <shhuiw@...il.com>
---
 mm/memblock.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/mm/memblock.c b/mm/memblock.c
index 09ff05b..0e4248f 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -250,13 +250,17 @@ static int __init_memblock memblock_double_array(struct memblock_type *type)
 	type->regions = new_array;
 	type->max <<= 1;
 
-	/* If we use SLAB that's it, we are done */
-	if (use_slab)
+	if (use_slab) {
+		if (memblock_is_region_reserved(__pa(old_array), old_size))
+			goto old_memblock;
+		kfree(old_array);
 		return 0;
+	}
 
 	/* Add the new reserved region now. Should not fail ! */
 	BUG_ON(memblock_add_region(&memblock.reserved, addr, new_size));
 
+old_memblock:
 	/* If the array wasn't our static init one, then free it. We only do
 	 * that before SLAB is available as later on, we don't know whether
 	 * to use kfree or free_bootmem_pages(). Shouldn't be a big deal
-- 
1.7.1

--
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