public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] stop null ptr deference in __alloc_pages
@ 2002-03-08 19:36 Martin J. Bligh
  2002-03-08 20:14 ` Samuel Ortiz
  0 siblings, 1 reply; 7+ messages in thread
From: Martin J. Bligh @ 2002-03-08 19:36 UTC (permalink / raw)
  To: Andrea Arcangeli, Marcelo Tosatti, Linus Torvalds; +Cc: linux-kernel

Summary: Avoid null ptr defererence in __alloc_pages
This exists in 2.4. and 2.5

Configuration: a NUMA (ia32) system which only has highmem 
on one or more nodes.

Action to create: Try to allocate ZONE_NORMAL memory 
from a node which only has highmem. What we should do
is fall back to another node, looking for ZONE_NORMAL
memory.

In looking at the specified zonelist, we panic because that zonelist
is NULL. The simple patch below avoids the null deference, and 
returns failure. alloc_pages will continue looking through the nodes
until it finds one with some ZONE_NORMAL memory. We actually
panic at the moment a few lines later when we do,
classzone->need_balance = 1; thus dereferencing the pointer.

--- linux-2.4.18-memalloc/mm/page_alloc.c.old	Fri Mar  8 18:21:41 2002
+++ linux-2.4.18-memalloc/mm/page_alloc.c	Fri Mar  8 18:23:27 2002
@@ -317,6 +317,8 @@
 
 	zone = zonelist->zones;
 	classzone = *zone;
+	if (classzone == NULL)
+		return NULL;
 	min = 1UL << order;
 	for (;;) {
 		zone_t *z = *(zone++);


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

end of thread, other threads:[~2002-03-08 22:43 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-03-08 19:36 [PATCH] stop null ptr deference in __alloc_pages Martin J. Bligh
2002-03-08 20:14 ` Samuel Ortiz
2002-03-08 20:49   ` Martin J. Bligh
2002-03-08 21:16     ` Martin J. Bligh
2002-03-08 21:37       ` Samuel Ortiz
2002-03-08 21:50         ` Martin J. Bligh
2002-03-08 22:40           ` Samuel Ortiz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox