summaryrefslogtreecommitdiff
path: root/arch/hexagon/include
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2020-01-16 15:58:41 +0100
committerArnd Bergmann <arnd@arndb.de>2021-07-23 14:40:00 +0200
commit2820cfdc08178c55efa1c0fa402f082ef09bfe70 (patch)
tree41a09cdb09e78200e39af196dff143a977464936 /arch/hexagon/include
parent2f69b04a88687626b044a66661c570ca0ca6a0fc (diff)
hexagon: use generic strncpy/strnlen from_user
Remove the hexagon implementation of strncpy/strnlen and instead use the generic version. The hexagon version reads the data twice for strncpy() by doing an extra strnlen(), and it apparently lacks a check for user_addr_max(). Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Diffstat (limited to 'arch/hexagon/include')
-rw-r--r--arch/hexagon/include/asm/uaccess.h33
1 files changed, 2 insertions, 31 deletions
diff --git a/arch/hexagon/include/asm/uaccess.h b/arch/hexagon/include/asm/uaccess.h
index 59aa3a50744f..d950df12d8c5 100644
--- a/arch/hexagon/include/asm/uaccess.h
+++ b/arch/hexagon/include/asm/uaccess.h
@@ -57,42 +57,13 @@ unsigned long raw_copy_to_user(void __user *to, const void *from,
__kernel_size_t __clear_user_hexagon(void __user *dest, unsigned long count);
#define __clear_user(a, s) __clear_user_hexagon((a), (s))
-extern long __strnlen_user(const char __user *src, long n);
-
-static inline strnlen_user(const char __user *src, long n)
-{
- if (!access_ok(src, 1))
- return 0;
-
- return __strnlen_user(src, n);
-}
-/* get around the ifndef in asm-generic/uaccess.h */
+extern long strnlen_user(const char __user *src, long n);
#define strnlen_user strnlen_user
-static inline long strncpy_from_user(char *dst, const char __user *src, long n);
+extern long strncpy_from_user(char *dst, const char __user *src, long n)
#define strncpy_from_user strncpy_from_user
#include <asm-generic/uaccess.h>
-/* Todo: an actual accelerated version of this. */
-static inline long strncpy_from_user(char *dst, const char __user *src, long n)
-{
- long res = strnlen_user(src, n);
-
- if (unlikely(!res))
- return -EFAULT;
-
- if (res > n) {
- long left = raw_copy_from_user(dst, src, n);
- if (unlikely(left))
- memset(dst + (n - left), 0, left);
- return n;
- } else {
- long left = raw_copy_from_user(dst, src, res);
- if (unlikely(left))
- memset(dst + (res - left), 0, left);
- return res-1;
- }
-}
#endif