[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1331617001-20906-2-git-send-email-apenwarr@gmail.com>
Date: Tue, 13 Mar 2012 01:36:37 -0400
From: Avery Pennarun <apenwarr@...il.com>
To: Andrew Morton <akpm@...ux-foundation.org>,
Josh Triplett <josh@...htriplett.org>,
"Paul E. McKenney" <paulmck@...ux.vnet.ibm.com>,
Ingo Molnar <mingo@...e.hu>,
"David S. Miller" <davem@...emloft.net>,
Peter Zijlstra <a.p.zijlstra@...llo.nl>,
"Fabio M. Di Nitto" <fdinitto@...hat.com>,
Avery Pennarun <apenwarr@...il.com>,
Johannes Weiner <hannes@...xchg.org>,
Olaf Hering <olaf@...fle.de>,
Paul Gortmaker <paul.gortmaker@...driver.com>,
Tejun Heo <tj@...nel.org>,
"H. Peter Anvin" <hpa@...ux.intel.com>,
Yinghai LU <yinghai@...nel.org>, linux-kernel@...r.kernel.org,
linux-mm@...ck.org
Subject: [PATCH 1/5] mm: bootmem: BUG() if you try to allocate bootmem too late.
If you try to allocate or reserve bootmem after the bootmem subsystem has
already been shut down and replaced with the real VM system, it would
succeed, but then your memory would silently get freed and could be
reallocated by the normal VM.
Add a few lines of code to catch this condition immediately rather than
manifesting as memory corruption.
Signed-off-by: Avery Pennarun <apenwarr@...il.com>
---
mm/bootmem.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/mm/bootmem.c b/mm/bootmem.c
index 668e94d..7a9f505 100644
--- a/mm/bootmem.c
+++ b/mm/bootmem.c
@@ -39,6 +39,7 @@ bootmem_data_t bootmem_node_data[MAX_NUMNODES] __initdata;
static struct list_head bdata_list __initdata = LIST_HEAD_INIT(bdata_list);
static int bootmem_debug;
+static int bootmem_stopped;
static int __init bootmem_debug_setup(char *buf)
{
@@ -182,6 +183,7 @@ static unsigned long __init free_all_bootmem_core(bootmem_data_t *bdata)
bdebug("nid=%td start=%lx end=%lx\n",
bdata - bootmem_node_data, start, end);
+ bootmem_stopped = 1;
while (start < end) {
unsigned long *map, idx, vec;
@@ -279,6 +281,7 @@ static int __init __reserve(bootmem_data_t *bdata, unsigned long sidx,
unsigned long idx;
int exclusive = flags & BOOTMEM_EXCLUSIVE;
+ BUG_ON(bootmem_stopped);
bdebug("nid=%td start=%lx end=%lx flags=%x\n",
bdata - bootmem_node_data,
sidx + bdata->node_min_pfn,
--
1.7.7.3
--
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