linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [Patch] mm: fix null pointer dereference in vm_normal_page()
@ 2009-02-18 12:56 Américo Wang
  2009-02-18 17:23 ` Johannes Weiner
  0 siblings, 1 reply; 2+ messages in thread
From: Américo Wang @ 2009-02-18 12:56 UTC (permalink / raw)
  To: LKML; +Cc: linux-mm, Andrew Morton, Nick Piggin


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>

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

* Re: [Patch] mm: fix null pointer dereference in vm_normal_page()
  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
  0 siblings, 0 replies; 2+ messages in thread
From: Johannes Weiner @ 2009-02-18 17:23 UTC (permalink / raw)
  To: Américo Wang; +Cc: LKML, linux-mm, Andrew Morton, Nick Piggin

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>

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

end of thread, other threads:[~2009-02-18 17:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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

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