Skip to content

Commit

Permalink
asm-generic headers: add arch-specific __strnlen_user calling in uacc…
Browse files Browse the repository at this point in the history
…ess.h

This patch changes the implementation of strnlen_user in include/asm-generic/uaccess.h.
Originally, it calls strlen() function directly, which may not correctly handle the access of
user space in most mmu-enabled architectures.
New __strnlen_user is added for using as an architecture specific function.

Signed-off-by: Guan Xuetao <[email protected]>
Reviewed-by: Arnd Bergmann <[email protected]>
  • Loading branch information
gxt committed Mar 17, 2011
1 parent 38f5bf8 commit 7f509a9
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions include/asm-generic/uaccess.h
Original file line number Diff line number Diff line change
Expand Up @@ -288,14 +288,16 @@ strncpy_from_user(char *dst, const char __user *src, long count)
*
* Return 0 on exception, a value greater than N if too long
*/
#ifndef strnlen_user
#ifndef __strnlen_user
#define __strnlen_user strnlen
#endif

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;
return __strnlen_user(src, n);
}
#endif

static inline long strlen_user(const char __user *src)
{
Expand Down

0 comments on commit 7f509a9

Please sign in to comment.