All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Américo Wang" <xiyou.wangcong@gmail.com>
To: LKML <linux-kernel@vger.kernel.org>
Cc: linux-mm@kvack.org, Andrew Morton <akpm@osdl.org>,
	Nick Piggin <nickpiggin@yahoo.com.au>
Subject: [Patch] mm: fix null pointer dereference in vm_normal_page()
Date: Wed, 18 Feb 2009 20:56:49 +0800	[thread overview]
Message-ID: <20090218125649.GU7272@hack.private> (raw)


One usage of vm_normal_page() is:

    struct page *page = vm_normal_page(gate_vma, start, *pte);

where gate_vma is returned by get_gate_vma() which can be NULL.
So let vm_normal_page return NULL when vma is NULL.

Signed-off-by: WANG Cong <wangcong@zeuux.org>
Cc: Nick Piggin <nickpiggin@yahoo.com.au>

---
diff --git a/mm/memory.c b/mm/memory.c
index baa999e..e428aa6 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -493,6 +493,9 @@ struct page *vm_normal_page(struct vm_area_struct *vma, unsigned long addr,
 {
 	unsigned long pfn = pte_pfn(pte);
 
+	if (!vma)
+		return NULL;
+
 	if (HAVE_PTE_SPECIAL) {
 		if (likely(!pte_special(pte)))
 			goto check_pfn;



WARNING: multiple messages have this Message-ID (diff)
From: "Américo Wang" <xiyou.wangcong@gmail.com>
To: LKML <linux-kernel@vger.kernel.org>
Cc: linux-mm@kvack.org, Andrew Morton <akpm@osdl.org>,
	Nick Piggin <nickpiggin@yahoo.com.au>
Subject: [Patch] mm: fix null pointer dereference in vm_normal_page()
Date: Wed, 18 Feb 2009 20:56:49 +0800	[thread overview]
Message-ID: <20090218125649.GU7272@hack.private> (raw)


One usage of vm_normal_page() is:

    struct page *page = vm_normal_page(gate_vma, start, *pte);

where gate_vma is returned by get_gate_vma() which can be NULL.
So let vm_normal_page return NULL when vma is NULL.

Signed-off-by: WANG Cong <wangcong@zeuux.org>
Cc: Nick Piggin <nickpiggin@yahoo.com.au>

---
diff --git a/mm/memory.c b/mm/memory.c
index baa999e..e428aa6 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -493,6 +493,9 @@ struct page *vm_normal_page(struct vm_area_struct *vma, unsigned long addr,
 {
 	unsigned long pfn = pte_pfn(pte);
 
+	if (!vma)
+		return NULL;
+
 	if (HAVE_PTE_SPECIAL) {
 		if (likely(!pte_special(pte)))
 			goto check_pfn;


--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

             reply	other threads:[~2009-02-18 12:56 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-18 12:56 Américo Wang [this message]
2009-02-18 12:56 ` [Patch] mm: fix null pointer dereference in vm_normal_page() Américo Wang
2009-02-18 17:23 ` Johannes Weiner
2009-02-18 17:23   ` Johannes Weiner

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=20090218125649.GU7272@hack.private \
    --to=xiyou.wangcong@gmail.com \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=nickpiggin@yahoo.com.au \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.