Skip to contentSkip to conversation

asm-generic: uaccess.h: Fixup GENERIC_STRNCPY_FROM_USER & STRNLEN_USER

PATCH New [email protected] 1 participant 1 message Apr 21, 2021

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

PATCH 1/1 asm-generic: uaccess.h: Fixup GENERIC_STRNCPY_FROM_USER & STRNLEN_USER

From: Guo Ren <[email protected]>

When arch include asm-generic/uaccess.h and enable GENERIC STRNCPY_FROM_USER / STRNLEN_USER. Then, compile error.

Cc Arnd Bergmann <[email protected]>
---
 include/asm-generic/uaccess.h | 8 ++++++++
 1 file changed, 8 insertions(+)
include/asm-generic/uaccess.h +8 -0
index 4973328..c02080d 100644
@@ -243,6 +243,9 @@ static inline int __get_user_fn(size_t size, const void __user *ptr, void *x)
 
 extern int __get_user_bad(void) __attribute__((noreturn));
 
+#ifdef CONFIG_GENERIC_STRNCPY_FROM_USER
+long strncpy_from_user(char *dst, const char __user *src, long count);
+#else
 /*
  * Copy a null terminated string from userspace.
  */
@@ -265,7 +268,11 @@ strncpy_from_user(char *dst, const char __user *src, long count)
 		return -EFAULT;
 	return __strncpy_from_user(dst, src, count);
 }
+#endif /* CONFIG_GENERIC_STRNCPY_FROM_USER */
 
+#ifdef CONFIG_GENERIC_STRNLEN_USER
+long strnlen_user(const char __user *src, long n);
+#else
 /*
  * Return the size of a string (including the ending 0)
  *
@@ -286,6 +293,7 @@ static inline long strnlen_user(const char __user *src, long n)
 		return 0;
 	return __strnlen_user(src, n);
 }
+#endif /* CONFIG_GENERIC_STRNLEN_USER */
 
 /*
  * Zero Userspace
Signature · 1 line
2.7.4