Skip to contentSkip to conversation

net: fix recent csum changes

PATCH Superseded Eric Dumazet 4 participants 8 messages Dec 3, 2021 – Dec 4, 2021

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: fix recent csum changes

From: Eric Dumazet <[email protected]>

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()")
Cc David Lebrun <[email protected]>
---
 include/linux/skbuff.h | 2 +-
 include/net/gro.h      | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
include/linux/skbuff.h +1 -1
index eae4bd3237a41cc1b60b44c91fbfe21dfdd8f117..2bbcdaf99ed3df739ddfd2de4be747262226d4b9 100644
@@ -3486,7 +3486,7 @@ static inline void skb_postpull_rcsum(struct sk_buff *skb,
 				      const void *start, unsigned int len)
 {
 	if (skb->ip_summed == CHECKSUM_COMPLETE)
-		skb->csum = ~csum_partial(start, len, ~skb->csum);
+		skb->csum = -csum_partial(start, len, -skb->csum);
 	else if (skb->ip_summed == CHECKSUM_PARTIAL &&
 		 skb_checksum_start_offset(skb) < 0)
 		skb->ip_summed = CHECKSUM_NONE;
include/net/gro.h +2 -2
index b1139fca7c435ca0c353c4ed17628dd7f3df4401..4529c4c6f3ca4ac23da569b0bc0e00e3c9dcd765 100644
@@ -173,8 +173,8 @@ static inline void skb_gro_postpull_rcsum(struct sk_buff *skb,
 					const void *start, unsigned int len)
 {
 	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
Signature · 1 line
2.34.1.400.ga245620fadb-goog
#1 lore raw
I love your patch! Perhaps something to improve:

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(a)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

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

>> 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
>> 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
>> 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

>> 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
>> 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

>> 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

>> 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)

> 3489			skb->csum = -csum_partial(start, len, -skb->csum);

3490 else if (skb->ip_summed == CHECKSUM_PARTIAL &&
3491 skb_checksum_start_offset(skb) < 0)
3492 skb->ip_summed = CHECKSUM_NONE;
3493 }
3494

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

#2 lore raw
In reply to Eric Dumazet
I love your patch! Perhaps something to improve:

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: parisc-randconfig-s031-20211203 (https://download.01.org/0day-ci/archive/20211204/202112041104.gPgP3Z6U-lkp(a)intel.com/config)
compiler: hppa64-linux-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=parisc SHELL=/bin/bash net/core/ net/ipv4/

If you fix the issue, kindly add following tag as appropriate

sparse warnings: (new ones prefixed by >>)
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
>> 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
>> 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
>> 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
>> 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
>> 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
>> 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):

>> 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
>> 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):
>> 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
>> 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):

>> 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
>> 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:

>> 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
>> 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
>> 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
>> 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/gre_offload.c: note: in included file:

>> 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
>> 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/fou.c: note: in included file:

>> 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
>> 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
>> 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
>> 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
>> 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
>> 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:
>> 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
>> 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:

>> 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
>> 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)

> 3489			skb->csum = -csum_partial(start, len, -skb->csum);

3490 else if (skb->ip_summed == CHECKSUM_PARTIAL &&
3491 skb_checksum_start_offset(skb) < 0)
3492 skb->ip_summed = CHECKSUM_NONE;
3493 }
3494

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

#3 lore raw
Quoted 24 lines · kernel test robot

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: parisc-randconfig-s031-20211203 (https://download.01.org/0day-ci/archive/20211204/202112041104.gPgP3Z6U-lkp(a)intel.com/config)
compiler: hppa64-linux-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=parisc SHELL=/bin/bash net/core/ net/ipv4/

Quoted 3 lines

If you fix the issue, kindly add following tag as appropriate

Yes, keeping sparse happy with these checksum is not easy.

I will add and use this helper, unless someone has a better idea.

include/net/checksum.h +0 -0
index 5b96d5bd6e54532a7a82511ff5d7d4c6f18982d5..5218041e5c8f93cd369a2a3a46add3e6a5e41af7

100644

include/net/checksum.h +0 -0
@@ -180,4 +180,8 @@ static inline void remcsum_unadjust(__sum16 *psum,

__wsum delta)

        *psum = csum_fold(csum_sub(delta, (__force __wsum)*psum));

}

+static inline __wsum wsum_negate(__wsum val)
+{
+ return (__force __wsum)-((__force u32)val);
+}
#endif

#4 lore raw

From: Eric Dumazet

Quoted 5 lines

Sent: 04 December 2021 04:41

Quoted 2 lines · kernel test robot

I love your patch! Perhaps something to improve:

...

Quoted 19 lines

Yes, keeping sparse happy with these checksum is not easy.

I will add and use this helper, unless someone has a better idea.

include/net/checksum.h +0 -0
index 5b96d5bd6e54532a7a82511ff5d7d4c6f18982d5..5218041e5c8f93cd369a2a3a46add3e6a5e41af7

100644

include/net/checksum.h +4 -0
@@ -180,4 +180,8 @@ static inline void remcsum_unadjust(__sum16 *psum,
 __wsum delta)
        *psum = csum_fold(csum_sub(delta, (__force __wsum)*psum));
 }
 
+static inline __wsum wsum_negate(__wsum val)
+{
+       return (__force __wsum)-((__force u32)val);
+}
Quoted 1 line

#endif

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)

#5 lore raw
Quoted 39 lines · David Laight

From: Eric Dumazet

Quoted 5 lines

Sent: 04 December 2021 04:41

Quoted 2 lines · kernel test robot

I love your patch! Perhaps something to improve:

...

Quoted 19 lines

Yes, keeping sparse happy with these checksum is not easy.

I will add and use this helper, unless someone has a better idea.

include/net/checksum.h +0 -0
index 5b96d5bd6e54532a7a82511ff5d7d4c6f18982d5..5218041e5c8f93cd369a2a3a46add3e6a5e41af7

100644

include/net/checksum.h +4 -0
@@ -180,4 +180,8 @@ static inline void remcsum_unadjust(__sum16 *psum,
 __wsum delta)
        *psum = csum_fold(csum_sub(delta, (__force __wsum)*psum));
 }
 
+static inline __wsum wsum_negate(__wsum val)
+{
+       return (__force __wsum)-((__force u32)val);
+}
Quoted 1 line

#endif

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))

Quoted 4 lines

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.

Quoted 6 lines

David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)

#6 lore raw

From: Eric Dumazet

Quoted 47 lines

Sent: 04 December 2021 18:34

Quoted 39 lines · David Laight

From: Eric Dumazet

Quoted 5 lines

Sent: 04 December 2021 04:41

Quoted 2 lines · kernel test robot

I love your patch! Perhaps something to improve:

...

Quoted 19 lines

Yes, keeping sparse happy with these checksum is not easy.

I will add and use this helper, unless someone has a better idea.

include/net/checksum.h +0 -0
index 5b96d5bd6e54532a7a82511ff5d7d4c6f18982d5..5218041e5c8f93cd369a2a3a46add3e6a5e41af7

100644

include/net/checksum.h +4 -0
@@ -180,4 +180,8 @@ static inline void remcsum_unadjust(__sum16 *psum,
 __wsum delta)
        *psum = csum_fold(csum_sub(delta, (__force __wsum)*psum));
 }
 
+static inline __wsum wsum_negate(__wsum val)
+{
+       return (__force __wsum)-((__force u32)val);
+}
Quoted 1 line

#endif

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))

Quoted 4 lines

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.

Quoted 7 lines

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)

#7 lore raw

From: David Laight <[email protected]>

Quoted 72 lines

Sent: 04 December 2021 19:03

From: Eric Dumazet

Quoted 47 lines

Sent: 04 December 2021 18:34

Quoted 39 lines · David Laight

From: Eric Dumazet

Quoted 5 lines

Sent: 04 December 2021 04:41

Quoted 2 lines · kernel test robot

I love your patch! Perhaps something to improve:

...

Quoted 19 lines

Yes, keeping sparse happy with these checksum is not easy.

I will add and use this helper, unless someone has a better idea.

include/net/checksum.h +0 -0
index 5b96d5bd6e54532a7a82511ff5d7d4c6f18982d5..5218041e5c8f93cd369a2a3a46add3e6a5e41af7

100644

include/net/checksum.h +4 -0
@@ -180,4 +180,8 @@ static inline void remcsum_unadjust(__sum16 *psum,
 __wsum delta)
        *psum = csum_fold(csum_sub(delta, (__force __wsum)*psum));
 }
 
+static inline __wsum wsum_negate(__wsum val)
+{
+       return (__force __wsum)-((__force u32)val);
+}
Quoted 1 line

#endif

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))

Quoted 4 lines

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.

Quoted 7 lines

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.

Quoted 3 lines
	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)