public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Martin J. Bligh" <Martin.Bligh@us.ibm.com>
To: Andrea Arcangeli <andrea@suse.de>,
	Marcelo Tosatti <marcelo@conectiva.com.br>,
	Linus Torvalds <torvalds@transmeta.com>
Cc: linux-kernel <linux-kernel@vger.kernel.org>
Subject: [PATCH] stop null ptr deference in __alloc_pages
Date: Fri, 08 Mar 2002 11:36:31 -0800	[thread overview]
Message-ID: <7730000.1015616191@flay> (raw)

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++);


             reply	other threads:[~2002-03-08 19:37 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-03-08 19:36 Martin J. Bligh [this message]
2002-03-08 20:14 ` [PATCH] stop null ptr deference in __alloc_pages 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7730000.1015616191@flay \
    --to=martin.bligh@us.ibm.com \
    --cc=andrea@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcelo@conectiva.com.br \
    --cc=torvalds@transmeta.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox