summaryrefslogtreecommitdiffstats
path: root/arch/arc
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2020-01-16 13:18:38 +0100
committerArnd Bergmann <arnd@arndb.de>2021-07-23 14:39:56 +0200
commitf27180dd63e1e6eca3230b9d3fdcc33564a81117 (patch)
tree32f334f2fad44c2b989b546970e830a165ebc1ce /arch/arc
parentLinux 5.14-rc2 (diff)
downloadlinux-f27180dd63e1e6eca3230b9d3fdcc33564a81117.tar.xz
linux-f27180dd63e1e6eca3230b9d3fdcc33564a81117.zip
asm-generic/uaccess.h: remove __strncpy_from_user/__strnlen_user
This is a preparation for changing over architectures to the generic implementation one at a time. As there are no callers of either __strncpy_from_user() or __strnlen_user(), fold these into the strncpy_from_user() and strnlen_user() functions to make each implementation independent of the others. Many of these implementations have known bugs, but the intention here is to not change behavior at all and stay compatible with those bugs for the moment. Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Diffstat (limited to 'arch/arc')
-rw-r--r--arch/arc/include/asm/uaccess.h14
1 files changed, 10 insertions, 4 deletions
diff --git a/arch/arc/include/asm/uaccess.h b/arch/arc/include/asm/uaccess.h
index ea40ec7f6cae..3476348f361e 100644
--- a/arch/arc/include/asm/uaccess.h
+++ b/arch/arc/include/asm/uaccess.h
@@ -661,6 +661,9 @@ __arc_strncpy_from_user(char *dst, const char __user *src, long count)
long res = 0;
char val;
+ if (!access_ok(src, 1))
+ return -EFAULT;
+
if (count == 0)
return 0;
@@ -693,6 +696,9 @@ static inline long __arc_strnlen_user(const char __user *s, long n)
long res, tmp1, cnt;
char val;
+ if (!access_ok(s, 1))
+ return 0;
+
__asm__ __volatile__(
" mov %2, %1 \n"
"1: ldb.ab %3, [%0, 1] \n"
@@ -724,8 +730,8 @@ static inline long __arc_strnlen_user(const char __user *s, long n)
#define INLINE_COPY_FROM_USER
#define __clear_user(d, n) __arc_clear_user(d, n)
-#define __strncpy_from_user(d, s, n) __arc_strncpy_from_user(d, s, n)
-#define __strnlen_user(s, n) __arc_strnlen_user(s, n)
+#define strncpy_from_user(d, s, n) __arc_strncpy_from_user(d, s, n)
+#define strnlen_user(s, n) __arc_strnlen_user(s, n)
#else
extern unsigned long arc_clear_user_noinline(void __user *to,
unsigned long n);
@@ -734,8 +740,8 @@ extern long arc_strncpy_from_user_noinline (char *dst, const char __user *src,
extern long arc_strnlen_user_noinline(const char __user *src, long n);
#define __clear_user(d, n) arc_clear_user_noinline(d, n)
-#define __strncpy_from_user(d, s, n) arc_strncpy_from_user_noinline(d, s, n)
-#define __strnlen_user(s, n) arc_strnlen_user_noinline(s, n)
+#define strncpy_from_user(d, s, n) arc_strncpy_from_user_noinline(d, s, n)
+#define strnlen_user(s, n) arc_strnlen_user_noinline(s, n)
#endif