Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ff06dffb authored by David S. Miller's avatar David S. Miller
Browse files

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.

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 29af0eba
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -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
+0 −10
Original line number Diff line number Diff line
@@ -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);

+0 −4
Original line number Diff line number Diff line
@@ -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);

+1 −1
Original line number Diff line number Diff line
@@ -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
+0 −3
Original line number Diff line number Diff line
@@ -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);

Loading