All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Prevent an oops in vmalloc_user()
@ 2006-11-09 22:00 Jonathan Corbet
  2006-11-09 22:29 ` Eric Dumazet
  0 siblings, 1 reply; 3+ messages in thread
From: Jonathan Corbet @ 2006-11-09 22:00 UTC (permalink / raw)
  To: linux-kernel; +Cc: akpm

Prevent an oops in vmalloc_user()

If an attempt to allocate memory with vmalloc_user() fails, the result
will be an oops when it tries to tweak the flags in the (non-existent)
VMA.  One could argue that __find_vm_area() should not return a random
pointer on failure, but vmalloc_user() requires a check regardless.

Signed-off-by: Jonathan Corbet <corbet@lwn.net>

--- 2.6.19-rc5/mm/vmalloc.c.orig	2006-11-09 13:51:38.000000000 -0700
+++ 2.6.19-rc5/mm/vmalloc.c	2006-11-09 13:52:10.000000000 -0700
@@ -532,10 +532,12 @@ void *vmalloc_user(unsigned long size)
 	void *ret;
 
 	ret = __vmalloc(size, GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, PAGE_KERNEL);
-	write_lock(&vmlist_lock);
-	area = __find_vm_area(ret);
-	area->flags |= VM_USERMAP;
-	write_unlock(&vmlist_lock);
+	if (ret) {
+		write_lock(&vmlist_lock);
+		area = __find_vm_area(ret);
+		area->flags |= VM_USERMAP;
+		write_unlock(&vmlist_lock);
+	}
 
 	return ret;
 }

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

* Re: [PATCH] Prevent an oops in vmalloc_user()
  2006-11-09 22:00 [PATCH] Prevent an oops in vmalloc_user() Jonathan Corbet
@ 2006-11-09 22:29 ` Eric Dumazet
  2006-11-09 22:41   ` Andrew Morton
  0 siblings, 1 reply; 3+ messages in thread
From: Eric Dumazet @ 2006-11-09 22:29 UTC (permalink / raw)
  To: Jonathan Corbet; +Cc: linux-kernel, akpm

Jonathan Corbet a écrit :
> Prevent an oops in vmalloc_user()
> 
> If an attempt to allocate memory with vmalloc_user() fails, the result
> will be an oops when it tries to tweak the flags in the (non-existent)
> VMA.  One could argue that __find_vm_area() should not return a random
> pointer on failure, but vmalloc_user() requires a check regardless.
> 

Yes, I already posted a patch for that, and other problem as well.

http://lkml.org/lkml/2006/10/23/86

Maybe it was lost...

Eric

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

* Re: [PATCH] Prevent an oops in vmalloc_user()
  2006-11-09 22:29 ` Eric Dumazet
@ 2006-11-09 22:41   ` Andrew Morton
  0 siblings, 0 replies; 3+ messages in thread
From: Andrew Morton @ 2006-11-09 22:41 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: Jonathan Corbet, linux-kernel

On Thu, 09 Nov 2006 23:29:34 +0100
Eric Dumazet <dada1@cosmosbay.com> wrote:

> Jonathan Corbet a __crit :
> > Prevent an oops in vmalloc_user()
> > 
> > If an attempt to allocate memory with vmalloc_user() fails, the result
> > will be an oops when it tries to tweak the flags in the (non-existent)
> > VMA.  One could argue that __find_vm_area() should not return a random
> > pointer on failure, but vmalloc_user() requires a check regardless.
> > 
> 
> Yes, I already posted a patch for that, and other problem as well.
> 
> http://lkml.org/lkml/2006/10/23/86
> 
> Maybe it was lost...
> 

It's in -mm but I'd queued it for 2.6.20 because you went and mixed a bunch
of things into the same patch.

Whatever - I'll push it for 2.6.19.

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

end of thread, other threads:[~2006-11-09 22:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-11-09 22:00 [PATCH] Prevent an oops in vmalloc_user() Jonathan Corbet
2006-11-09 22:29 ` Eric Dumazet
2006-11-09 22:41   ` Andrew Morton

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.