diff options
author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2018-06-09 02:33:51 +0200 |
---|---|---|
committer | Palmer Dabbelt <palmer@sifive.com> | 2018-06-09 12:34:31 -0700 |
commit | 86406d51d3600bfa2b6f86e1e6bfce712bec0d53 (patch) | |
tree | 377b5f849722635bc2e919a4a7176da05d7859d0 /arch/riscv/include/asm | |
parent | 9bf97390b3030b68a465681043a66461c7cf6a65 (diff) | |
download | linux-stable-86406d51d3600bfa2b6f86e1e6bfce712bec0d53.tar.gz linux-stable-86406d51d3600bfa2b6f86e1e6bfce712bec0d53.tar.bz2 linux-stable-86406d51d3600bfa2b6f86e1e6bfce712bec0d53.zip |
riscv: split the declaration of __copy_user
We use a single __copy_user assembly function to copy memory both from
and to userspace. While this works, it triggers sparse errors because
we're implicitly casting between the kernel and user address spaces by
calling __copy_user.
This patch splits the C declaration into a pair of functions,
__asm_copy_{to,from}_user, that have sane semantics WRT __user. This
split make things fine from sparse's point of view. The assembly
implementation keeps a single definition but add a double ENTRY() for it,
one for __asm_copy_to_user and another one for __asm_copy_from_user.
The result is a spare-safe implementation that pays no performance
or code size penalty.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Signed-off-by: Palmer Dabbelt <palmer@sifive.com>
Diffstat (limited to 'arch/riscv/include/asm')
-rw-r--r-- | arch/riscv/include/asm/uaccess.h | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/arch/riscv/include/asm/uaccess.h b/arch/riscv/include/asm/uaccess.h index 14b0b22fb578..473cfc84e412 100644 --- a/arch/riscv/include/asm/uaccess.h +++ b/arch/riscv/include/asm/uaccess.h @@ -392,19 +392,21 @@ do { \ }) -extern unsigned long __must_check __copy_user(void __user *to, +extern unsigned long __must_check __asm_copy_to_user(void __user *to, + const void *from, unsigned long n); +extern unsigned long __must_check __asm_copy_from_user(void *to, const void __user *from, unsigned long n); static inline unsigned long raw_copy_from_user(void *to, const void __user *from, unsigned long n) { - return __copy_user(to, from, n); + return __asm_copy_to_user(to, from, n); } static inline unsigned long raw_copy_to_user(void __user *to, const void *from, unsigned long n) { - return __copy_user(to, from, n); + return __asm_copy_from_user(to, from, n); } extern long strncpy_from_user(char *dest, const char __user *src, long count); |