[<prev] [next>] [day] [month] [year] [list]
Message-ID: <201804221936.kj1HfOHv%fengguang.wu@intel.com>
Date: Sun, 22 Apr 2018 19:57:41 +0800
From: kbuild test robot <lkp@...el.com>
To: David Ahern <dsahern@...il.com>
Cc: kbuild-all@...org, netdev@...r.kernel.org
Subject: [net-next:master 211/214] net/ipv6/route.c:3357:41: sparse:
incorrect type in argument 2 (different address spaces)
tree: https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git master
head: e0ada51db907ed2db5d46ad7ff86a8b5df68e59b
commit: a68886a691804d3f6d479ebf6825480fbafb6a00 [211/214] net/ipv6: Make from in rt6_info rcu protected
reproduce:
# apt-get install sparse
git checkout a68886a691804d3f6d479ebf6825480fbafb6a00
make ARCH=x86_64 allmodconfig
make C=1 CF=-D__CHECK_ENDIAN__
sparse warnings: (new ones prefixed by >>)
net/ipv6/route.c:2584:15: sparse: expression using sizeof(void)
>> net/ipv6/route.c:3357:41: sparse: incorrect type in argument 2 (different address spaces) @@ expected struct fib6_info *ort @@ got struct fib6_info struct fib6_info *ort @@
net/ipv6/route.c:3357:41: expected struct fib6_info *ort
net/ipv6/route.c:3357:41: got struct fib6_info [noderef] <asn:4>*from
net/ipv6/route.c:1391:15: sparse: expression using sizeof(void)
>> net/ipv6/route.c:1544:36: sparse: incorrect type in initializer (different address spaces) @@ expected struct fib6_info *from @@ got struct fib6_info struct fib6_info *from @@
net/ipv6/route.c:1544:36: expected struct fib6_info *from
net/ipv6/route.c:1544:36: got struct fib6_info [noderef] <asn:4>*from
net/ipv6/route.c:1589:36: sparse: incorrect type in initializer (different address spaces) @@ expected struct fib6_info *from @@ got struct fib6_info struct fib6_info *from @@
net/ipv6/route.c:1589:36: expected struct fib6_info *from
net/ipv6/route.c:1589:36: got struct fib6_info [noderef] <asn:4>*from
net/ipv6/route.c:1962:39: sparse: incorrect type in assignment (different base types) @@ expected unsigned int [unsigned] [usertype] flow_label @@ got gned] [usertype] flow_label @@
net/ipv6/route.c:1962:39: expected unsigned int [unsigned] [usertype] flow_label
net/ipv6/route.c:1962:39: got restricted __be32
net/ipv6/route.c:2304:15: sparse: expression using sizeof(void)
net/ipv6/route.c:3189:12: sparse: context imbalance in 'ip6_route_del' - wrong count at exit
vim +3357 net/ipv6/route.c
^1da177e4 Linus Torvalds 2005-04-16 3250
6700c2709 David S. Miller 2012-07-17 3251 static void rt6_do_redirect(struct dst_entry *dst, struct sock *sk, struct sk_buff *skb)
a6279458c YOSHIFUJI Hideaki 2006-08-23 3252 {
a6279458c YOSHIFUJI Hideaki 2006-08-23 3253 struct netevent_redirect netevent;
e8599ff4b David S. Miller 2012-07-11 3254 struct rt6_info *rt, *nrt = NULL;
e8599ff4b David S. Miller 2012-07-11 3255 struct ndisc_options ndopts;
e8599ff4b David S. Miller 2012-07-11 3256 struct inet6_dev *in6_dev;
e8599ff4b David S. Miller 2012-07-11 3257 struct neighbour *neigh;
a68886a69 David Ahern 2018-04-20 3258 struct fib6_info *from;
71bcdba06 YOSHIFUJI Hideaki / 吉藤英明 2013-01-05 3259 struct rd_msg *msg;
6e157b6ac David S. Miller 2012-07-12 3260 int optlen, on_link;
6e157b6ac David S. Miller 2012-07-12 3261 u8 *lladdr;
e8599ff4b David S. Miller 2012-07-11 3262
29a3cad5c Simon Horman 2013-05-28 3263 optlen = skb_tail_pointer(skb) - skb_transport_header(skb);
71bcdba06 YOSHIFUJI Hideaki / 吉藤英明 2013-01-05 3264 optlen -= sizeof(*msg);
e8599ff4b David S. Miller 2012-07-11 3265
e8599ff4b David S. Miller 2012-07-11 3266 if (optlen < 0) {
6e157b6ac David S. Miller 2012-07-12 3267 net_dbg_ratelimited("rt6_do_redirect: packet too short\n");
e8599ff4b David S. Miller 2012-07-11 3268 return;
e8599ff4b David S. Miller 2012-07-11 3269 }
e8599ff4b David S. Miller 2012-07-11 3270
71bcdba06 YOSHIFUJI Hideaki / 吉藤英明 2013-01-05 3271 msg = (struct rd_msg *)icmp6_hdr(skb);
e8599ff4b David S. Miller 2012-07-11 3272
71bcdba06 YOSHIFUJI Hideaki / 吉藤英明 2013-01-05 3273 if (ipv6_addr_is_multicast(&msg->dest)) {
6e157b6ac David S. Miller 2012-07-12 3274 net_dbg_ratelimited("rt6_do_redirect: destination address is multicast\n");
e8599ff4b David S. Miller 2012-07-11 3275 return;
e8599ff4b David S. Miller 2012-07-11 3276 }
e8599ff4b David S. Miller 2012-07-11 3277
6e157b6ac David S. Miller 2012-07-12 3278 on_link = 0;
71bcdba06 YOSHIFUJI Hideaki / 吉藤英明 2013-01-05 3279 if (ipv6_addr_equal(&msg->dest, &msg->target)) {
e8599ff4b David S. Miller 2012-07-11 3280 on_link = 1;
71bcdba06 YOSHIFUJI Hideaki / 吉藤英明 2013-01-05 3281 } else if (ipv6_addr_type(&msg->target) !=
e8599ff4b David S. Miller 2012-07-11 3282 (IPV6_ADDR_UNICAST|IPV6_ADDR_LINKLOCAL)) {
6e157b6ac David S. Miller 2012-07-12 3283 net_dbg_ratelimited("rt6_do_redirect: target address is not link-local unicast\n");
e8599ff4b David S. Miller 2012-07-11 3284 return;
e8599ff4b David S. Miller 2012-07-11 3285 }
e8599ff4b David S. Miller 2012-07-11 3286
e8599ff4b David S. Miller 2012-07-11 3287 in6_dev = __in6_dev_get(skb->dev);
e8599ff4b David S. Miller 2012-07-11 3288 if (!in6_dev)
e8599ff4b David S. Miller 2012-07-11 3289 return;
e8599ff4b David S. Miller 2012-07-11 3290 if (in6_dev->cnf.forwarding || !in6_dev->cnf.accept_redirects)
e8599ff4b David S. Miller 2012-07-11 3291 return;
e8599ff4b David S. Miller 2012-07-11 3292
e8599ff4b David S. Miller 2012-07-11 3293 /* RFC2461 8.1:
e8599ff4b David S. Miller 2012-07-11 3294 * The IP source address of the Redirect MUST be the same as the current
e8599ff4b David S. Miller 2012-07-11 3295 * first-hop router for the specified ICMP Destination Address.
e8599ff4b David S. Miller 2012-07-11 3296 */
e8599ff4b David S. Miller 2012-07-11 3297
f997c55c1 Alexander Aring 2016-06-15 3298 if (!ndisc_parse_options(skb->dev, msg->opt, optlen, &ndopts)) {
e8599ff4b David S. Miller 2012-07-11 3299 net_dbg_ratelimited("rt6_redirect: invalid ND options\n");
e8599ff4b David S. Miller 2012-07-11 3300 return;
e8599ff4b David S. Miller 2012-07-11 3301 }
6e157b6ac David S. Miller 2012-07-12 3302
6e157b6ac David S. Miller 2012-07-12 3303 lladdr = NULL;
e8599ff4b David S. Miller 2012-07-11 3304 if (ndopts.nd_opts_tgt_lladdr) {
e8599ff4b David S. Miller 2012-07-11 3305 lladdr = ndisc_opt_addr_data(ndopts.nd_opts_tgt_lladdr,
e8599ff4b David S. Miller 2012-07-11 3306 skb->dev);
e8599ff4b David S. Miller 2012-07-11 3307 if (!lladdr) {
e8599ff4b David S. Miller 2012-07-11 3308 net_dbg_ratelimited("rt6_redirect: invalid link-layer address length\n");
e8599ff4b David S. Miller 2012-07-11 3309 return;
e8599ff4b David S. Miller 2012-07-11 3310 }
e8599ff4b David S. Miller 2012-07-11 3311 }
e8599ff4b David S. Miller 2012-07-11 3312
6e157b6ac David S. Miller 2012-07-12 3313 rt = (struct rt6_info *) dst;
ec13ad1d7 Matthias Schiffer 2015-11-02 3314 if (rt->rt6i_flags & RTF_REJECT) {
6e157b6ac David S. Miller 2012-07-12 3315 net_dbg_ratelimited("rt6_redirect: source isn't a valid nexthop for redirect target\n");
e8599ff4b David S. Miller 2012-07-11 3316 return;
6e157b6ac David S. Miller 2012-07-12 3317 }
e8599ff4b David S. Miller 2012-07-11 3318
6e157b6ac David S. Miller 2012-07-12 3319 /* Redirect received -> path was valid.
6e157b6ac David S. Miller 2012-07-12 3320 * Look, redirects are sent only in response to data packets,
6e157b6ac David S. Miller 2012-07-12 3321 * so that this nexthop apparently is reachable. --ANK
6e157b6ac David S. Miller 2012-07-12 3322 */
0dec879f6 Julian Anastasov 2017-02-06 3323 dst_confirm_neigh(&rt->dst, &ipv6_hdr(skb)->saddr);
a6279458c YOSHIFUJI Hideaki 2006-08-23 3324
71bcdba06 YOSHIFUJI Hideaki / 吉藤英明 2013-01-05 3325 neigh = __neigh_lookup(&nd_tbl, &msg->target, skb->dev, 1);
6e157b6ac David S. Miller 2012-07-12 3326 if (!neigh)
6e157b6ac David S. Miller 2012-07-12 3327 return;
a6279458c YOSHIFUJI Hideaki 2006-08-23 3328
^1da177e4 Linus Torvalds 2005-04-16 3329 /*
^1da177e4 Linus Torvalds 2005-04-16 3330 * We have finally decided to accept it.
^1da177e4 Linus Torvalds 2005-04-16 3331 */
^1da177e4 Linus Torvalds 2005-04-16 3332
f997c55c1 Alexander Aring 2016-06-15 3333 ndisc_update(skb->dev, neigh, lladdr, NUD_STALE,
^1da177e4 Linus Torvalds 2005-04-16 3334 NEIGH_UPDATE_F_WEAK_OVERRIDE|
^1da177e4 Linus Torvalds 2005-04-16 3335 NEIGH_UPDATE_F_OVERRIDE|
^1da177e4 Linus Torvalds 2005-04-16 3336 (on_link ? 0 : (NEIGH_UPDATE_F_OVERRIDE_ISROUTER|
f997c55c1 Alexander Aring 2016-06-15 3337 NEIGH_UPDATE_F_ISROUTER)),
f997c55c1 Alexander Aring 2016-06-15 3338 NDISC_REDIRECT, &ndopts);
^1da177e4 Linus Torvalds 2005-04-16 3339
4d85cd0c2 David Ahern 2018-04-20 3340 rcu_read_lock();
a68886a69 David Ahern 2018-04-20 3341 from = rcu_dereference(rt->from);
a68886a69 David Ahern 2018-04-20 3342 nrt = ip6_rt_cache_alloc(from, &msg->dest, NULL);
4d85cd0c2 David Ahern 2018-04-20 3343 rcu_read_unlock();
383084739 David S. Miller 2011-12-03 3344 if (!nrt)
^1da177e4 Linus Torvalds 2005-04-16 3345 goto out;
^1da177e4 Linus Torvalds 2005-04-16 3346
^1da177e4 Linus Torvalds 2005-04-16 3347 nrt->rt6i_flags = RTF_GATEWAY|RTF_UP|RTF_DYNAMIC|RTF_CACHE;
^1da177e4 Linus Torvalds 2005-04-16 3348 if (on_link)
^1da177e4 Linus Torvalds 2005-04-16 3349 nrt->rt6i_flags &= ~RTF_GATEWAY;
^1da177e4 Linus Torvalds 2005-04-16 3350
4e3fd7a06 Alexey Dobriyan 2011-11-21 3351 nrt->rt6i_gateway = *(struct in6_addr *)neigh->primary_key;
^1da177e4 Linus Torvalds 2005-04-16 3352
2b760fcf5 Wei Wang 2017-10-06 3353 /* No need to remove rt from the exception table if rt is
2b760fcf5 Wei Wang 2017-10-06 3354 * a cached route because rt6_insert_exception() will
2b760fcf5 Wei Wang 2017-10-06 3355 * takes care of it
2b760fcf5 Wei Wang 2017-10-06 3356 */
d4ead6b34 David Ahern 2018-04-17 @3357 if (rt6_insert_exception(nrt, rt->from)) {
2b760fcf5 Wei Wang 2017-10-06 3358 dst_release_immediate(&nrt->dst);
2b760fcf5 Wei Wang 2017-10-06 3359 goto out;
2b760fcf5 Wei Wang 2017-10-06 3360 }
^1da177e4 Linus Torvalds 2005-04-16 3361
d8d1f30b9 Changli Gao 2010-06-10 3362 netevent.old = &rt->dst;
d8d1f30b9 Changli Gao 2010-06-10 3363 netevent.new = &nrt->dst;
71bcdba06 YOSHIFUJI Hideaki / 吉藤英明 2013-01-05 3364 netevent.daddr = &msg->dest;
605928337 YOSHIFUJI Hideaki / 吉藤英明 2013-01-14 3365 netevent.neigh = neigh;
8d71740c5 Tom Tucker 2006-07-30 3366 call_netevent_notifiers(NETEVENT_REDIRECT, &netevent);
8d71740c5 Tom Tucker 2006-07-30 3367
^1da177e4 Linus Torvalds 2005-04-16 3368 out:
e8599ff4b David S. Miller 2012-07-11 3369 neigh_release(neigh);
6e157b6ac David S. Miller 2012-07-12 3370 }
6e157b6ac David S. Miller 2012-07-12 3371
:::::: The code at line 3357 was first introduced by commit
:::::: d4ead6b34b67fd711639324b6465a050bcb197d4 net/ipv6: move metrics from dst to rt6_info
:::::: TO: David Ahern <dsahern@...il.com>
:::::: CC: David S. Miller <davem@...emloft.net>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
Powered by blists - more mailing lists