Skip to content

Commit

Permalink
asm-generic: uaccess: add missing access_ok() check to strnlen_user()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Mike Frysinger authored and Arnd Bergmann committed Jun 19, 2009
1 parent 0732f87 commit 9844813
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/asm-generic/uaccess.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9844813

Please sign in to comment.