Commit 7f509a9ef7af0d6ac852d49eb87ed2b9857821cc
1 parent
38f5bf84bd
Exists in
master
and in
7 other branches
asm-generic headers: add arch-specific __strnlen_user calling in uaccess.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 <gxt@mprc.pku.edu.cn> Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Showing 1 changed file with 5 additions and 3 deletions Side-by-side Diff
include/asm-generic/uaccess.h
... | ... | @@ -288,14 +288,16 @@ |
288 | 288 | * |
289 | 289 | * Return 0 on exception, a value greater than N if too long |
290 | 290 | */ |
291 | -#ifndef strnlen_user | |
291 | +#ifndef __strnlen_user | |
292 | +#define __strnlen_user strnlen | |
293 | +#endif | |
294 | + | |
292 | 295 | static inline long strnlen_user(const char __user *src, long n) |
293 | 296 | { |
294 | 297 | if (!access_ok(VERIFY_READ, src, 1)) |
295 | 298 | return 0; |
296 | - return strlen((void * __force)src) + 1; | |
299 | + return __strnlen_user(src, n); | |
297 | 300 | } |
298 | -#endif | |
299 | 301 | |
300 | 302 | static inline long strlen_user(const char __user *src) |
301 | 303 | { |