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] [thread-next>] [day] [month] [year] [list]
Message-Id: <d1a1b6416d71a5062fb3b3e364f9db6b6d4ef6b2.1311258580.git.luto@mit.edu>
Date:	Thu, 21 Jul 2011 10:33:14 -0400
From:	Andy Lutomirski <luto@....EDU>
To:	mingo@...hat.com, wzt <wzt.wzt@...il.com>
Cc:	linux-kernel@...r.kernel.org, x86@...nel.org, ak@...ux.intel.com,
	tglx@...utronix.de, hpa@...or.com, Michal Hocko <mhocko@...e.cz>,
	Zhitong Wang <zhitong.wangzt@...baba-inc.com>,
	Andy Lutomirski <luto@....edu>
Subject: [PATCH] x86: Fix memory leak of init_vdso_vars()

From: Zhitong Wang <wzt.wzt@...il.com>

If init_vdso_vars ran out of memory (not very likely), then it would
leak a few pages as well.

Also rename init_vdso_vars to just init_vdso, since initializing
vvars is just about the only thing this function doesn't do.

Signed-off-by: Zhitong Wang <zhitong.wangzt@...baba-inc.com>
[Rebased and slightly simplified from the original.]
Signed-off-by: Andy Lutomirski <luto@....edu>
---
 arch/x86/vdso/vma.c |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/arch/x86/vdso/vma.c b/arch/x86/vdso/vma.c
index c39938d..cabaf0e 100644
--- a/arch/x86/vdso/vma.c
+++ b/arch/x86/vdso/vma.c
@@ -54,7 +54,7 @@ found:
 	apply_alternatives(alt_data, alt_data + alt_sec->sh_size);
 }
 
-static int __init init_vdso_vars(void)
+static int __init init_vdso(void)
 {
 	int npages = (vdso_end - vdso_start + PAGE_SIZE - 1) / PAGE_SIZE;
 	int i;
@@ -69,19 +69,24 @@ static int __init init_vdso_vars(void)
 		struct page *p;
 		p = alloc_page(GFP_KERNEL);
 		if (!p)
-			goto oom;
+			goto oom_free;
 		vdso_pages[i] = p;
 		copy_page(page_address(p), vdso_start + i*PAGE_SIZE);
 	}
 
 	return 0;
 
- oom:
+oom_free:
+	for(i--; i >= 0; i--)
+		__free_page(vdso_pages[i]);
+	__free_page(vdso_pages);
+
+oom:
 	printk("Cannot allocate vdso\n");
 	vdso_enabled = 0;
 	return -ENOMEM;
 }
-subsys_initcall(init_vdso_vars);
+subsys_initcall(init_vdso);
 
 struct linux_binprm;
 
-- 
1.7.6

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