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: <1331617001-20906-3-git-send-email-apenwarr@gmail.com>
Date:	Tue, 13 Mar 2012 01:36:38 -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 2/5] mm: bootmem: it's okay to reserve_bootmem an invalid address.

...but only if you provide BOOTMEM_EXCLUSIVE, which should guarantee that
you're actually checking the return value.  In that case, just return an
error code if the memory you tried to get is invalid.  This lets callers
safely probe around for a valid memory range.

If you don't use BOOTMEM_EXCLUSIVE and the memory address is invalid, just
crash as before, since the caller is probably not bothering to check the
return value.

Signed-off-by: Avery Pennarun <apenwarr@...il.com>
---
 mm/bootmem.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/mm/bootmem.c b/mm/bootmem.c
index 7a9f505..d397dae 100644
--- a/mm/bootmem.c
+++ b/mm/bootmem.c
@@ -351,7 +351,10 @@ static int __init mark_bootmem(unsigned long start, unsigned long end,
 			return 0;
 		pos = bdata->node_low_pfn;
 	}
-	BUG();
+	/* people who don't use BOOTMEM_EXCLUSIVE don't check the return
+	 * value, so BUG() if it goes wrong. */
+	BUG_ON(!(reserve && (flags & BOOTMEM_EXCLUSIVE));
+	return -ENOENT;
 }
 
 /**
@@ -421,7 +424,7 @@ int __init reserve_bootmem_node(pg_data_t *pgdat, unsigned long physaddr,
 }
 
 /**
- * reserve_bootmem - mark a page range as usable
+ * reserve_bootmem - mark a page range as reserved
  * @addr: starting address of the range
  * @size: size of the range in bytes
  * @flags: reservation flags (see linux/bootmem.h)
-- 
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

Powered by Openwall GNU/*/Linux Powered by OpenVZ