From: Mike Frysinger <vapier@gentoo.org>
To: Arnd Bergmann <arnd@arndb.de>
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH 3/4] asm-generic: uaccess: fix up local access_ok() usage
Date: Sun, 14 Jun 2009 02:00:03 -0400 [thread overview]
Message-ID: <1244959204-11269-3-git-send-email-vapier@gentoo.org> (raw)
In-Reply-To: <1244959204-11269-1-git-send-email-vapier@gentoo.org>
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 most 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.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
---
include/asm-generic/uaccess.h | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/include/asm-generic/uaccess.h b/include/asm-generic/uaccess.h
index d299557..d3a9519 100644
--- a/include/asm-generic/uaccess.h
+++ b/include/asm-generic/uaccess.h
@@ -166,7 +166,7 @@ static inline __must_check long __copy_to_user(void __user *to,
__typeof__(*(ptr)) _x = (x); \
__typeof__(*(ptr)) *_p = (ptr); \
might_sleep(); \
- __access_ok(_p, sizeof(*_p)) ? \
+ access_ok(VERIFY_WRITE, _p, sizeof(*_p)) ? \
__put_user(_x, _p) : \
-EFAULT; \
})
@@ -224,7 +224,7 @@ extern int __put_user_bad(void) __attribute__((noreturn));
({ \
__typeof__(*(ptr)) *_p = (ptr); \
might_sleep(); \
- __access_ok(_p, sizeof(*_p)) ? \
+ access_ok(VERIFY_READ, _p, sizeof(*_p)) ? \
__get_user(x, _p) : \
-EFAULT; \
})
@@ -249,7 +249,7 @@ static inline long copy_from_user(void *to,
const void __user * from, unsigned long n)
{
might_sleep();
- if (__access_ok(from, n))
+ if (access_ok(VERIFY_READ, from, n))
return __copy_from_user(to, from, n);
else
return n;
@@ -259,7 +259,7 @@ static inline long copy_to_user(void __user *to,
const void *from, unsigned long n)
{
might_sleep();
- if (__access_ok(to, n))
+ if (access_ok(VERIFY_WRITE, to, n))
return __copy_to_user(to, from, n);
else
return n;
@@ -283,7 +283,7 @@ __strncpy_from_user(char *dst, const char __user *src, long count)
static inline long
strncpy_from_user(char *dst, const char __user *src, long count)
{
- if (!__access_ok(src, 1))
+ if (!access_ok(VERIFY_READ, src, 1))
return -EFAULT;
return __strncpy_from_user(dst, src, count);
}
@@ -323,7 +323,7 @@ static inline __must_check unsigned long
clear_user(void __user *to, unsigned long n)
{
might_sleep();
- if (!__access_ok(to, n))
+ if (!access_ok(VERIFY_WRITE, to, n))
return n;
return __clear_user(to, n);
--
1.6.3.1
next prev parent reply other threads:[~2009-06-14 6:00 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-14 6:00 [PATCH 1/4] asm-generic: uaccess: do not expand args multiple times Mike Frysinger
2009-06-14 6:00 ` [PATCH 2/4] asm-generic: uaccess: add missing access_ok() check to strnlen_user() Mike Frysinger
2009-06-14 20:35 ` Arnd Bergmann
2009-06-14 6:00 ` Mike Frysinger [this message]
2009-06-14 20:35 ` [PATCH 3/4] asm-generic: uaccess: fix up local access_ok() usage Arnd Bergmann
2009-06-14 6:00 ` [PATCH 4/4] asm-generic: uaccess: fix access_ok() prototype Mike Frysinger
2009-06-14 20:17 ` Arnd Bergmann
2009-06-16 10:34 ` Mike Frysinger
2009-06-14 20:14 ` [PATCH 1/4] asm-generic: uaccess: do not expand args multiple times Arnd Bergmann
2009-06-24 4:38 ` Al Viro
2009-06-24 11:35 ` Mike Frysinger
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=1244959204-11269-3-git-send-email-vapier@gentoo.org \
--to=vapier@gentoo.org \
--cc=arnd@arndb.de \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®