linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] powerpc: Perform a bounds check in arch_add_memory
@ 2019-08-27  5:20 Alastair D'Silva
  2019-08-27  6:28 ` Michal Hocko
  0 siblings, 1 reply; 9+ messages in thread
From: Alastair D'Silva @ 2019-08-27  5:20 UTC (permalink / raw)
  To: alastair
  Cc: Michal Hocko, David Hildenbrand, linux-kernel, Mike Rapoport,
	Paul Mackerras, Aneesh Kumar K.V, Andrew Morton, linuxppc-dev

From: Alastair D'Silva <alastair@d-silva.org>

It is possible for firmware to allocate memory ranges outside
the range of physical memory that we support (MAX_PHYSMEM_BITS).

This patch adds a bounds check to ensure that any hotplugged
memory is addressable.

Signed-off-by: Alastair D'Silva <alastair@d-silva.org>
---
 arch/powerpc/mm/mem.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c
index 9191a66b3bc5..de18fb73de30 100644
--- a/arch/powerpc/mm/mem.c
+++ b/arch/powerpc/mm/mem.c
@@ -111,6 +111,9 @@ int __ref arch_add_memory(int nid, u64 start, u64 size,
 	unsigned long nr_pages = size >> PAGE_SHIFT;
 	int rc;
 
+	if ((start + size - 1) >> MAX_PHYSMEM_BITS)
+		return -EINVAL;
+
 	resize_hpt_for_hotplug(memblock_phys_mem_size());
 
 	start = (unsigned long)__va(start);
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2019-09-05  7:55 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-08-27  5:20 [PATCH] powerpc: Perform a bounds check in arch_add_memory Alastair D'Silva
2019-08-27  6:28 ` Michal Hocko
2019-08-27  6:39   ` Alastair D'Silva
2019-08-27  7:13     ` David Hildenbrand
2019-09-01 23:54       ` Alastair D'Silva
2019-09-02  7:28         ` David Hildenbrand
2019-09-04  5:25           ` Alastair D'Silva
2019-09-05  7:52             ` David Hildenbrand
2019-08-27  7:18     ` Michal Hocko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).