The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] asm-generic headers: add arch-specific __strnlen_user calling in uaccess.h
@ 2011-01-11  8:07 Guan Xuetao
  2011-01-11 15:49 ` Arnd Bergmann
  0 siblings, 1 reply; 2+ messages in thread
From: Guan Xuetao @ 2011-01-11  8:07 UTC (permalink / raw)
  To: Arnd Bergmann, linux-arch, linux-kernel

From: Guan Xuetao <guanxuetao@mprc.pku.edu.cn>

	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 <guanxuetao@mprc.pku.edu.cn>
---
 include/asm-generic/uaccess.h |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/include/asm-generic/uaccess.h b/include/asm-generic/uaccess.h
index b218b85..ac68c99 100644
--- a/include/asm-generic/uaccess.h
+++ b/include/asm-generic/uaccess.h
@@ -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)
 {



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-01-11 15:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-11  8:07 [PATCH] asm-generic headers: add arch-specific __strnlen_user calling in uaccess.h Guan Xuetao
2011-01-11 15:49 ` Arnd Bergmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox