Commit 0a5ea224 authored by Al Viro's avatar Al Viro

x86: switch both 32bit and 64bit to providing csum_and_copy_from_user()

... rather than messing with the wrapper.  As a side effect,
32bit variant gets access_ok() into it and can be switched to
user_access_begin()/user_access_end()
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 73e800ec
/* SPDX-License-Identifier: GPL-2.0 */ /* SPDX-License-Identifier: GPL-2.0 */
#define _HAVE_ARCH_COPY_AND_CSUM_FROM_USER 1
#ifdef CONFIG_X86_32 #ifdef CONFIG_X86_32
# include <asm/checksum_32.h> # include <asm/checksum_32.h>
#else #else
......
...@@ -44,18 +44,21 @@ static inline __wsum csum_partial_copy_nocheck(const void *src, void *dst, ...@@ -44,18 +44,21 @@ static inline __wsum csum_partial_copy_nocheck(const void *src, void *dst,
return csum_partial_copy_generic(src, dst, len, sum, NULL, NULL); return csum_partial_copy_generic(src, dst, len, sum, NULL, NULL);
} }
static inline __wsum csum_partial_copy_from_user(const void __user *src, static inline __wsum csum_and_copy_from_user(const void __user *src,
void *dst, void *dst, int len,
int len, __wsum sum, __wsum sum, int *err_ptr)
int *err_ptr)
{ {
__wsum ret; __wsum ret;
might_sleep(); might_sleep();
stac(); if (!user_access_begin(src, len)) {
if (len)
*err_ptr = -EFAULT;
return sum;
}
ret = csum_partial_copy_generic((__force void *)src, dst, ret = csum_partial_copy_generic((__force void *)src, dst,
len, sum, err_ptr, NULL); len, sum, err_ptr, NULL);
clac(); user_access_end();
return ret; return ret;
} }
......
...@@ -129,7 +129,6 @@ static inline __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr, ...@@ -129,7 +129,6 @@ static inline __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr,
*/ */
extern __wsum csum_partial(const void *buff, int len, __wsum sum); extern __wsum csum_partial(const void *buff, int len, __wsum sum);
#define _HAVE_ARCH_COPY_AND_CSUM_FROM_USER 1
#define HAVE_CSUM_COPY_USER 1 #define HAVE_CSUM_COPY_USER 1
...@@ -139,15 +138,13 @@ extern __visible __wsum csum_partial_copy_generic(const void *src, const void *d ...@@ -139,15 +138,13 @@ extern __visible __wsum csum_partial_copy_generic(const void *src, const void *d
int *src_err_ptr, int *dst_err_ptr); int *src_err_ptr, int *dst_err_ptr);
extern __wsum csum_partial_copy_from_user(const void __user *src, void *dst, extern __wsum csum_and_copy_from_user(const void __user *src, void *dst,
int len, __wsum isum, int *errp); int len, __wsum isum, int *errp);
extern __wsum csum_and_copy_to_user(const void *src, void __user *dst, extern __wsum csum_and_copy_to_user(const void *src, void __user *dst,
int len, __wsum isum, int *errp); int len, __wsum isum, int *errp);
extern __wsum csum_partial_copy_nocheck(const void *src, void *dst, extern __wsum csum_partial_copy_nocheck(const void *src, void *dst,
int len, __wsum sum); int len, __wsum sum);
#define csum_and_copy_from_user csum_partial_copy_from_user
/** /**
* ip_compute_csum - Compute an 16bit IP checksum. * ip_compute_csum - Compute an 16bit IP checksum.
* @buff: buffer address. * @buff: buffer address.
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
#include <asm/smap.h> #include <asm/smap.h>
/** /**
* csum_partial_copy_from_user - Copy and checksum from user space. * csum_and_copy_from_user - Copy and checksum from user space.
* @src: source address (user space) * @src: source address (user space)
* @dst: destination address * @dst: destination address
* @len: number of bytes to be copied. * @len: number of bytes to be copied.
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
* src and dst are best aligned to 64bits. * src and dst are best aligned to 64bits.
*/ */
__wsum __wsum
csum_partial_copy_from_user(const void __user *src, void *dst, csum_and_copy_from_user(const void __user *src, void *dst,
int len, __wsum isum, int *errp) int len, __wsum isum, int *errp)
{ {
might_sleep(); might_sleep();
...@@ -68,7 +68,7 @@ csum_partial_copy_from_user(const void __user *src, void *dst, ...@@ -68,7 +68,7 @@ csum_partial_copy_from_user(const void __user *src, void *dst,
return isum; return isum;
} }
EXPORT_SYMBOL(csum_partial_copy_from_user); EXPORT_SYMBOL(csum_and_copy_from_user);
/** /**
* csum_and_copy_to_user - Copy and checksum to user space. * csum_and_copy_to_user - Copy and checksum to user space.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment