Content-Type: multipart/mixed; boundary="===============5827196062691474608==" MIME-Version: 1.0 From: Taehee Yoo To: kbuild-all@lists.01.org Subject: Re: [PATCH net-next v2 5/7] mld: convert ipv6_mc_socklist->sflist to RCU Date: Sun, 14 Feb 2021 20:32:04 +0900 Message-ID: <14dd6a56-4088-0fb6-5b15-2d8424e94d36@gmail.com> In-Reply-To: <202102140308.IZ2lfKij-lkp@intel.com> List-Id: --===============5827196062691474608== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable On 21. 2. 14. =EC=98=A4=EC=A0=84 4:41, kernel test robot wrote: > Hi Taehee, > = > Thank you for the patch! Perhaps something to improve: > = > [auto build test WARNING on net-next/master] > = > url: https://github.com/0day-ci/linux/commits/Taehee-Yoo/mld-change-co= ntext-from-atomic-to-sleepable/20210214-015930 > base: https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.gi= t 3c5a2fd042d0bfac71a2dfb99515723d318df47b > config: x86_64-randconfig-s022-20210214 (attached as .config) > compiler: gcc-9 (Debian 9.3.0-15) 9.3.0 > reproduce: > # apt-get install sparse > # sparse version: v0.6.3-215-g0fb77bb6-dirty > # https://github.com/0day-ci/linux/commit/5a21fa32b1401aa428cd02= 49ee5b02ddb12cff60 > git remote add linux-review https://github.com/0day-ci/linux > git fetch --no-tags linux-review Taehee-Yoo/mld-change-context-f= rom-atomic-to-sleepable/20210214-015930 > git checkout 5a21fa32b1401aa428cd0249ee5b02ddb12cff60 > # save the attached .config to linux build tree > make W=3D1 C=3D1 CF=3D'-fdiagnostic-prefix -D__CHECK_ENDIAN__' A= RCH=3Dx86_64 > = > If you fix the issue, kindly add following tag as appropriate > Reported-by: kernel test robot > = > = > "sparse warnings: (new ones prefixed by >>)" >>> net/ipv6/mcast.c:430:17: sparse: sparse: incompatible types in comparis= on expression (different address spaces): >>> net/ipv6/mcast.c:430:17: sparse: struct ip6_sf_socklist [noderef] __= rcu * >>> net/ipv6/mcast.c:430:17: sparse: struct ip6_sf_socklist * > net/ipv6/mcast.c: note: in included file: > include/net/mld.h:32:43: sparse: sparse: array of flexible structures > net/ipv6/mcast.c:257:25: sparse: sparse: context imbalance in 'ip6_mc= _find_dev_rcu' - different lock contexts for basic block > net/ipv6/mcast.c:447:9: sparse: sparse: context imbalance in 'ip6_mc_= source' - unexpected unlock > net/ipv6/mcast.c:536:9: sparse: sparse: context imbalance in 'ip6_mc_= msfilter' - unexpected unlock > net/ipv6/mcast.c:583:21: sparse: sparse: context imbalance in 'ip6_mc= _msfget' - unexpected unlock > net/ipv6/mcast.c:2724:25: sparse: sparse: context imbalance in 'igmp6= _mc_get_next' - unexpected unlock > net/ipv6/mcast.c:2746:9: sparse: sparse: context imbalance in 'igmp6_= mc_get_idx' - wrong count at exit > net/ipv6/mcast.c:2773:9: sparse: sparse: context imbalance in 'igmp6_= mc_seq_stop' - unexpected unlock > net/ipv6/mcast.c:2845:31: sparse: sparse: context imbalance in 'igmp6= _mcf_get_next' - unexpected unlock > net/ipv6/mcast.c:2877:9: sparse: sparse: context imbalance in 'igmp6_= mcf_get_idx' - wrong count at exit > net/ipv6/mcast.c:2894:9: sparse: sparse: context imbalance in 'igmp6_= mcf_seq_next' - wrong count at exit > net/ipv6/mcast.c:2907:17: sparse: sparse: context imbalance in 'igmp6= _mcf_seq_stop' - unexpected unlock > = > vim +430 net/ipv6/mcast.c > = > 325 = > 326 int ip6_mc_source(int add, int omode, struct sock *sk, > 327 struct group_source_req *pgsr) > 328 { > 329 struct in6_addr *source, *group; > 330 struct ipv6_mc_socklist *pmc; > 331 struct inet6_dev *idev; > 332 struct ipv6_pinfo *inet6 =3D inet6_sk(sk); > 333 struct ip6_sf_socklist *psl; > 334 struct net *net =3D sock_net(sk); > 335 int i, j, rv; > 336 int leavegroup =3D 0; > 337 int err; > 338 = > 339 source =3D &((struct sockaddr_in6 *)&pgsr->gsr_source)->sin6_add= r; > 340 group =3D &((struct sockaddr_in6 *)&pgsr->gsr_group)->sin6_addr; > 341 = > 342 if (!ipv6_addr_is_multicast(group)) > 343 return -EINVAL; > 344 = > 345 rcu_read_lock(); > 346 idev =3D ip6_mc_find_dev_rcu(net, group, pgsr->gsr_interface); > 347 if (!idev) { > 348 rcu_read_unlock(); > 349 return -ENODEV; > 350 } > 351 = > 352 err =3D -EADDRNOTAVAIL; > 353 = > 354 for_each_pmc_rcu(inet6, pmc) { > 355 if (pgsr->gsr_interface && pmc->ifindex !=3D pgsr->gsr_interfac= e) > 356 continue; > 357 if (ipv6_addr_equal(&pmc->addr, group)) > 358 break; > 359 } > 360 if (!pmc) { /* must have a prior join */ > 361 err =3D -EINVAL; > 362 goto done; > 363 } > 364 /* if a source filter was set, must be the same mode as before */ > 365 if (rcu_access_pointer(pmc->sflist)) { > 366 if (pmc->sfmode !=3D omode) { > 367 err =3D -EINVAL; > 368 goto done; > 369 } > 370 } else if (pmc->sfmode !=3D omode) { > 371 /* allow mode switches for empty-set filters */ > 372 ip6_mc_add_src(idev, group, omode, 0, NULL, 0); > 373 ip6_mc_del_src(idev, group, pmc->sfmode, 0, NULL, 0); > 374 pmc->sfmode =3D omode; > 375 } > 376 = > 377 psl =3D rtnl_dereference(pmc->sflist); > 378 if (!add) { > 379 if (!psl) > 380 goto done; /* err =3D -EADDRNOTAVAIL */ > 381 rv =3D !0; > 382 for (i =3D 0; i < psl->sl_count; i++) { > 383 rv =3D !ipv6_addr_equal(&psl->sl_addr[i], source); > 384 if (rv =3D=3D 0) > 385 break; > 386 } > 387 if (rv) /* source not found */ > 388 goto done; /* err =3D -EADDRNOTAVAIL */ > 389 = > 390 /* special case - (INCLUDE, empty) =3D=3D LEAVE_GROUP */ > 391 if (psl->sl_count =3D=3D 1 && omode =3D=3D MCAST_INCLUDE) { > 392 leavegroup =3D 1; > 393 goto done; > 394 } > 395 = > 396 /* update the interface filter */ > 397 ip6_mc_del_src(idev, group, omode, 1, source, 1); > 398 = > 399 for (j =3D i+1; j < psl->sl_count; j++) > 400 psl->sl_addr[j-1] =3D psl->sl_addr[j]; > 401 psl->sl_count--; > 402 err =3D 0; > 403 goto done; > 404 } > 405 /* else, add a new source to the filter */ > 406 = > 407 if (psl && psl->sl_count >=3D sysctl_mld_max_msf) { > 408 err =3D -ENOBUFS; > 409 goto done; > 410 } > 411 if (!psl || psl->sl_count =3D=3D psl->sl_max) { > 412 struct ip6_sf_socklist *newpsl; > 413 int count =3D IP6_SFBLOCK; > 414 = > 415 if (psl) > 416 count +=3D psl->sl_max; > 417 newpsl =3D sock_kmalloc(sk, IP6_SFLSIZE(count), GFP_ATOMIC); > 418 if (!newpsl) { > 419 err =3D -ENOBUFS; > 420 goto done; > 421 } > 422 newpsl->sl_max =3D count; > 423 newpsl->sl_count =3D count - IP6_SFBLOCK; > 424 if (psl) { > 425 for (i =3D 0; i < psl->sl_count; i++) > 426 newpsl->sl_addr[i] =3D psl->sl_addr[i]; > 427 atomic_sub(IP6_SFLSIZE(psl->sl_max), &sk->sk_omem_alloc); > 428 kfree_rcu(psl, rcu); > 429 } > > 430 rcu_assign_pointer(psl, newpsl); > 431 rcu_assign_pointer(pmc->sflist, psl); > 432 } > 433 rv =3D 1; /* > 0 for insert logic below if sl_count is 0 */ > 434 for (i =3D 0; i < psl->sl_count; i++) { > 435 rv =3D !ipv6_addr_equal(&psl->sl_addr[i], source); > 436 if (rv =3D=3D 0) /* There is an error in the address. */ > 437 goto done; > 438 } > 439 for (j =3D psl->sl_count-1; j >=3D i; j--) > 440 psl->sl_addr[j+1] =3D psl->sl_addr[j]; > 441 psl->sl_addr[i] =3D *source; > 442 psl->sl_count++; > 443 err =3D 0; > 444 /* update the interface list */ > 445 ip6_mc_add_src(idev, group, omode, 1, source, 1); > 446 done: > 447 read_unlock_bh(&idev->lock); > 448 rcu_read_unlock(); > 449 if (leavegroup) > 450 err =3D ipv6_sock_mc_drop(sk, pgsr->gsr_interface, group); > 451 return err; > 452 } > 453 = > = > --- > 0-DAY CI Kernel Test Service, Intel Corporation > https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org > = I will add __rcu annotation in a v3 patch to avoid sparse warning. Thanks! --===============5827196062691474608==--