aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Filippov <jcmvbkbc@gmail.com>2017-12-17 17:43:15 -0500
committerMax Filippov <jcmvbkbc@gmail.com>2017-12-17 18:34:57 -0500
commit57358ba9564a0520f870dc14a0f91e7dacc18236 (patch)
tree616be15e6bbe43bbf7539a359b3485b070f62920
parente0baa01438d3fa3979f94f98be19ca3df88e0b7c (diff)
xtensa: use generic strncpy_from_user with KASAN
This enables KASAN check of the destination buffer. Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
-rw-r--r--arch/xtensa/Kconfig1
-rw-r--r--arch/xtensa/include/asm/uaccess.h7
-rw-r--r--arch/xtensa/kernel/xtensa_ksyms.c2
3 files changed, 10 insertions, 0 deletions
diff --git a/arch/xtensa/Kconfig b/arch/xtensa/Kconfig
index f9f95d6e8da8..e2afffb71a6b 100644
--- a/arch/xtensa/Kconfig
+++ b/arch/xtensa/Kconfig
@@ -15,6 +15,7 @@ config XTENSA
15 select GENERIC_IRQ_SHOW 15 select GENERIC_IRQ_SHOW
16 select GENERIC_PCI_IOMAP 16 select GENERIC_PCI_IOMAP
17 select GENERIC_SCHED_CLOCK 17 select GENERIC_SCHED_CLOCK
18 select GENERIC_STRNCPY_FROM_USER if KASAN
18 select HAVE_ARCH_KASAN if MMU 19 select HAVE_ARCH_KASAN if MMU
19 select HAVE_CC_STACKPROTECTOR 20 select HAVE_CC_STACKPROTECTOR
20 select HAVE_DEBUG_KMEMLEAK 21 select HAVE_DEBUG_KMEMLEAK
diff --git a/arch/xtensa/include/asm/uaccess.h b/arch/xtensa/include/asm/uaccess.h
index 18bbe1caad94..f1158b4c629c 100644
--- a/arch/xtensa/include/asm/uaccess.h
+++ b/arch/xtensa/include/asm/uaccess.h
@@ -44,6 +44,8 @@
44#define __access_ok(addr, size) (__kernel_ok || __user_ok((addr), (size))) 44#define __access_ok(addr, size) (__kernel_ok || __user_ok((addr), (size)))
45#define access_ok(type, addr, size) __access_ok((unsigned long)(addr), (size)) 45#define access_ok(type, addr, size) __access_ok((unsigned long)(addr), (size))
46 46
47#define user_addr_max() (uaccess_kernel() ? ~0UL : TASK_SIZE)
48
47/* 49/*
48 * These are the main single-value transfer routines. They 50 * These are the main single-value transfer routines. They
49 * automatically use the right size if we just have the right pointer 51 * automatically use the right size if we just have the right pointer
@@ -277,6 +279,8 @@ clear_user(void *addr, unsigned long size)
277#define __clear_user __xtensa_clear_user 279#define __clear_user __xtensa_clear_user
278 280
279 281
282#ifndef CONFIG_GENERIC_STRNCPY_FROM_USER
283
280extern long __strncpy_user(char *, const char *, long); 284extern long __strncpy_user(char *, const char *, long);
281 285
282static inline long 286static inline long
@@ -286,6 +290,9 @@ strncpy_from_user(char *dst, const char *src, long count)
286 return __strncpy_user(dst, src, count); 290 return __strncpy_user(dst, src, count);
287 return -EFAULT; 291 return -EFAULT;
288} 292}
293#else
294long strncpy_from_user(char *dst, const char *src, long count);
295#endif
289 296
290/* 297/*
291 * Return the size of a string (including the ending 0!) 298 * Return the size of a string (including the ending 0!)
diff --git a/arch/xtensa/kernel/xtensa_ksyms.c b/arch/xtensa/kernel/xtensa_ksyms.c
index 3a443f83ae87..04f19de46700 100644
--- a/arch/xtensa/kernel/xtensa_ksyms.c
+++ b/arch/xtensa/kernel/xtensa_ksyms.c
@@ -44,7 +44,9 @@ EXPORT_SYMBOL(memmove);
44EXPORT_SYMBOL(__memset); 44EXPORT_SYMBOL(__memset);
45EXPORT_SYMBOL(__memcpy); 45EXPORT_SYMBOL(__memcpy);
46EXPORT_SYMBOL(__memmove); 46EXPORT_SYMBOL(__memmove);
47#ifndef CONFIG_GENERIC_STRNCPY_FROM_USER
47EXPORT_SYMBOL(__strncpy_user); 48EXPORT_SYMBOL(__strncpy_user);
49#endif
48EXPORT_SYMBOL(clear_page); 50EXPORT_SYMBOL(clear_page);
49EXPORT_SYMBOL(copy_page); 51EXPORT_SYMBOL(copy_page);
50 52