Skip to content

Commit

Permalink
xtensa: use generic strncpy_from_user with KASAN
Browse files Browse the repository at this point in the history
This enables KASAN check of the destination buffer.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
  • Loading branch information
Max Filippov committed Dec 17, 2017
1 parent e0baa01 commit 57358ba
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions arch/xtensa/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ config XTENSA
select GENERIC_IRQ_SHOW
select GENERIC_PCI_IOMAP
select GENERIC_SCHED_CLOCK
select GENERIC_STRNCPY_FROM_USER if KASAN
select HAVE_ARCH_KASAN if MMU
select HAVE_CC_STACKPROTECTOR
select HAVE_DEBUG_KMEMLEAK
Expand Down
7 changes: 7 additions & 0 deletions arch/xtensa/include/asm/uaccess.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
#define __access_ok(addr, size) (__kernel_ok || __user_ok((addr), (size)))
#define access_ok(type, addr, size) __access_ok((unsigned long)(addr), (size))

#define user_addr_max() (uaccess_kernel() ? ~0UL : TASK_SIZE)

/*
* These are the main single-value transfer routines. They
* automatically use the right size if we just have the right pointer
Expand Down Expand Up @@ -277,6 +279,8 @@ clear_user(void *addr, unsigned long size)
#define __clear_user __xtensa_clear_user


#ifndef CONFIG_GENERIC_STRNCPY_FROM_USER

extern long __strncpy_user(char *, const char *, long);

static inline long
Expand All @@ -286,6 +290,9 @@ strncpy_from_user(char *dst, const char *src, long count)
return __strncpy_user(dst, src, count);
return -EFAULT;
}
#else
long strncpy_from_user(char *dst, const char *src, long count);
#endif

/*
* Return the size of a string (including the ending 0!)
Expand Down
2 changes: 2 additions & 0 deletions arch/xtensa/kernel/xtensa_ksyms.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ EXPORT_SYMBOL(memmove);
EXPORT_SYMBOL(__memset);
EXPORT_SYMBOL(__memcpy);
EXPORT_SYMBOL(__memmove);
#ifndef CONFIG_GENERIC_STRNCPY_FROM_USER
EXPORT_SYMBOL(__strncpy_user);
#endif
EXPORT_SYMBOL(clear_page);
EXPORT_SYMBOL(copy_page);

Expand Down

0 comments on commit 57358ba

Please sign in to comment.