Skip to content

Commit 5904122

Browse files
author
Al Viro
committed
take the dummy csum_and_copy_from_user() into net/checksum.h
now that can be done conveniently - all non-trivial cases have _HAVE_ARCH_COPY_AND_CSUM_FROM_USER defined, so the fallback in net/checksum.h is used only for dummy (copy_from_user, then csum_partial) implementation. Allowing us to get rid of all dummy instances, both of csum_and_copy_from_user() and csum_partial_copy_from_user(). Signed-off-by: Al Viro <[email protected]>
1 parent 24f9aa9 commit 5904122

File tree

11 files changed

+2
-149
lines changed

11 files changed

+2
-149
lines changed

arch/c6x/lib/checksum.c

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,6 @@
44
#include <linux/module.h>
55
#include <net/checksum.h>
66

7-
#include <asm/byteorder.h>
8-
9-
/*
10-
* copy from fs while checksumming, otherwise like csum_partial
11-
*/
12-
__wsum
13-
csum_partial_copy_from_user(const void __user *src, void *dst, int len,
14-
__wsum sum, int *csum_err)
15-
{
16-
int missing;
17-
18-
missing = __copy_from_user(dst, src, len);
19-
if (missing) {
20-
memset(dst + len - missing, 0, missing);
21-
*csum_err = -EFAULT;
22-
} else
23-
*csum_err = 0;
24-
25-
return csum_partial(dst, len, sum);
26-
}
27-
EXPORT_SYMBOL(csum_partial_copy_from_user);
28-
297
/* These are from csum_64plus.S */
308
EXPORT_SYMBOL(csum_partial);
319
EXPORT_SYMBOL(csum_partial_copy);

arch/ia64/include/asm/checksum.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,6 @@ extern __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr,
3737
*/
3838
extern __wsum csum_partial(const void *buff, int len, __wsum sum);
3939

40-
#define _HAVE_ARCH_COPY_AND_CSUM_FROM_USER
41-
/*
42-
* Same as csum_partial, but copies from src while it checksums.
43-
*
44-
* Here it is even more important to align src and dst on a 32-bit (or
45-
* even better 64-bit) boundary.
46-
*/
47-
extern __wsum csum_and_copy_from_user(const void __user *src, void *dst,
48-
int len, __wsum sum,
49-
int *errp);
50-
5140
extern __wsum csum_partial_copy_nocheck(const void *src, void *dst,
5241
int len, __wsum sum);
5342

arch/ia64/lib/csum_partial_copy.c

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -103,24 +103,6 @@ unsigned long do_csum_c(const unsigned char * buff, int len, unsigned int psum)
103103
* This is very ugly but temporary. THIS NEEDS SERIOUS ENHANCEMENTS.
104104
* But it's very tricky to get right even in C.
105105
*/
106-
__wsum
107-
csum_and_copy_from_user(const void __user *src, void *dst,
108-
int len, __wsum psum, int *errp)
109-
{
110-
/* XXX Fixme
111-
* for now we separate the copy from checksum for obvious
112-
* alignment difficulties. Look at the Alpha code and you'll be
113-
* scared.
114-
*/
115-
116-
if (copy_from_user(dst, src, len))
117-
*errp = -EFAULT;
118-
119-
return csum_partial(dst, len, psum);
120-
}
121-
122-
EXPORT_SYMBOL(csum_and_copy_from_user);
123-
124106
__wsum
125107
csum_partial_copy_nocheck(const void *src, void *dst, int len, __wsum sum)
126108
{

arch/nios2/include/asm/checksum.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
extern __wsum csum_partial(const void *buff, int len, __wsum sum);
1515
extern __wsum csum_partial_copy(const void *src, void *dst, int len,
1616
__wsum sum);
17-
extern __wsum csum_partial_copy_from_user(const void __user *src, void *dst,
18-
int len, __wsum sum, int *csum_err);
1917
#define csum_partial_copy_nocheck(src, dst, len, sum) \
2018
csum_partial_copy((src), (dst), (len), (sum))
2119

arch/parisc/include/asm/checksum.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,6 @@ extern __wsum csum_partial(const void *, int, __wsum);
2626
*/
2727
extern __wsum csum_partial_copy_nocheck(const void *, void *, int, __wsum);
2828

29-
#define _HAVE_ARCH_COPY_AND_CSUM_FROM_USER
30-
/*
31-
* this is a new version of the above that records errors it finds in *errp,
32-
* but continues and zeros the rest of the buffer.
33-
*/
34-
extern __wsum csum_and_copy_from_user(const void __user *src,
35-
void *dst, int len, __wsum sum, int *errp);
36-
3729
/*
3830
* Optimized for IP headers, which always checksum on 4 octet boundaries.
3931
*

arch/parisc/lib/checksum.c

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -123,17 +123,3 @@ __wsum csum_partial_copy_nocheck(const void *src, void *dst,
123123
return sum;
124124
}
125125
EXPORT_SYMBOL(csum_partial_copy_nocheck);
126-
127-
/*
128-
* Copy from userspace and compute checksum. If we catch an exception
129-
* then zero the rest of the buffer.
130-
*/
131-
__wsum csum_and_copy_from_user(const void __user *src,
132-
void *dst, int len,
133-
__wsum sum, int *err_ptr)
134-
{
135-
if (copy_from_user(dst, src, len))
136-
*err_ptr = -EFAULT;
137-
return csum_partial(dst, len, sum);
138-
}
139-
EXPORT_SYMBOL(csum_and_copy_from_user);

arch/s390/include/asm/checksum.h

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -39,25 +39,6 @@ csum_partial(const void *buff, int len, __wsum sum)
3939
return sum;
4040
}
4141

42-
/*
43-
* the same as csum_partial_copy, but copies from user space.
44-
*
45-
* here even more important to align src and dst on a 32-bit (or even
46-
* better 64-bit) boundary
47-
*
48-
* Copy from userspace and compute checksum.
49-
*/
50-
static inline __wsum
51-
csum_partial_copy_from_user(const void __user *src, void *dst,
52-
int len, __wsum sum,
53-
int *err_ptr)
54-
{
55-
if (unlikely(copy_from_user(dst, src, len)))
56-
*err_ptr = -EFAULT;
57-
return csum_partial(dst, len, sum);
58-
}
59-
60-
6142
static inline __wsum
6243
csum_partial_copy_nocheck (const void *src, void *dst, int len, __wsum sum)
6344
{

arch/x86/um/asm/checksum.h

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -36,26 +36,6 @@ __wsum csum_partial_copy_nocheck(const void *src, void *dst,
3636
return csum_partial(dst, len, sum);
3737
}
3838

39-
/*
40-
* the same as csum_partial, but copies from src while it
41-
* checksums, and handles user-space pointer exceptions correctly, when needed.
42-
*
43-
* here even more important to align src and dst on a 32-bit (or even
44-
* better 64-bit) boundary
45-
*/
46-
47-
static __inline__
48-
__wsum csum_partial_copy_from_user(const void __user *src, void *dst,
49-
int len, __wsum sum, int *err_ptr)
50-
{
51-
if (copy_from_user(dst, src, len)) {
52-
*err_ptr = -EFAULT;
53-
return (__force __wsum)-1;
54-
}
55-
56-
return csum_partial(dst, len, sum);
57-
}
58-
5939
/**
6040
* csum_fold - Fold and invert a 32bit checksum.
6141
* sum: 32bit unfolded sum

include/asm-generic/checksum.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,6 @@ extern __wsum csum_partial(const void *buff, int len, __wsum sum);
2525
*/
2626
extern __wsum csum_partial_copy(const void *src, void *dst, int len, __wsum sum);
2727

28-
/*
29-
* the same as csum_partial_copy, but copies from user space.
30-
*
31-
* here even more important to align src and dst on a 32-bit (or even
32-
* better 64-bit) boundary
33-
*/
34-
extern __wsum csum_partial_copy_from_user(const void __user *src, void *dst,
35-
int len, __wsum sum, int *csum_err);
36-
3728
#ifndef csum_partial_copy_nocheck
3829
#define csum_partial_copy_nocheck(src, dst, len, sum) \
3930
csum_partial_copy((src), (dst), (len), (sum))

include/net/checksum.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,9 @@ static inline
2626
__wsum csum_and_copy_from_user (const void __user *src, void *dst,
2727
int len, __wsum sum, int *err_ptr)
2828
{
29-
if (access_ok(src, len))
30-
return csum_partial_copy_from_user(src, dst, len, sum, err_ptr);
31-
32-
if (len)
29+
if (copy_from_user(dst, src, len))
3330
*err_ptr = -EFAULT;
34-
35-
return sum;
31+
return csum_partial(dst, len, sum);
3632
}
3733
#endif
3834

0 commit comments

Comments
 (0)