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

On Wed, Feb 18, 2009 at 08:56:49PM +0800, Américo Wang wrote:
> 
> 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.

I assume you refer to __get_user_pages()...?

This function checks whether the address is in the gate area and only
iff so requests the VMA representing it.

If you really did see an oops that is worked-around by your patch,
then the in_gate_area()/get_gate_vma() in question are broken.

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

  Nacked-by: Johannes Weiner <hannes@cmpxchg.org>

> ---
> 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: Johannes Weiner <hannes@cmpxchg.org>
To: "Américo Wang" <xiyou.wangcong@gmail.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
	linux-mm@kvack.org, Andrew Morton <akpm@osdl.org>,
	Nick Piggin <nickpiggin@yahoo.com.au>
Subject: Re: [Patch] mm: fix null pointer dereference in vm_normal_page()
Date: Wed, 18 Feb 2009 18:23:37 +0100	[thread overview]
Message-ID: <20090218172337.GA1767@cmpxchg.org> (raw)
In-Reply-To: <20090218125649.GU7272@hack.private>

On Wed, Feb 18, 2009 at 08:56:49PM +0800, Americo Wang wrote:
> 
> 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.

I assume you refer to __get_user_pages()...?

This function checks whether the address is in the gate area and only
iff so requests the VMA representing it.

If you really did see an oops that is worked-around by your patch,
then the in_gate_area()/get_gate_vma() in question are broken.

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

  Nacked-by: Johannes Weiner <hannes@cmpxchg.org>

> ---
> 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 17:21 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-18 12:56 [Patch] mm: fix null pointer dereference in vm_normal_page() Américo Wang
2009-02-18 12:56 ` Américo Wang
2009-02-18 17:23 ` Johannes Weiner [this message]
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=20090218172337.GA1767@cmpxchg.org \
    --to=hannes@cmpxchg.org \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=nickpiggin@yahoo.com.au \
    --cc=xiyou.wangcong@gmail.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 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.