All of lore.kernel.org
 help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: kbuild-all@lists.01.org
Subject: [sashal-linux-stable:queue-4.9 13/24] net/ipv6/datagram.c:246:19: sparse: sparse: incorrect type in assignment (different base types)
Date: Fri, 08 Jan 2021 22:51:36 +0800	[thread overview]
Message-ID: <202101082232.HwmvPCJu-lkp@intel.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 6305 bytes --]

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/sashal/linux-stable.git queue-4.9
head:   07b4f6a206099b595f61c1dbaa951ef38ca7bb36
commit: b7893488b12bf8550004d996c65f106916e86c3a [13/24] net: ipv6: keep sk status consistent after datagram connect failure
config: i386-randconfig-s001-20210108 (attached as .config)
compiler: gcc-7 (Ubuntu 7.5.0-6ubuntu2) 7.5.0
reproduce:
        # apt-get install sparse
        # sparse version: v0.6.3-208-g46a52ca4-dirty
        # https://git.kernel.org/pub/scm/linux/kernel/git/sashal/linux-stable.git/commit/?id=b7893488b12bf8550004d996c65f106916e86c3a
        git remote add sashal-linux-stable https://git.kernel.org/pub/scm/linux/kernel/git/sashal/linux-stable.git
        git fetch --no-tags sashal-linux-stable queue-4.9
        git checkout b7893488b12bf8550004d996c65f106916e86c3a
        # 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@intel.com>


"sparse warnings: (new ones prefixed by >>)"
>> net/ipv6/datagram.c:246:19: sparse: sparse: incorrect type in assignment (different base types) @@     expected restricted __be32 [usertype] old_dport @@     got restricted __be16 [usertype] skc_dport @@
   net/ipv6/datagram.c:246:19: sparse:     expected restricted __be32 [usertype] old_dport
   net/ipv6/datagram.c:246:19: sparse:     got restricted __be16 [usertype] skc_dport
>> net/ipv6/datagram.c:264:34: sparse: sparse: incorrect type in assignment (different base types) @@     expected restricted __be16 [usertype] skc_dport @@     got restricted __be32 [usertype] old_dport @@
   net/ipv6/datagram.c:264:34: sparse:     expected restricted __be16 [usertype] skc_dport
   net/ipv6/datagram.c:264:34: sparse:     got restricted __be32 [usertype] old_dport

vim +246 net/ipv6/datagram.c

   141	
   142	int __ip6_datagram_connect(struct sock *sk, struct sockaddr *uaddr,
   143				   int addr_len)
   144	{
   145		struct sockaddr_in6	*usin = (struct sockaddr_in6 *) uaddr;
   146		struct inet_sock	*inet = inet_sk(sk);
   147		struct ipv6_pinfo	*np = inet6_sk(sk);
   148		struct in6_addr		*daddr, old_daddr;
   149		__be32			fl6_flowlabel = 0;
   150		__be32			old_fl6_flowlabel;
   151		__be32			old_dport;
   152		int			addr_type;
   153		int			err;
   154	
   155		if (usin->sin6_family == AF_INET) {
   156			if (__ipv6_only_sock(sk))
   157				return -EAFNOSUPPORT;
   158			err = __ip4_datagram_connect(sk, uaddr, addr_len);
   159			goto ipv4_connected;
   160		}
   161	
   162		if (addr_len < SIN6_LEN_RFC2133)
   163			return -EINVAL;
   164	
   165		if (usin->sin6_family != AF_INET6)
   166			return -EAFNOSUPPORT;
   167	
   168		if (np->sndflow)
   169			fl6_flowlabel = usin->sin6_flowinfo & IPV6_FLOWINFO_MASK;
   170	
   171		if (ipv6_addr_any(&usin->sin6_addr)) {
   172			/*
   173			 *	connect to self
   174			 */
   175			if (ipv6_addr_v4mapped(&sk->sk_v6_rcv_saddr))
   176				ipv6_addr_set_v4mapped(htonl(INADDR_LOOPBACK),
   177						       &usin->sin6_addr);
   178			else
   179				usin->sin6_addr = in6addr_loopback;
   180		}
   181	
   182		addr_type = ipv6_addr_type(&usin->sin6_addr);
   183	
   184		daddr = &usin->sin6_addr;
   185	
   186		if (addr_type & IPV6_ADDR_MAPPED) {
   187			struct sockaddr_in sin;
   188	
   189			if (__ipv6_only_sock(sk)) {
   190				err = -ENETUNREACH;
   191				goto out;
   192			}
   193			sin.sin_family = AF_INET;
   194			sin.sin_addr.s_addr = daddr->s6_addr32[3];
   195			sin.sin_port = usin->sin6_port;
   196	
   197			err = __ip4_datagram_connect(sk,
   198						     (struct sockaddr *) &sin,
   199						     sizeof(sin));
   200	
   201	ipv4_connected:
   202			if (err)
   203				goto out;
   204	
   205			ipv6_addr_set_v4mapped(inet->inet_daddr, &sk->sk_v6_daddr);
   206	
   207			if (ipv6_addr_any(&np->saddr) ||
   208			    ipv6_mapped_addr_any(&np->saddr))
   209				ipv6_addr_set_v4mapped(inet->inet_saddr, &np->saddr);
   210	
   211			if (ipv6_addr_any(&sk->sk_v6_rcv_saddr) ||
   212			    ipv6_mapped_addr_any(&sk->sk_v6_rcv_saddr)) {
   213				ipv6_addr_set_v4mapped(inet->inet_rcv_saddr,
   214						       &sk->sk_v6_rcv_saddr);
   215				if (sk->sk_prot->rehash)
   216					sk->sk_prot->rehash(sk);
   217			}
   218	
   219			goto out;
   220		}
   221	
   222		if (__ipv6_addr_needs_scope_id(addr_type)) {
   223			if (addr_len >= sizeof(struct sockaddr_in6) &&
   224			    usin->sin6_scope_id) {
   225				if (sk->sk_bound_dev_if &&
   226				    sk->sk_bound_dev_if != usin->sin6_scope_id) {
   227					err = -EINVAL;
   228					goto out;
   229				}
   230				sk->sk_bound_dev_if = usin->sin6_scope_id;
   231			}
   232	
   233			if (!sk->sk_bound_dev_if && (addr_type & IPV6_ADDR_MULTICAST))
   234				sk->sk_bound_dev_if = np->mcast_oif;
   235	
   236			/* Connect to link-local address requires an interface */
   237			if (!sk->sk_bound_dev_if) {
   238				err = -EINVAL;
   239				goto out;
   240			}
   241		}
   242	
   243		/* save the current peer information before updating it */
   244		old_daddr = sk->sk_v6_daddr;
   245		old_fl6_flowlabel = np->flow_label;
 > 246		old_dport = inet->inet_dport;
   247	
   248		sk->sk_v6_daddr = *daddr;
   249		np->flow_label = fl6_flowlabel;
   250		inet->inet_dport = usin->sin6_port;
   251	
   252		/*
   253		 *	Check for a route to destination an obtain the
   254		 *	destination cache for it.
   255		 */
   256	
   257		err = ip6_datagram_dst_update(sk, true);
   258		if (err) {
   259			/* Restore the socket peer info, to keep it consistent with
   260			 * the old socket state
   261			 */
   262			sk->sk_v6_daddr = old_daddr;
   263			np->flow_label = old_fl6_flowlabel;
 > 264			inet->inet_dport = old_dport;
   265			goto out;
   266		}
   267	
   268		sk->sk_state = TCP_ESTABLISHED;
   269		sk_set_txhash(sk);
   270	out:
   271		return err;
   272	}
   273	EXPORT_SYMBOL_GPL(__ip6_datagram_connect);
   274	

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

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 26068 bytes --]

                 reply	other threads:[~2021-01-08 14:51 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=202101082232.HwmvPCJu-lkp@intel.com \
    --to=lkp@intel.com \
    --cc=kbuild-all@lists.01.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.