summaryrefslogtreecommitdiffstats
path: root/include/asm-generic/uaccess.h
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2009-06-14 08:00:02 +0200
committerArnd Bergmann <arnd@arndb.de>2009-06-19 14:58:07 +0200
commit9844813f226f6d07e1544e915529cb88f4fcb868 (patch)
treecdf051b38220c6d99a6f4aac372d7b95eda26c6a /include/asm-generic/uaccess.h
parentMerge branch 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tyt... (diff)
downloadlinux-9844813f226f6d07e1544e915529cb88f4fcb868.tar.xz
linux-9844813f226f6d07e1544e915529cb88f4fcb868.zip
asm-generic: uaccess: add missing access_ok() check to strnlen_user()
The strnlen_user() function was missing a access_ok() check on the pointer given. We've had cases on Blackfin systems where test programs caused kernel crashes here because userspace passed up a NULL/-1 pointer and the kernel gladly attempted to run strlen() on it. Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Diffstat (limited to 'include/asm-generic/uaccess.h')
-rw-r--r--include/asm-generic/uaccess.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/include/asm-generic/uaccess.h b/include/asm-generic/uaccess.h
index 6d8cab22e294..5dd511b62ce9 100644
--- a/include/asm-generic/uaccess.h
+++ b/include/asm-generic/uaccess.h
@@ -291,6 +291,8 @@ strncpy_from_user(char *dst, const char __user *src, long count)
#ifndef strnlen_user
static inline long strnlen_user(const char __user *src, long n)
{
+ if (!access_ok(VERIFY_READ, src, 1))
+ return 0;
return strlen((void * __force)src) + 1;
}
#endif