sparc: Add full proper error handling to strncpy_from_user().
David Miller
maintainerPATCH 1/1 sparc: Add full proper error handling to strncpy_from_user().
Linus removed the end-of-address-space hackery from fs/namei.c:do_getname() so we really have to validate these edge conditions and cannot cheat any more (as x86 used to as well).
Move to a common C implementation like x86 did. And if both src and dst are sufficiently aligned we'll do word at a time copies and checks as well.
---
This addresses:
http://marc.info/?l=linux-arch&m3761921425977&w=2
arch/sparc/include/asm/uaccess.h | 3 + arch/sparc/include/asm/uaccess_32.h | 10 --- arch/sparc/include/asm/uaccess_64.h | 4 - arch/sparc/lib/Makefile | 2 +- arch/sparc/lib/ksyms.c | 3 - arch/sparc/lib/strncpy_from_user_32.S | 47 ------------ arch/sparc/lib/strncpy_from_user_64.S | 133 --------------------------------- arch/sparc/lib/usercopy.c | 132 ++++++++++++++++++++++++++++++++ 8 files changed, 136 insertions(+), 198 deletions(-) delete mode 100644 arch/sparc/lib/strncpy_from_user_32.S delete mode 100644 arch/sparc/lib/strncpy_from_user_64.S
arch/sparc/include/asm/uaccess.h +3 -0
@@ -5,4 +5,7 @@#else #include <asm/uaccess_32.h> #endif + +extern long strncpy_from_user (char *dest,const char __user *src,long count); +#endif
arch/sparc/include/asm/uaccess_32.h +0 -10
@@ -304,16 +304,6 @@ static inline unsigned long clear_user(void __user *addr, unsigned long n)return n; } -extern long __strncpy_from_user (char *dest,const char __user *src,long count); - -static inline long strncpy_from_user (char *dest,const char __user *src,long count) -{ -if (__access_ok ((unsigned long ) src, count)) -return __strncpy_from_user (dest, src, count); -else -return -EFAULT ; -} -extern long __strlen_user (const char __user *);extern long __strnlen_user (const char __user *,long len);
arch/sparc/include/asm/uaccess_64.h +0 -4
@@ -257,10 +257,6 @@ extern unsigned long __must_check __clear_user(void __user *, unsigned long);#define clear_user __clear_user -extern long __must_check __strncpy_from_user (char *dest,const char __user *src,long count); - -#define strncpy_from_user __strncpy_from_user -extern long __strlen_user (const char __user *);extern long __strnlen_user (const char __user *,long len);
arch/sparc/lib/Makefile +1 -1
@@ -10,7 +10,7 @@ lib-y += strlen.o lib-y += checksum_$(BITS).o lib-$(CONFIG_SPARC32) += blockops.o lib-y += memscan_$(BITS).o memcmp.o strncmp_$(BITS).o -lib-y += strncpy_from_user_$(BITS).o strlen_user_$(BITS).o +lib-y += strlen_user_$(BITS).o lib-$(CONFIG_SPARC32) += divdi3.o udivdi3.o lib-$(CONFIG_SPARC32) += copy_user.o locks.o lib-$(CONFIG_SPARC64) += atomic_64.o
arch/sparc/lib/ksyms.c +0 -3
@@ -33,9 +33,6 @@ EXPORT_SYMBOL(memset);EXPORT_SYMBOL (memmove);EXPORT_SYMBOL (__bzero); -/* Moving data to/from/in userspace. */ -EXPORT_SYMBOL (__strncpy_from_user); -/* Networking helper routines. */ EXPORT_SYMBOL (csum_partial);
arch/sparc/lib/strncpy_from_user_32.S deleted +0 -47
47 lines not on this page · raw message
arch/sparc/lib/strncpy_from_user_64.S deleted +0 -133
133 lines not on this page · raw message
arch/sparc/lib/usercopy.c +132 -0
139 lines not on this page · raw message
Signature · 1 line
1.7.10
Quoted 8 lines · David Miller
Linus removed the end-of-address-space hackery from fs/namei.c:do_getname() so we really have to validate these edge conditions and cannot cheat any more (as x86 used to as well).
Move to a common C implementation like x86 did. And if both src and dst are sufficiently aligned we'll do word at a time copies and checks as well.
Great - I have removed this from my TODO list.
Sam