public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: Mike Frysinger <vapier@gentoo.org>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] asm-generic: uaccess: fix up local access_ok() usage
Date: Sat, 13 Jun 2009 22:53:39 +0200	[thread overview]
Message-ID: <200906132253.39879.arnd@arndb.de> (raw)
In-Reply-To: <1244903447-23579-1-git-send-email-vapier@gentoo.org>

On Saturday 13 June 2009, Mike Frysinger wrote:
> There's no reason that I can see to use the short __access_ok() form
> directly when the access_ok() is clearer in intent and for more people,
> expands to the same C code (i.e. always specify the first field -- access
> type).  Not all no-mmu systems lack memory protection, so the read/write
> could feasibly be checked.

Ah, I didn't consider this. I checked all the architectures and could not
find a case where access_ok actually evaluates the the first argument, so
I chose the slightly terser variant. I also don't let you override
access_ok() at this moment, which means that you don't have a choice
to use the generic uaccess.h and still differentiate between read and
write accesses.

What I really got wrong was the prototype for __access_ok(), as you
showed in your follow-up. I only tested this with the microblaze
patch that overrides __access_ok() with an architecture specific
version that gets this part right.

Would this simpler patch help you as well?

--- a/include/asm-generic/uaccess.h
+++ b/include/asm-generic/uaccess.h
@@ -37,14 +37,14 @@ static inline void set_fs(mm_segment_t fs)
 #define VERIFY_READ	0
 #define VERIFY_WRITE	1
 
-#define access_ok(type, addr, size) __access_ok((unsigned long)(addr),(size))
+#define access_ok(type, addr, size) __access_ok((addr), (size))
 
 /*
  * The architecture should really override this if possible, at least
  * doing a check on the get_fs()
  */
 #ifndef __access_ok
-static inline int __access_ok(unsigned long addr, unsigned long size)
+static inline int __access_ok(void __user *ptr, unsigned long size)
 {
 	return 1;
 }

It may not be clearer in intent, but it's what the majority (by a small
margin) of architecture do anyway.

> Also, the strnlen_user() function was missing a access_ok() check on the
> pointer given.  We've had cases on Blackfin systems where test cases
> caused kernel crashes here because userspace passed up a NULL/-1 pointer
> and the kernel gladly attempted to run strlen() on it.

Right, well spotted. I'll take this fix as a separate patch, ok?

	Arnd <><

  parent reply	other threads:[~2009-06-13 20:53 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-13 14:30 [PATCH] asm-generic: uaccess: fix up local access_ok() usage Mike Frysinger
2009-06-13 14:30 ` [PATCH] asm-generic: hard_irqs: handle NR_IRQS > 256 automatically Mike Frysinger
2009-06-13 17:57   ` H. Peter Anvin
2009-06-13 21:18     ` Arnd Bergmann
2009-06-14  0:25       ` Mike Frysinger
2009-06-14 20:43         ` [PATCH] asm-generic: drop HARDIRQ_BITS definition from hardirq.h Arnd Bergmann
2009-06-15 15:59           ` Steven Rostedt
2009-06-15 16:17           ` Mike Frysinger
2009-06-15 16:44           ` Steven Rostedt
2009-06-16 14:37             ` [PATCH v3] " Arnd Bergmann
2009-06-13 15:59 ` [PATCH] asm-generic: uaccess: fix up local access_ok() usage Mike Frysinger
2009-06-13 20:53 ` Arnd Bergmann [this message]
2009-06-14  0:47   ` Mike Frysinger
2009-06-14 10:10     ` Arnd Bergmann
2009-06-14 10:17       ` Mike Frysinger
2009-06-14 10:24         ` Arnd Bergmann

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=200906132253.39879.arnd@arndb.de \
    --to=arnd@arndb.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=vapier@gentoo.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox