All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Corbet <corbet@lwn.net>
To: linux-kernel@vger.kernel.org
Cc: akpm@osdl.org
Subject: [PATCH] Prevent an oops in vmalloc_user()
Date: Thu, 09 Nov 2006 15:00:19 -0700	[thread overview]
Message-ID: <31360.1163109619@lwn.net> (raw)

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;
 }

             reply	other threads:[~2006-11-09 22:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-11-09 22:00 Jonathan Corbet [this message]
2006-11-09 22:29 ` [PATCH] Prevent an oops in vmalloc_user() Eric Dumazet
2006-11-09 22:41   ` Andrew Morton

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=31360.1163109619@lwn.net \
    --to=corbet@lwn.net \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    /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.