lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <202111180110.0nxJC8xc-lkp@intel.com>
Date:   Thu, 18 Nov 2021 01:31:18 +0800
From:   kernel test robot <lkp@...el.com>
To:     Arnd Bergmann <arnd@...db.de>
Cc:     kbuild-all@...ts.01.org, linux-kernel@...r.kernel.org
Subject: net/netfilter/nft_exthdr.c:264:33: sparse: sparse: incorrect type in
 assignment (different base types)

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   8ab774587903771821b59471cc723bba6d893942
commit: 803f4e1eab7a8938ba3a3c30dd4eb5e9eeef5e63 asm-generic: simplify asm/unaligned.h
date:   6 months ago
config: i386-randconfig-s031-20211116 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce:
        # apt-get install sparse
        # sparse version: v0.6.4-dirty
        # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=803f4e1eab7a8938ba3a3c30dd4eb5e9eeef5e63
        git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
        git fetch --no-tags linus master
        git checkout 803f4e1eab7a8938ba3a3c30dd4eb5e9eeef5e63
        # save the attached .config to linux build tree
        make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=i386 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@...el.com>


sparse warnings: (new ones prefixed by >>)
>> net/netfilter/nft_exthdr.c:264:33: sparse: sparse: incorrect type in assignment (different base types) @@     expected restricted __be16 [usertype] v16 @@     got unsigned short x @@
   net/netfilter/nft_exthdr.c:264:33: sparse:     expected restricted __be16 [usertype] v16
   net/netfilter/nft_exthdr.c:264:33: sparse:     got unsigned short x
>> net/netfilter/nft_exthdr.c:279:25: sparse: sparse: incorrect type in assignment (different base types) @@     expected unsigned short x @@     got restricted __be16 [assigned] [usertype] v16 @@
   net/netfilter/nft_exthdr.c:279:25: sparse:     expected unsigned short x
   net/netfilter/nft_exthdr.c:279:25: sparse:     got restricted __be16 [assigned] [usertype] v16
   net/netfilter/nft_exthdr.c:284:33: sparse: sparse: incorrect type in assignment (different base types) @@     expected restricted __be32 [assigned] [usertype] v32 @@     got unsigned int @@
   net/netfilter/nft_exthdr.c:284:33: sparse:     expected restricted __be32 [assigned] [usertype] v32
   net/netfilter/nft_exthdr.c:284:33: sparse:     got unsigned int
>> net/netfilter/nft_exthdr.c:285:33: sparse: sparse: incorrect type in assignment (different base types) @@     expected restricted __be32 [usertype] v32 @@     got unsigned int x @@
   net/netfilter/nft_exthdr.c:285:33: sparse:     expected restricted __be32 [usertype] v32
   net/netfilter/nft_exthdr.c:285:33: sparse:     got unsigned int x
>> net/netfilter/nft_exthdr.c:290:25: sparse: sparse: incorrect type in assignment (different base types) @@     expected unsigned int x @@     got restricted __be32 [assigned] [usertype] v32 @@
   net/netfilter/nft_exthdr.c:290:25: sparse:     expected unsigned int x
   net/netfilter/nft_exthdr.c:290:25: sparse:     got restricted __be32 [assigned] [usertype] v32

vim +264 net/netfilter/nft_exthdr.c

935b7f64301887 Manuel Messner     2017-02-07  221  
99d1712bc41c7c Florian Westphal   2017-08-08  222  static void nft_exthdr_tcp_set_eval(const struct nft_expr *expr,
99d1712bc41c7c Florian Westphal   2017-08-08  223  				    struct nft_regs *regs,
99d1712bc41c7c Florian Westphal   2017-08-08  224  				    const struct nft_pktinfo *pkt)
99d1712bc41c7c Florian Westphal   2017-08-08  225  {
99d1712bc41c7c Florian Westphal   2017-08-08  226  	u8 buff[sizeof(struct tcphdr) + MAX_TCP_OPTION_SPACE];
99d1712bc41c7c Florian Westphal   2017-08-08  227  	struct nft_exthdr *priv = nft_expr_priv(expr);
99d1712bc41c7c Florian Westphal   2017-08-08  228  	unsigned int i, optl, tcphdr_len, offset;
99d1712bc41c7c Florian Westphal   2017-08-08  229  	struct tcphdr *tcph;
99d1712bc41c7c Florian Westphal   2017-08-08  230  	u8 *opt;
99d1712bc41c7c Florian Westphal   2017-08-08  231  
99d1712bc41c7c Florian Westphal   2017-08-08  232  	tcph = nft_tcp_header_pointer(pkt, sizeof(buff), buff, &tcphdr_len);
99d1712bc41c7c Florian Westphal   2017-08-08  233  	if (!tcph)
99d1712bc41c7c Florian Westphal   2017-08-08  234  		return;
99d1712bc41c7c Florian Westphal   2017-08-08  235  
99d1712bc41c7c Florian Westphal   2017-08-08  236  	opt = (u8 *)tcph;
99d1712bc41c7c Florian Westphal   2017-08-08  237  	for (i = sizeof(*tcph); i < tcphdr_len - 1; i += optl) {
99d1712bc41c7c Florian Westphal   2017-08-08  238  		union {
99d1712bc41c7c Florian Westphal   2017-08-08  239  			__be16 v16;
99d1712bc41c7c Florian Westphal   2017-08-08  240  			__be32 v32;
99d1712bc41c7c Florian Westphal   2017-08-08  241  		} old, new;
99d1712bc41c7c Florian Westphal   2017-08-08  242  
99d1712bc41c7c Florian Westphal   2017-08-08  243  		optl = optlen(opt, i);
99d1712bc41c7c Florian Westphal   2017-08-08  244  
99d1712bc41c7c Florian Westphal   2017-08-08  245  		if (priv->type != opt[i])
99d1712bc41c7c Florian Westphal   2017-08-08  246  			continue;
99d1712bc41c7c Florian Westphal   2017-08-08  247  
99d1712bc41c7c Florian Westphal   2017-08-08  248  		if (i + optl > tcphdr_len || priv->len + priv->offset > optl)
99d1712bc41c7c Florian Westphal   2017-08-08  249  			return;
99d1712bc41c7c Florian Westphal   2017-08-08  250  
7418ee4c8810e4 Florian Westphal   2019-05-23  251  		if (skb_ensure_writable(pkt->skb,
7418ee4c8810e4 Florian Westphal   2019-05-23  252  					pkt->xt.thoff + i + priv->len))
99d1712bc41c7c Florian Westphal   2017-08-08  253  			return;
99d1712bc41c7c Florian Westphal   2017-08-08  254  
99d1712bc41c7c Florian Westphal   2017-08-08  255  		tcph = nft_tcp_header_pointer(pkt, sizeof(buff), buff,
99d1712bc41c7c Florian Westphal   2017-08-08  256  					      &tcphdr_len);
99d1712bc41c7c Florian Westphal   2017-08-08  257  		if (!tcph)
99d1712bc41c7c Florian Westphal   2017-08-08  258  			return;
99d1712bc41c7c Florian Westphal   2017-08-08  259  
99d1712bc41c7c Florian Westphal   2017-08-08  260  		offset = i + priv->offset;
99d1712bc41c7c Florian Westphal   2017-08-08  261  
99d1712bc41c7c Florian Westphal   2017-08-08  262  		switch (priv->len) {
99d1712bc41c7c Florian Westphal   2017-08-08  263  		case 2:
99d1712bc41c7c Florian Westphal   2017-08-08 @264  			old.v16 = get_unaligned((u16 *)(opt + offset));
2e34328b396a69 Sergey Marinkevich 2020-03-29  265  			new.v16 = (__force __be16)nft_reg_load16(
2e34328b396a69 Sergey Marinkevich 2020-03-29  266  				&regs->data[priv->sreg]);
99d1712bc41c7c Florian Westphal   2017-08-08  267  
99d1712bc41c7c Florian Westphal   2017-08-08  268  			switch (priv->type) {
99d1712bc41c7c Florian Westphal   2017-08-08  269  			case TCPOPT_MSS:
99d1712bc41c7c Florian Westphal   2017-08-08  270  				/* increase can cause connection to stall */
99d1712bc41c7c Florian Westphal   2017-08-08  271  				if (ntohs(old.v16) <= ntohs(new.v16))
99d1712bc41c7c Florian Westphal   2017-08-08  272  					return;
99d1712bc41c7c Florian Westphal   2017-08-08  273  			break;
99d1712bc41c7c Florian Westphal   2017-08-08  274  			}
99d1712bc41c7c Florian Westphal   2017-08-08  275  
99d1712bc41c7c Florian Westphal   2017-08-08  276  			if (old.v16 == new.v16)
99d1712bc41c7c Florian Westphal   2017-08-08  277  				return;
99d1712bc41c7c Florian Westphal   2017-08-08  278  
99d1712bc41c7c Florian Westphal   2017-08-08 @279  			put_unaligned(new.v16, (u16*)(opt + offset));
99d1712bc41c7c Florian Westphal   2017-08-08  280  			inet_proto_csum_replace2(&tcph->check, pkt->skb,
99d1712bc41c7c Florian Westphal   2017-08-08  281  						 old.v16, new.v16, false);
99d1712bc41c7c Florian Westphal   2017-08-08  282  			break;
99d1712bc41c7c Florian Westphal   2017-08-08  283  		case 4:
2e34328b396a69 Sergey Marinkevich 2020-03-29  284  			new.v32 = regs->data[priv->sreg];
99d1712bc41c7c Florian Westphal   2017-08-08 @285  			old.v32 = get_unaligned((u32 *)(opt + offset));
99d1712bc41c7c Florian Westphal   2017-08-08  286  
99d1712bc41c7c Florian Westphal   2017-08-08  287  			if (old.v32 == new.v32)
99d1712bc41c7c Florian Westphal   2017-08-08  288  				return;
99d1712bc41c7c Florian Westphal   2017-08-08  289  
99d1712bc41c7c Florian Westphal   2017-08-08 @290  			put_unaligned(new.v32, (u32*)(opt + offset));
99d1712bc41c7c Florian Westphal   2017-08-08  291  			inet_proto_csum_replace4(&tcph->check, pkt->skb,
99d1712bc41c7c Florian Westphal   2017-08-08  292  						 old.v32, new.v32, false);
99d1712bc41c7c Florian Westphal   2017-08-08  293  			break;
99d1712bc41c7c Florian Westphal   2017-08-08  294  		default:
99d1712bc41c7c Florian Westphal   2017-08-08  295  			WARN_ON_ONCE(1);
99d1712bc41c7c Florian Westphal   2017-08-08  296  			break;
99d1712bc41c7c Florian Westphal   2017-08-08  297  		}
99d1712bc41c7c Florian Westphal   2017-08-08  298  
99d1712bc41c7c Florian Westphal   2017-08-08  299  		return;
99d1712bc41c7c Florian Westphal   2017-08-08  300  	}
99d1712bc41c7c Florian Westphal   2017-08-08  301  }
99d1712bc41c7c Florian Westphal   2017-08-08  302  

:::::: The code at line 264 was first introduced by commit
:::::: 99d1712bc41c7c9a5a473c104a4ad15427757b22 netfilter: exthdr: tcp option set support

:::::: TO: Florian Westphal <fw@...len.de>
:::::: CC: Pablo Neira Ayuso <pablo@...filter.org>

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

Download attachment ".config.gz" of type "application/gzip" (36459 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ