From: Eric Dumazet <hidden> Date: 2021-12-03 18:52:44
From: Eric Dumazet <redacted>
Vladimir reported csum issues after my recent change in skb_postpull_rcsum()
Issue here is the following:
initial skb->csum is the csum of
[part to be pulled][rest of packet]
Old code:
skb->csum = csum_sub(skb->csum, csum_partial(pull, pull_length, 0));
New code:
skb->csum = ~csum_partial(pull, pull_length, ~skb->csum);
This is broken if the csum of [pulled part]
happens to be equal to skb->csum, because end
result of skb->csum is 0 in new code, instead
of being 0xffffffff
David Laight suggested to use
skb->csum = -csum_partial(pull, pull_length, -skb->csum);
I based my patches on existing code present in include/net/seg6.h,
update_csum_diff4() and update_csum_diff16() which might need
a similar fix.
I guess that my tests, mostly pulling 40 bytes of IPv6 header
were not providing enough entropy to hit this bug.
Fixes: 29c3002644bd ("net: optimize skb_postpull_rcsum()")
Fixes: 0bd28476f636 ("gro: optimize skb_gro_postpull_rcsum()")
Signed-off-by: Eric Dumazet <redacted>
Reported-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Suggested-by: David Laight <redacted>
Cc: David Lebrun <redacted>
---
include/linux/skbuff.h | 2 +-
include/net/gro.h | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
@@ -173,8 +173,8 @@ static inline void skb_gro_postpull_rcsum(struct sk_buff *skb,constvoid*start,unsignedintlen){if(NAPI_GRO_CB(skb)->csum_valid)-NAPI_GRO_CB(skb)->csum=~csum_partial(start,len,-~NAPI_GRO_CB(skb)->csum);+NAPI_GRO_CB(skb)->csum=-csum_partial(start,len,+-NAPI_GRO_CB(skb)->csum);}/* GRO checksum functions. These are logical equivalents of the normal
From: kernel test robot <hidden> Date: 2021-12-04 03:34:35
Hi Eric,
I love your patch! Perhaps something to improve:
[auto build test WARNING on net-next/master]
url: https://github.com/0day-ci/linux/commits/Eric-Dumazet/net-fix-recent-csum-changes/20211204-025401
base: https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git 43332cf97425a3e5508c827c82201ecc5ddd54e0
config: arc-randconfig-s032-20211203 (https://download.01.org/0day-ci/archive/20211204/202112041119.X8sqBWc9-lkp@intel.com/config)
compiler: arc-elf-gcc (GCC) 11.2.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# apt-get install sparse
# sparse version: v0.6.4-dirty
# https://github.com/0day-ci/linux/commit/c13fbd113358fb59f76f76d25a1fdb57379c4b9c
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Eric-Dumazet/net-fix-recent-csum-changes/20211204-025401
git checkout c13fbd113358fb59f76f76d25a1fdb57379c4b9c
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=arc SHELL=/bin/bash net/core/ net/ethernet/
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <redacted>
sparse warnings: (new ones prefixed by >>)
net/core/skbuff.c: note: in included file (through include/net/checksum.h, include/linux/skbuff.h, include/net/net_namespace.h, ...):
arch/arc/include/asm/checksum.h:27:26: sparse: sparse: restricted __wsum degrades to integer
arch/arc/include/asm/checksum.h:27:36: sparse: sparse: restricted __wsum degrades to integer
arch/arc/include/asm/checksum.h:29:11: sparse: sparse: bad assignment (-=) to restricted __wsum
arch/arc/include/asm/checksum.h:30:16: sparse: sparse: restricted __wsum degrades to integer
arch/arc/include/asm/checksum.h:30:18: sparse: sparse: incorrect type in return expression (different base types) @@ expected restricted __sum16 @@ got unsigned int @@
arch/arc/include/asm/checksum.h:30:18: sparse: expected restricted __sum16
arch/arc/include/asm/checksum.h:30:18: sparse: got unsigned int
arch/arc/include/asm/checksum.h:27:26: sparse: sparse: restricted __wsum degrades to integer
arch/arc/include/asm/checksum.h:27:36: sparse: sparse: restricted __wsum degrades to integer
arch/arc/include/asm/checksum.h:29:11: sparse: sparse: bad assignment (-=) to restricted __wsum
arch/arc/include/asm/checksum.h:30:16: sparse: sparse: restricted __wsum degrades to integer
arch/arc/include/asm/checksum.h:30:18: sparse: sparse: incorrect type in return expression (different base types) @@ expected restricted __sum16 @@ got unsigned int @@
arch/arc/include/asm/checksum.h:30:18: sparse: expected restricted __sum16
arch/arc/include/asm/checksum.h:30:18: sparse: got unsigned int
arch/arc/include/asm/checksum.h:27:26: sparse: sparse: restricted __wsum degrades to integer
arch/arc/include/asm/checksum.h:27:36: sparse: sparse: restricted __wsum degrades to integer
arch/arc/include/asm/checksum.h:29:11: sparse: sparse: bad assignment (-=) to restricted __wsum
arch/arc/include/asm/checksum.h:30:16: sparse: sparse: restricted __wsum degrades to integer
arch/arc/include/asm/checksum.h:30:18: sparse: sparse: incorrect type in return expression (different base types) @@ expected restricted __sum16 @@ got unsigned int @@
arch/arc/include/asm/checksum.h:30:18: sparse: expected restricted __sum16
arch/arc/include/asm/checksum.h:30:18: sparse: got unsigned int
net/core/skbuff.c: note: in included file (through include/net/net_namespace.h, include/linux/inet.h):
include/linux/skbuff.h:3489:55: sparse: sparse: restricted __wsum degrades to integer
quoted
include/linux/skbuff.h:3489:55: sparse: sparse: incorrect type in argument 3 (different base types) @@ expected restricted __wsum [usertype] sum @@ got unsigned int @@
include/linux/skbuff.h:3489:55: sparse: expected restricted __wsum [usertype] sum
include/linux/skbuff.h:3489:55: sparse: got unsigned int
include/linux/skbuff.h:3489:29: sparse: sparse: restricted __wsum degrades to integer
include/linux/skbuff.h:3489:27: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __wsum [usertype] csum @@ got unsigned int @@
include/linux/skbuff.h:3489:27: sparse: expected restricted __wsum [usertype] csum
include/linux/skbuff.h:3489:27: sparse: got unsigned int
net/core/skbuff.c: note: in included file (through include/net/checksum.h, include/linux/skbuff.h, include/net/net_namespace.h, ...):
arch/arc/include/asm/checksum.h:27:26: sparse: sparse: restricted __wsum degrades to integer
arch/arc/include/asm/checksum.h:27:36: sparse: sparse: restricted __wsum degrades to integer
arch/arc/include/asm/checksum.h:29:11: sparse: sparse: bad assignment (-=) to restricted __wsum
arch/arc/include/asm/checksum.h:30:16: sparse: sparse: restricted __wsum degrades to integer
arch/arc/include/asm/checksum.h:30:18: sparse: sparse: incorrect type in return expression (different base types) @@ expected restricted __sum16 @@ got unsigned int @@
arch/arc/include/asm/checksum.h:30:18: sparse: expected restricted __sum16
arch/arc/include/asm/checksum.h:30:18: sparse: got unsigned int
net/core/skbuff.c: note: in included file (through include/net/net_namespace.h, include/linux/inet.h):
include/linux/skbuff.h:3489:55: sparse: sparse: restricted __wsum degrades to integer
quoted
include/linux/skbuff.h:3489:55: sparse: sparse: incorrect type in argument 3 (different base types) @@ expected restricted __wsum [usertype] sum @@ got unsigned int @@
include/linux/skbuff.h:3489:55: sparse: expected restricted __wsum [usertype] sum
include/linux/skbuff.h:3489:55: sparse: got unsigned int
include/linux/skbuff.h:3489:29: sparse: sparse: restricted __wsum degrades to integer
include/linux/skbuff.h:3489:27: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __wsum [usertype] csum @@ got unsigned int @@
include/linux/skbuff.h:3489:27: sparse: expected restricted __wsum [usertype] csum
include/linux/skbuff.h:3489:27: sparse: got unsigned int
include/linux/skbuff.h:3489:55: sparse: sparse: restricted __wsum degrades to integer
quoted
include/linux/skbuff.h:3489:55: sparse: sparse: incorrect type in argument 3 (different base types) @@ expected restricted __wsum [usertype] sum @@ got unsigned int @@
include/linux/skbuff.h:3489:55: sparse: expected restricted __wsum [usertype] sum
include/linux/skbuff.h:3489:55: sparse: got unsigned int
include/linux/skbuff.h:3489:29: sparse: sparse: restricted __wsum degrades to integer
include/linux/skbuff.h:3489:27: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __wsum [usertype] csum @@ got unsigned int @@
include/linux/skbuff.h:3489:27: sparse: expected restricted __wsum [usertype] csum
include/linux/skbuff.h:3489:27: sparse: got unsigned int
--
net/core/filter.c:5622:9: sparse: sparse: switch with no cases
net/core/filter.c:5663:9: sparse: sparse: switch with no cases
net/core/filter.c:1411:39: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected struct sock_filter const *filter @@ got struct sock_filter [noderef] __user *filter @@
net/core/filter.c:1411:39: sparse: expected struct sock_filter const *filter
net/core/filter.c:1411:39: sparse: got struct sock_filter [noderef] __user *filter
net/core/filter.c:1489:39: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected struct sock_filter const *filter @@ got struct sock_filter [noderef] __user *filter @@
net/core/filter.c:1489:39: sparse: expected struct sock_filter const *filter
net/core/filter.c:1489:39: sparse: got struct sock_filter [noderef] __user *filter
net/core/filter.c:10023:31: sparse: sparse: symbol 'cg_skb_verifier_ops' was not declared. Should it be static?
net/core/filter.c:10029:27: sparse: sparse: symbol 'cg_skb_prog_ops' was not declared. Should it be static?
net/core/filter.c:10074:31: sparse: sparse: symbol 'cg_sock_verifier_ops' was not declared. Should it be static?
net/core/filter.c:10080:27: sparse: sparse: symbol 'cg_sock_prog_ops' was not declared. Should it be static?
net/core/filter.c:10083:31: sparse: sparse: symbol 'cg_sock_addr_verifier_ops' was not declared. Should it be static?
net/core/filter.c:10089:27: sparse: sparse: symbol 'cg_sock_addr_prog_ops' was not declared. Should it be static?
net/core/filter.c:246:32: sparse: sparse: cast to restricted __be16
net/core/filter.c:246:32: sparse: sparse: cast to restricted __be16
net/core/filter.c:246:32: sparse: sparse: cast to restricted __be16
net/core/filter.c:246:32: sparse: sparse: cast to restricted __be16
net/core/filter.c:273:32: sparse: sparse: cast to restricted __be32
net/core/filter.c:273:32: sparse: sparse: cast to restricted __be32
net/core/filter.c:273:32: sparse: sparse: cast to restricted __be32
net/core/filter.c:273:32: sparse: sparse: cast to restricted __be32
net/core/filter.c:273:32: sparse: sparse: cast to restricted __be32
net/core/filter.c:273:32: sparse: sparse: cast to restricted __be32
net/core/filter.c:1910:43: sparse: sparse: incorrect type in argument 2 (different base types) @@ expected restricted __wsum [usertype] diff @@ got unsigned long long [usertype] to @@
net/core/filter.c:1910:43: sparse: expected restricted __wsum [usertype] diff
net/core/filter.c:1910:43: sparse: got unsigned long long [usertype] to
net/core/filter.c:1913:36: sparse: sparse: incorrect type in argument 2 (different base types) @@ expected restricted __be16 [usertype] old @@ got unsigned long long [usertype] from @@
net/core/filter.c:1913:36: sparse: expected restricted __be16 [usertype] old
net/core/filter.c:1913:36: sparse: got unsigned long long [usertype] from
net/core/filter.c:1913:42: sparse: sparse: incorrect type in argument 3 (different base types) @@ expected restricted __be16 [usertype] new @@ got unsigned long long [usertype] to @@
net/core/filter.c:1913:42: sparse: expected restricted __be16 [usertype] new
net/core/filter.c:1913:42: sparse: got unsigned long long [usertype] to
net/core/filter.c:1916:36: sparse: sparse: incorrect type in argument 2 (different base types) @@ expected restricted __be32 [usertype] from @@ got unsigned long long [usertype] from @@
net/core/filter.c:1916:36: sparse: expected restricted __be32 [usertype] from
net/core/filter.c:1916:36: sparse: got unsigned long long [usertype] from
net/core/filter.c:1916:42: sparse: sparse: incorrect type in argument 3 (different base types) @@ expected restricted __be32 [usertype] to @@ got unsigned long long [usertype] to @@
net/core/filter.c:1916:42: sparse: expected restricted __be32 [usertype] to
net/core/filter.c:1916:42: sparse: got unsigned long long [usertype] to
net/core/filter.c:1961:59: sparse: sparse: incorrect type in argument 3 (different base types) @@ expected restricted __wsum [usertype] diff @@ got unsigned long long [usertype] to @@
net/core/filter.c:1961:59: sparse: expected restricted __wsum [usertype] diff
net/core/filter.c:1961:59: sparse: got unsigned long long [usertype] to
net/core/filter.c:1964:52: sparse: sparse: incorrect type in argument 3 (different base types) @@ expected restricted __be16 [usertype] from @@ got unsigned long long [usertype] from @@
net/core/filter.c:1964:52: sparse: expected restricted __be16 [usertype] from
net/core/filter.c:1964:52: sparse: got unsigned long long [usertype] from
net/core/filter.c:1964:58: sparse: sparse: incorrect type in argument 4 (different base types) @@ expected restricted __be16 [usertype] to @@ got unsigned long long [usertype] to @@
net/core/filter.c:1964:58: sparse: expected restricted __be16 [usertype] to
net/core/filter.c:1964:58: sparse: got unsigned long long [usertype] to
net/core/filter.c:1967:52: sparse: sparse: incorrect type in argument 3 (different base types) @@ expected restricted __be32 [usertype] from @@ got unsigned long long [usertype] from @@
net/core/filter.c:1967:52: sparse: expected restricted __be32 [usertype] from
net/core/filter.c:1967:52: sparse: got unsigned long long [usertype] from
net/core/filter.c:1967:58: sparse: sparse: incorrect type in argument 4 (different base types) @@ expected restricted __be32 [usertype] to @@ got unsigned long long [usertype] to @@
net/core/filter.c:1967:58: sparse: expected restricted __be32 [usertype] to
net/core/filter.c:1967:58: sparse: got unsigned long long [usertype] to
net/core/filter.c:2013:28: sparse: sparse: incorrect type in return expression (different base types) @@ expected unsigned long long @@ got restricted __wsum @@
net/core/filter.c:2013:28: sparse: expected unsigned long long
net/core/filter.c:2013:28: sparse: got restricted __wsum
net/core/filter.c:2035:35: sparse: sparse: incorrect type in return expression (different base types) @@ expected unsigned long long @@ got restricted __wsum [usertype] csum @@
net/core/filter.c:2035:35: sparse: expected unsigned long long
net/core/filter.c:2035:35: sparse: got restricted __wsum [usertype] csum
net/core/filter.c: note: in included file (through include/linux/netlink.h, include/linux/sock_diag.h):
include/linux/skbuff.h:3489:55: sparse: sparse: restricted __wsum degrades to integer
quoted
include/linux/skbuff.h:3489:55: sparse: sparse: incorrect type in argument 3 (different base types) @@ expected restricted __wsum [usertype] sum @@ got unsigned int @@
include/linux/skbuff.h:3489:55: sparse: expected restricted __wsum [usertype] sum
include/linux/skbuff.h:3489:55: sparse: got unsigned int
include/linux/skbuff.h:3489:29: sparse: sparse: restricted __wsum degrades to integer
include/linux/skbuff.h:3489:27: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __wsum [usertype] csum @@ got unsigned int @@
include/linux/skbuff.h:3489:27: sparse: expected restricted __wsum [usertype] csum
include/linux/skbuff.h:3489:27: sparse: got unsigned int
include/linux/skbuff.h:3489:55: sparse: sparse: restricted __wsum degrades to integer
quoted
include/linux/skbuff.h:3489:55: sparse: sparse: incorrect type in argument 3 (different base types) @@ expected restricted __wsum [usertype] sum @@ got unsigned int @@
include/linux/skbuff.h:3489:55: sparse: expected restricted __wsum [usertype] sum
include/linux/skbuff.h:3489:55: sparse: got unsigned int
include/linux/skbuff.h:3489:29: sparse: sparse: restricted __wsum degrades to integer
include/linux/skbuff.h:3489:27: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __wsum [usertype] csum @@ got unsigned int @@
include/linux/skbuff.h:3489:27: sparse: expected restricted __wsum [usertype] csum
include/linux/skbuff.h:3489:27: sparse: got unsigned int
--
net/core/dev.c:3207:23: sparse: sparse: incorrect type in argument 4 (different base types) @@ expected restricted __wsum [usertype] csum @@ got unsigned int @@
net/core/dev.c:3207:23: sparse: expected restricted __wsum [usertype] csum
net/core/dev.c:3207:23: sparse: got unsigned int
net/core/dev.c:3207:23: sparse: sparse: cast from restricted __wsum
net/core/dev.c: note: in included file (through include/linux/if_ether.h):
include/linux/skbuff.h:3489:55: sparse: sparse: restricted __wsum degrades to integer
quoted
include/linux/skbuff.h:3489:55: sparse: sparse: incorrect type in argument 3 (different base types) @@ expected restricted __wsum [usertype] sum @@ got unsigned int @@
include/linux/skbuff.h:3489:55: sparse: expected restricted __wsum [usertype] sum
include/linux/skbuff.h:3489:55: sparse: got unsigned int
include/linux/skbuff.h:3489:29: sparse: sparse: restricted __wsum degrades to integer
include/linux/skbuff.h:3489:27: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __wsum [usertype] csum @@ got unsigned int @@
include/linux/skbuff.h:3489:27: sparse: expected restricted __wsum [usertype] csum
include/linux/skbuff.h:3489:27: sparse: got unsigned int
net/core/dev.c: note: in included file (through include/net/checksum.h, include/linux/skbuff.h, include/linux/if_ether.h):
arch/arc/include/asm/checksum.h:27:26: sparse: sparse: restricted __wsum degrades to integer
arch/arc/include/asm/checksum.h:27:36: sparse: sparse: restricted __wsum degrades to integer
arch/arc/include/asm/checksum.h:29:11: sparse: sparse: bad assignment (-=) to restricted __wsum
arch/arc/include/asm/checksum.h:30:16: sparse: sparse: restricted __wsum degrades to integer
arch/arc/include/asm/checksum.h:30:18: sparse: sparse: incorrect type in return expression (different base types) @@ expected restricted __sum16 @@ got unsigned int @@
arch/arc/include/asm/checksum.h:30:18: sparse: expected restricted __sum16
arch/arc/include/asm/checksum.h:30:18: sparse: got unsigned int
net/core/dev.c:3712:17: sparse: sparse: context imbalance in '__dev_queue_xmit' - different lock contexts for basic block
net/core/dev.c: note: in included file (through arch/arc/include/asm/irqflags.h, include/linux/irqflags.h, include/linux/rcupdate.h, ...):
arch/arc/include/asm/irqflags-arcv2.h:80:31: sparse: sparse: undefined identifier '__builtin_arc_lr'
arch/arc/include/asm/irqflags-arcv2.h:83:17: sparse: sparse: undefined identifier '__builtin_arc_sr'
--
net/ethernet/eth.c: note: in included file:
include/net/gro.h:177:56: sparse: sparse: restricted __wsum degrades to integer
quoted
include/net/gro.h:177:56: sparse: sparse: incorrect type in argument 3 (different base types) @@ expected restricted __wsum [usertype] sum @@ got unsigned int @@
include/net/gro.h:177:56: sparse: expected restricted __wsum [usertype] sum
include/net/gro.h:177:56: sparse: got unsigned int
include/net/gro.h:176:42: sparse: sparse: restricted __wsum degrades to integer
include/net/gro.h:176:40: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __wsum [usertype] csum @@ got unsigned int @@
include/net/gro.h:176:40: sparse: expected restricted __wsum [usertype] csum
include/net/gro.h:176:40: sparse: got unsigned int
vim +3489 include/linux/skbuff.h
3474
3475 /**
3476 * skb_postpull_rcsum - update checksum for received skb after pull
3477 * @skb: buffer to update
3478 * @start: start of data before pull
3479 * @len: length of data pulled
3480 *
3481 * After doing a pull on a received packet, you need to call this to
3482 * update the CHECKSUM_COMPLETE checksum, or set ip_summed to
3483 * CHECKSUM_NONE so that it can be recomputed from scratch.
3484 */
3485 static inline void skb_postpull_rcsum(struct sk_buff *skb,
3486 const void *start, unsigned int len)
3487 {
3488 if (skb->ip_summed == CHECKSUM_COMPLETE)
include/linux/skbuff.h:3489:55: sparse: sparse: restricted __wsum degrades to integer
include/linux/skbuff.h:3489:55: sparse: sparse: incorrect type in argument 3 (different base types) @@ expected restricted __wsum [usertype] @@ got unsigned int @@
include/linux/skbuff.h:3489:55: sparse: expected restricted __wsum [usertype]
include/linux/skbuff.h:3489:55: sparse: got unsigned int
include/linux/skbuff.h:3489:29: sparse: sparse: restricted __wsum degrades to integer
quoted
include/linux/skbuff.h:3489:27: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __wsum [usertype] csum @@ got unsigned int @@
include/linux/skbuff.h:3489:27: sparse: expected restricted __wsum [usertype] csum
include/linux/skbuff.h:3489:27: sparse: got unsigned int
--
net/core/filter.c:1411:39: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected struct sock_filter const *filter @@ got struct sock_filter [noderef] __user *filter @@
net/core/filter.c:1411:39: sparse: expected struct sock_filter const *filter
net/core/filter.c:1411:39: sparse: got struct sock_filter [noderef] __user *filter
net/core/filter.c:1489:39: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected struct sock_filter const *filter @@ got struct sock_filter [noderef] __user *filter @@
net/core/filter.c:1489:39: sparse: expected struct sock_filter const *filter
net/core/filter.c:1489:39: sparse: got struct sock_filter [noderef] __user *filter
net/core/filter.c:2296:45: sparse: sparse: incorrect type in argument 2 (different base types) @@ expected restricted __be32 [usertype] daddr @@ got unsigned int [usertype] ipv4_nh @@
net/core/filter.c:2296:45: sparse: expected restricted __be32 [usertype] daddr
net/core/filter.c:2296:45: sparse: got unsigned int [usertype] ipv4_nh
net/core/filter.c:10023:31: sparse: sparse: symbol 'cg_skb_verifier_ops' was not declared. Should it be static?
net/core/filter.c:10029:27: sparse: sparse: symbol 'cg_skb_prog_ops' was not declared. Should it be static?
net/core/filter.c:10074:31: sparse: sparse: symbol 'cg_sock_verifier_ops' was not declared. Should it be static?
net/core/filter.c:10080:27: sparse: sparse: symbol 'cg_sock_prog_ops' was not declared. Should it be static?
net/core/filter.c:10083:31: sparse: sparse: symbol 'cg_sock_addr_verifier_ops' was not declared. Should it be static?
net/core/filter.c:10089:27: sparse: sparse: symbol 'cg_sock_addr_prog_ops' was not declared. Should it be static?
net/core/filter.c:246:32: sparse: sparse: cast to restricted __be16
net/core/filter.c:273:32: sparse: sparse: cast to restricted __be32
net/core/filter.c:1910:43: sparse: sparse: incorrect type in argument 2 (different base types) @@ expected restricted __wsum [usertype] diff @@ got unsigned long long [usertype] to @@
net/core/filter.c:1910:43: sparse: expected restricted __wsum [usertype] diff
net/core/filter.c:1910:43: sparse: got unsigned long long [usertype] to
net/core/filter.c:1913:36: sparse: sparse: incorrect type in argument 2 (different base types) @@ expected restricted __be16 [usertype] old @@ got unsigned long long [usertype] from @@
net/core/filter.c:1913:36: sparse: expected restricted __be16 [usertype] old
net/core/filter.c:1913:36: sparse: got unsigned long long [usertype] from
net/core/filter.c:1913:42: sparse: sparse: incorrect type in argument 3 (different base types) @@ expected restricted __be16 [usertype] new @@ got unsigned long long [usertype] to @@
net/core/filter.c:1913:42: sparse: expected restricted __be16 [usertype] new
net/core/filter.c:1913:42: sparse: got unsigned long long [usertype] to
net/core/filter.c:1916:36: sparse: sparse: incorrect type in argument 2 (different base types) @@ expected restricted __be32 [usertype] from @@ got unsigned long long [usertype] from @@
net/core/filter.c:1916:36: sparse: expected restricted __be32 [usertype] from
net/core/filter.c:1916:36: sparse: got unsigned long long [usertype] from
net/core/filter.c:1916:42: sparse: sparse: incorrect type in argument 3 (different base types) @@ expected restricted __be32 [usertype] to @@ got unsigned long long [usertype] to @@
net/core/filter.c:1916:42: sparse: expected restricted __be32 [usertype] to
net/core/filter.c:1916:42: sparse: got unsigned long long [usertype] to
net/core/filter.c:1961:59: sparse: sparse: incorrect type in argument 3 (different base types) @@ expected restricted __wsum [usertype] diff @@ got unsigned long long [usertype] to @@
net/core/filter.c:1961:59: sparse: expected restricted __wsum [usertype] diff
net/core/filter.c:1961:59: sparse: got unsigned long long [usertype] to
net/core/filter.c:1964:52: sparse: sparse: incorrect type in argument 3 (different base types) @@ expected restricted __be16 [usertype] from @@ got unsigned long long [usertype] from @@
net/core/filter.c:1964:52: sparse: expected restricted __be16 [usertype] from
net/core/filter.c:1964:52: sparse: got unsigned long long [usertype] from
net/core/filter.c:1964:58: sparse: sparse: incorrect type in argument 4 (different base types) @@ expected restricted __be16 [usertype] to @@ got unsigned long long [usertype] to @@
net/core/filter.c:1964:58: sparse: expected restricted __be16 [usertype] to
net/core/filter.c:1964:58: sparse: got unsigned long long [usertype] to
net/core/filter.c:1967:52: sparse: sparse: incorrect type in argument 3 (different base types) @@ expected restricted __be32 [usertype] from @@ got unsigned long long [usertype] from @@
net/core/filter.c:1967:52: sparse: expected restricted __be32 [usertype] from
net/core/filter.c:1967:52: sparse: got unsigned long long [usertype] from
net/core/filter.c:1967:58: sparse: sparse: incorrect type in argument 4 (different base types) @@ expected restricted __be32 [usertype] to @@ got unsigned long long [usertype] to @@
net/core/filter.c:1967:58: sparse: expected restricted __be32 [usertype] to
net/core/filter.c:1967:58: sparse: got unsigned long long [usertype] to
net/core/filter.c:2013:28: sparse: sparse: incorrect type in return expression (different base types) @@ expected unsigned long long @@ got restricted __wsum @@
net/core/filter.c:2013:28: sparse: expected unsigned long long
net/core/filter.c:2013:28: sparse: got restricted __wsum
net/core/filter.c:2035:35: sparse: sparse: incorrect type in return expression (different base types) @@ expected unsigned long long @@ got restricted __wsum [usertype] csum @@
net/core/filter.c:2035:35: sparse: expected unsigned long long
net/core/filter.c:2035:35: sparse: got restricted __wsum [usertype] csum
net/core/filter.c:5333:17: sparse: sparse: incorrect type in assignment (different base types) @@ expected unsigned int [usertype] spi @@ got restricted __be32 const [usertype] spi @@
net/core/filter.c:5333:17: sparse: expected unsigned int [usertype] spi
net/core/filter.c:5333:17: sparse: got restricted __be32 const [usertype] spi
net/core/filter.c:5341:33: sparse: sparse: incorrect type in assignment (different base types) @@ expected unsigned int [usertype] remote_ipv4 @@ got restricted __be32 const [usertype] a4 @@
net/core/filter.c:5341:33: sparse: expected unsigned int [usertype] remote_ipv4
net/core/filter.c:5341:33: sparse: got restricted __be32 const [usertype] a4
net/core/filter.c: note: in included file (through include/linux/netlink.h, include/linux/sock_diag.h):
quoted
include/linux/skbuff.h:3489:55: sparse: sparse: restricted __wsum degrades to integer
include/linux/skbuff.h:3489:55: sparse: sparse: incorrect type in argument 3 (different base types) @@ expected restricted __wsum [usertype] @@ got unsigned int @@
include/linux/skbuff.h:3489:55: sparse: expected restricted __wsum [usertype]
include/linux/skbuff.h:3489:55: sparse: got unsigned int
include/linux/skbuff.h:3489:29: sparse: sparse: restricted __wsum degrades to integer
quoted
include/linux/skbuff.h:3489:27: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __wsum [usertype] csum @@ got unsigned int @@
include/linux/skbuff.h:3489:27: sparse: expected restricted __wsum [usertype] csum
include/linux/skbuff.h:3489:27: sparse: got unsigned int
net/core/filter.c: note: in included file (through include/net/ip.h):
include/net/route.h:372:48: sparse: sparse: incorrect type in argument 2 (different base types) @@ expected unsigned int [usertype] key @@ got restricted __be32 [usertype] daddr @@
include/net/route.h:372:48: sparse: expected unsigned int [usertype] key
include/net/route.h:372:48: sparse: got restricted __be32 [usertype] daddr
include/net/route.h:372:48: sparse: sparse: incorrect type in argument 2 (different base types) @@ expected unsigned int [usertype] key @@ got restricted __be32 [usertype] daddr @@
include/net/route.h:372:48: sparse: expected unsigned int [usertype] key
include/net/route.h:372:48: sparse: got restricted __be32 [usertype] daddr
include/net/route.h:372:48: sparse: sparse: incorrect type in argument 2 (different base types) @@ expected unsigned int [usertype] key @@ got restricted __be32 [usertype] daddr @@
include/net/route.h:372:48: sparse: expected unsigned int [usertype] key
include/net/route.h:372:48: sparse: got restricted __be32 [usertype] daddr
net/core/filter.c: note: in included file (through include/linux/netlink.h, include/linux/sock_diag.h):
quoted
include/linux/skbuff.h:3489:55: sparse: sparse: restricted __wsum degrades to integer
include/linux/skbuff.h:3489:55: sparse: sparse: incorrect type in argument 3 (different base types) @@ expected restricted __wsum [usertype] @@ got unsigned int @@
include/linux/skbuff.h:3489:55: sparse: expected restricted __wsum [usertype]
include/linux/skbuff.h:3489:55: sparse: got unsigned int
include/linux/skbuff.h:3489:29: sparse: sparse: restricted __wsum degrades to integer
quoted
include/linux/skbuff.h:3489:27: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __wsum [usertype] csum @@ got unsigned int @@
include/linux/skbuff.h:3489:27: sparse: expected restricted __wsum [usertype] csum
include/linux/skbuff.h:3489:27: sparse: got unsigned int
--
net/core/dev.c:3207:23: sparse: sparse: incorrect type in argument 4 (different base types) @@ expected restricted __wsum [usertype] csum @@ got unsigned int @@
net/core/dev.c:3207:23: sparse: expected restricted __wsum [usertype] csum
net/core/dev.c:3207:23: sparse: got unsigned int
net/core/dev.c:3207:23: sparse: sparse: cast from restricted __wsum
net/core/dev.c:3207:23: sparse: sparse: incorrect type in argument 4 (different base types) @@ expected restricted __wsum [usertype] csum @@ got unsigned int @@
net/core/dev.c:3207:23: sparse: expected restricted __wsum [usertype] csum
net/core/dev.c:3207:23: sparse: got unsigned int
net/core/dev.c:3207:23: sparse: sparse: incorrect type in argument 1 (different base types) @@ expected unsigned int [usertype] val @@ got restricted __wsum @@
net/core/dev.c:3207:23: sparse: expected unsigned int [usertype] val
net/core/dev.c:3207:23: sparse: got restricted __wsum
net/core/dev.c:3207:23: sparse: sparse: incorrect type in argument 4 (different base types) @@ expected restricted __wsum [usertype] csum @@ got unsigned int @@
net/core/dev.c:3207:23: sparse: expected restricted __wsum [usertype] csum
net/core/dev.c:3207:23: sparse: got unsigned int
net/core/dev.c:3207:23: sparse: sparse: cast from restricted __wsum
net/core/dev.c:3207:23: sparse: sparse: incorrect type in argument 4 (different base types) @@ expected restricted __wsum [usertype] csum @@ got unsigned int @@
net/core/dev.c:3207:23: sparse: expected restricted __wsum [usertype] csum
net/core/dev.c:3207:23: sparse: got unsigned int
net/core/dev.c:3207:23: sparse: sparse: cast from restricted __wsum
net/core/dev.c:3207:23: sparse: sparse: incorrect type in argument 4 (different base types) @@ expected restricted __wsum [usertype] csum @@ got unsigned int @@
net/core/dev.c:3207:23: sparse: expected restricted __wsum [usertype] csum
net/core/dev.c:3207:23: sparse: got unsigned int
net/core/dev.c:3207:23: sparse: sparse: cast from restricted __wsum
net/core/dev.c:3207:23: sparse: sparse: incorrect type in argument 4 (different base types) @@ expected restricted __wsum [usertype] csum @@ got unsigned int @@
net/core/dev.c:3207:23: sparse: expected restricted __wsum [usertype] csum
net/core/dev.c:3207:23: sparse: got unsigned int
net/core/dev.c:3207:23: sparse: sparse: cast from restricted __wsum
net/core/dev.c: note: in included file (through include/linux/if_ether.h):
quoted
include/linux/skbuff.h:3489:55: sparse: sparse: restricted __wsum degrades to integer
include/linux/skbuff.h:3489:55: sparse: sparse: incorrect type in argument 3 (different base types) @@ expected restricted __wsum [usertype] @@ got unsigned int @@
include/linux/skbuff.h:3489:55: sparse: expected restricted __wsum [usertype]
include/linux/skbuff.h:3489:55: sparse: got unsigned int
include/linux/skbuff.h:3489:29: sparse: sparse: restricted __wsum degrades to integer
quoted
include/linux/skbuff.h:3489:27: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __wsum [usertype] csum @@ got unsigned int @@
include/linux/skbuff.h:3489:27: sparse: expected restricted __wsum [usertype] csum
include/linux/skbuff.h:3489:27: sparse: got unsigned int
net/core/dev.c:3712:17: sparse: sparse: context imbalance in '__dev_queue_xmit' - different lock contexts for basic block
net/core/dev.c:4918:17: sparse: sparse: context imbalance in 'net_tx_action' - different lock contexts for basic block
--
net/ipv4/udp_offload.c:139:60: sparse: sparse: incorrect type in argument 2 (different base types) @@ expected restricted __wsum [usertype] res @@ got fouled restricted __sum16 @@
net/ipv4/udp_offload.c:139:60: sparse: expected restricted __wsum [usertype] res
net/ipv4/udp_offload.c:139:60: sparse: got fouled restricted __sum16
net/ipv4/udp_offload.c:330:49: sparse: sparse: incorrect type in argument 2 (different base types) @@ expected restricted __wsum [usertype] res @@ got fouled restricted __sum16 @@
net/ipv4/udp_offload.c:330:49: sparse: expected restricted __wsum [usertype] res
net/ipv4/udp_offload.c:330:49: sparse: got fouled restricted __sum16
net/ipv4/udp_offload.c:332:60: sparse: sparse: incorrect type in argument 2 (different base types) @@ expected restricted __wsum [usertype] res @@ got fouled restricted __sum16 @@
net/ipv4/udp_offload.c:332:60: sparse: expected restricted __wsum [usertype] res
net/ipv4/udp_offload.c:332:60: sparse: got fouled restricted __sum16
net/ipv4/udp_offload.c:348:41: sparse: sparse: incorrect type in argument 2 (different base types) @@ expected restricted __wsum [usertype] res @@ got fouled restricted __sum16 @@
net/ipv4/udp_offload.c:348:41: sparse: expected restricted __wsum [usertype] res
net/ipv4/udp_offload.c:348:41: sparse: got fouled restricted __sum16
net/ipv4/udp_offload.c:350:52: sparse: sparse: incorrect type in argument 2 (different base types) @@ expected restricted __wsum [usertype] res @@ got fouled restricted __sum16 @@
net/ipv4/udp_offload.c:350:52: sparse: expected restricted __wsum [usertype] res
net/ipv4/udp_offload.c:350:52: sparse: got fouled restricted __sum16
net/ipv4/udp_offload.c: note: in included file:
quoted
include/net/gro.h:177:56: sparse: sparse: restricted __wsum degrades to integer
include/net/gro.h:177:56: sparse: sparse: incorrect type in argument 3 (different base types) @@ expected restricted __wsum [usertype] @@ got unsigned int @@
include/net/gro.h:177:56: sparse: expected restricted __wsum [usertype]
include/net/gro.h:177:56: sparse: got unsigned int
include/net/gro.h:176:42: sparse: sparse: restricted __wsum degrades to integer
quoted
include/net/gro.h:176:40: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __wsum [usertype] csum @@ got unsigned int @@
include/linux/skbuff.h:3489:55: sparse: sparse: restricted __wsum degrades to integer
include/linux/skbuff.h:3489:55: sparse: sparse: incorrect type in argument 3 (different base types) @@ expected restricted __wsum [usertype] @@ got unsigned int @@
include/linux/skbuff.h:3489:55: sparse: expected restricted __wsum [usertype]
include/linux/skbuff.h:3489:55: sparse: got unsigned int
include/linux/skbuff.h:3489:29: sparse: sparse: restricted __wsum degrades to integer
quoted
include/linux/skbuff.h:3489:27: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __wsum [usertype] csum @@ got unsigned int @@
include/linux/skbuff.h:3489:27: sparse: expected restricted __wsum [usertype] csum
include/linux/skbuff.h:3489:27: sparse: got unsigned int
net/ipv4/fou.c: note: in included file:
quoted
include/net/gro.h:177:56: sparse: sparse: restricted __wsum degrades to integer
include/net/gro.h:177:56: sparse: sparse: incorrect type in argument 3 (different base types) @@ expected restricted __wsum [usertype] @@ got unsigned int @@
include/net/gro.h:177:56: sparse: expected restricted __wsum [usertype]
include/net/gro.h:177:56: sparse: got unsigned int
include/net/gro.h:176:42: sparse: sparse: restricted __wsum degrades to integer
quoted
include/net/gro.h:176:40: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __wsum [usertype] csum @@ got unsigned int @@
include/net/gro.h:176:40: sparse: expected restricted __wsum [usertype] csum
include/net/gro.h:176:40: sparse: got unsigned int
--
net/ipv4/ip_tunnel.c: note: in included file:
quoted
include/linux/skbuff.h:3489:55: sparse: sparse: restricted __wsum degrades to integer
include/linux/skbuff.h:3489:55: sparse: sparse: incorrect type in argument 3 (different base types) @@ expected restricted __wsum [usertype] @@ got unsigned int @@
include/linux/skbuff.h:3489:55: sparse: expected restricted __wsum [usertype]
include/linux/skbuff.h:3489:55: sparse: got unsigned int
include/linux/skbuff.h:3489:29: sparse: sparse: restricted __wsum degrades to integer
quoted
include/linux/skbuff.h:3489:27: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __wsum [usertype] csum @@ got unsigned int @@
include/linux/skbuff.h:3489:27: sparse: expected restricted __wsum [usertype] csum
include/linux/skbuff.h:3489:27: sparse: got unsigned int
vim +3489 include/linux/skbuff.h
3474
3475 /**
3476 * skb_postpull_rcsum - update checksum for received skb after pull
3477 * @skb: buffer to update
3478 * @start: start of data before pull
3479 * @len: length of data pulled
3480 *
3481 * After doing a pull on a received packet, you need to call this to
3482 * update the CHECKSUM_COMPLETE checksum, or set ip_summed to
3483 * CHECKSUM_NONE so that it can be recomputed from scratch.
3484 */
3485 static inline void skb_postpull_rcsum(struct sk_buff *skb,
3486 const void *start, unsigned int len)
3487 {
3488 if (skb->ip_summed == CHECKSUM_COMPLETE)
I was thinking that the expression also requires some comments.
So maybe put a #define / static inline in checksum.h like:
/* Subract the checksum of a buffer.
* The domain is __wsum is [1..~0u] (ie excludes zero)
* so ~csum_partial() cannot be used.
* The two's compliment gives the right answer provided the old 'csum'
* isn't zero - which it shouldn't be. */
#define csum_partial_sub(buf, len, csum) (-csum_partial(buf, len, -(csum))
and then add the annotations there to keep sparse happy there.
will sparse accept '1 + ~csum' ? The compiler should use negate for it.
It actually makes it slightly more obvious why the code is right.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
I was thinking that the expression also requires some comments.
So maybe put a #define / static inline in checksum.h like:
/* Subract the checksum of a buffer.
* The domain is __wsum is [1..~0u] (ie excludes zero)
* so ~csum_partial() cannot be used.
* The two's compliment gives the right answer provided the old 'csum'
* isn't zero - which it shouldn't be. */
#define csum_partial_sub(buf, len, csum) (-csum_partial(buf, len, -(csum))
and then add the annotations there to keep sparse happy there.
will sparse accept '1 + ~csum' ? The compiler should use negate for it.
It actually makes it slightly more obvious why the code is right.
Sparse is not happy with 1 + ~csum,
So we unfortunately would need something ugly like
(__force __wsum)(1 + ~(__force u32)csum)
Which most readers of this code will not find obvious.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
I was thinking that the expression also requires some comments.
So maybe put a #define / static inline in checksum.h like:
/* Subract the checksum of a buffer.
* The domain is __wsum is [1..~0u] (ie excludes zero)
* so ~csum_partial() cannot be used.
* The two's compliment gives the right answer provided the old 'csum'
* isn't zero - which it shouldn't be. */
#define csum_partial_sub(buf, len, csum) (-csum_partial(buf, len, -(csum))
and then add the annotations there to keep sparse happy there.
will sparse accept '1 + ~csum' ? The compiler should use negate for it.
It actually makes it slightly more obvious why the code is right.
Sparse is not happy with 1 + ~csum,
So we unfortunately would need something ugly like
(__force __wsum)(1 + ~(__force u32)csum)
Which most readers of this code will not find obvious.
Sparse really isn't helping here at all.
Perhaps there should be a way of marking a function so that
sparse just ignores it.
I also rather dislike that the compiler sees the (u32)csum cast.
The sparse annotation should really be either __sparse(u32)csum
or __sparse(u32, csum) to that compiler type checking still applies.
Perhaps adding:
#define WSUM(val) (__force __wsum)(val)
#define U32(csum) (__force u32)(csum)
before the 'static inlines' in checksum.h and #undeffing them at the end.
Then all the functions could be made a little easier to read.
return WSUM(1 + ~U32(csum_partial(buf, len, WSUM(1 + ~U32(csum)));
is a bit better than the casts - still not nice.
David
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
I was thinking that the expression also requires some comments.
So maybe put a #define / static inline in checksum.h like:
/* Subract the checksum of a buffer.
* The domain is __wsum is [1..~0u] (ie excludes zero)
* so ~csum_partial() cannot be used.
* The two's compliment gives the right answer provided the old 'csum'
* isn't zero - which it shouldn't be. */
#define csum_partial_sub(buf, len, csum) (-csum_partial(buf, len, -(csum))
and then add the annotations there to keep sparse happy there.
will sparse accept '1 + ~csum' ? The compiler should use negate for it.
It actually makes it slightly more obvious why the code is right.
Sparse is not happy with 1 + ~csum,
So we unfortunately would need something ugly like
(__force __wsum)(1 + ~(__force u32)csum)
Which most readers of this code will not find obvious.
Sparse really isn't helping here at all.
Perhaps there should be a way of marking a function so that
sparse just ignores it.
I also rather dislike that the compiler sees the (u32)csum cast.
The sparse annotation should really be either __sparse(u32)csum
or __sparse(u32, csum) to that compiler type checking still applies.
Perhaps adding:
#define WSUM(val) (__force __wsum)(val)
#define U32(csum) (__force u32)(csum)
before the 'static inlines' in checksum.h and #undeffing them at the end.
Then all the functions could be made a little easier to read.
return WSUM(1 + ~U32(csum_partial(buf, len, WSUM(1 + ~U32(csum)));
is a bit better than the casts - still not nice.
Thinking again...
#ifdef __sparse
/* Skip offsetting to save 4 casts. */
return ~csum_partial(buf, len, ~csum);
#else
/* Offset by one so that zero is never returned. */
return 1 + ~csum_partial(bufg, len, 1 + ~csum);
#endif
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)