Content-Type: multipart/mixed; boundary="===============7893379319510841390==" MIME-Version: 1.0 From: kernel test robot To: kbuild-all@lists.01.org Subject: Re: [PATCH v1 2/2] xfrm: Fix xfrm migrate issues when address family changes Date: Sun, 26 Dec 2021 10:18:21 +0800 Message-ID: <202112261010.hDTqK3oK-lkp@intel.com> In-Reply-To: <20211223004555.1284666-3-evitayan@google.com> List-Id: --===============7893379319510841390== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Hi Yan, Thank you for the patch! Perhaps something to improve: [auto build test WARNING on klassert-ipsec-next/master] [also build test WARNING on klassert-ipsec/master net-next/master net/maste= r v5.16-rc6 next-20211224] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch] url: https://github.com/0day-ci/linux/commits/Yan-Yan/Fix-issues-in-xfrm= _migrate/20211223-084725 base: https://git.kernel.org/pub/scm/linux/kernel/git/klassert/ipsec-next= .git master config: x86_64-allyesconfig (https://download.01.org/0day-ci/archive/202112= 26/202112261010.hDTqK3oK-lkp(a)intel.com/config) compiler: gcc-9 (Debian 9.3.0-22) 9.3.0 reproduce (this is a W=3D1 build): # https://github.com/0day-ci/linux/commit/11348c1b6c9b3af9e634611c9= 7eabadb35dffcef git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review Yan-Yan/Fix-issues-in-xfrm_migrate= /20211223-084725 git checkout 11348c1b6c9b3af9e634611c97eabadb35dffcef # save the config file to linux build tree mkdir build_dir make W=3D1 O=3Dbuild_dir ARCH=3Dx86_64 SHELL=3D/bin/bash drivers/gp= io/ kernel/bpf/ net/key/ net/sched/ net/xfrm/ If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot All warnings (new ones prefixed by >>): net/xfrm/xfrm_state.c: In function 'xfrm_state_clone2': >> net/xfrm/xfrm_state.c:1594:10: warning: returning 'int' from a function = with return type 'int *' makes pointer from integer without a cast [-Wint-c= onversion] 1594 | return err; | ^~~ net/xfrm/xfrm_state.c: In function 'xfrm_state_migrate': >> net/xfrm/xfrm_state.c:1675:31: warning: ordered comparison of pointer wi= th integer zero [-Wextra] 1675 | if (xfrm_state_clone2(x, xc) < 0) | ^ vim +1594 net/xfrm/xfrm_state.c 1588 = 1589 static int *xfrm_state_clone2(struct xfrm_state *orig, 1590 struct xfrm_state *x) 1591 { 1592 int err =3D xfrm_init_state(x); 1593 if (err < 0) > 1594 return err; 1595 = 1596 x->props.flags =3D orig->props.flags; 1597 x->props.extra_flags =3D orig->props.extra_flags; 1598 = 1599 x->if_id =3D orig->if_id; 1600 x->tfcpad =3D orig->tfcpad; 1601 x->replay_maxdiff =3D orig->replay_maxdiff; 1602 x->replay_maxage =3D orig->replay_maxage; 1603 memcpy(&x->curlft, &orig->curlft, sizeof(x->curlft)); 1604 x->km.state =3D orig->km.state; 1605 x->km.seq =3D orig->km.seq; 1606 x->replay =3D orig->replay; 1607 x->preplay =3D orig->preplay; 1608 = 1609 return 0; 1610 } 1611 = 1612 struct xfrm_state *xfrm_migrate_state_find(struct xfrm_migrate *m, s= truct net *net, 1613 u32 if_id) 1614 { 1615 unsigned int h; 1616 struct xfrm_state *x =3D NULL; 1617 = 1618 spin_lock_bh(&net->xfrm.xfrm_state_lock); 1619 = 1620 if (m->reqid) { 1621 h =3D xfrm_dst_hash(net, &m->old_daddr, &m->old_saddr, 1622 m->reqid, m->old_family); 1623 hlist_for_each_entry(x, net->xfrm.state_bydst+h, bydst) { 1624 if (x->props.mode !=3D m->mode || 1625 x->id.proto !=3D m->proto) 1626 continue; 1627 if (m->reqid && x->props.reqid !=3D m->reqid) 1628 continue; 1629 if (if_id !=3D 0 && x->if_id !=3D if_id) 1630 continue; 1631 if (!xfrm_addr_equal(&x->id.daddr, &m->old_daddr, 1632 m->old_family) || 1633 !xfrm_addr_equal(&x->props.saddr, &m->old_saddr, 1634 m->old_family)) 1635 continue; 1636 xfrm_state_hold(x); 1637 break; 1638 } 1639 } else { 1640 h =3D xfrm_src_hash(net, &m->old_daddr, &m->old_saddr, 1641 m->old_family); 1642 hlist_for_each_entry(x, net->xfrm.state_bysrc+h, bysrc) { 1643 if (x->props.mode !=3D m->mode || 1644 x->id.proto !=3D m->proto) 1645 continue; 1646 if (if_id !=3D 0 && x->if_id !=3D if_id) 1647 continue; 1648 if (!xfrm_addr_equal(&x->id.daddr, &m->old_daddr, 1649 m->old_family) || 1650 !xfrm_addr_equal(&x->props.saddr, &m->old_saddr, 1651 m->old_family)) 1652 continue; 1653 xfrm_state_hold(x); 1654 break; 1655 } 1656 } 1657 = 1658 spin_unlock_bh(&net->xfrm.xfrm_state_lock); 1659 = 1660 return x; 1661 } 1662 EXPORT_SYMBOL(xfrm_migrate_state_find); 1663 = 1664 struct xfrm_state *xfrm_state_migrate(struct xfrm_state *x, 1665 struct xfrm_migrate *m, 1666 struct xfrm_encap_tmpl *encap) 1667 { 1668 struct xfrm_state *xc; 1669 = 1670 xc =3D xfrm_state_clone1(x, encap); 1671 if (!xc) 1672 return NULL; 1673 = 1674 xc->props.family =3D m->new_family; > 1675 if (xfrm_state_clone2(x, xc) < 0) 1676 goto error; 1677 = 1678 memcpy(&xc->id.daddr, &m->new_daddr, sizeof(xc->id.daddr)); 1679 memcpy(&xc->props.saddr, &m->new_saddr, sizeof(xc->props.saddr)); 1680 = 1681 /* add state */ 1682 if (xfrm_addr_equal(&x->id.daddr, &m->new_daddr, m->new_family)) { 1683 /* a care is needed when the destination address of the 1684 state is to be updated as it is a part of triplet */ 1685 xfrm_state_insert(xc); 1686 } else { 1687 if (xfrm_state_add(xc) < 0) 1688 goto error; 1689 } 1690 = 1691 return xc; 1692 error: 1693 xfrm_state_put(xc); 1694 return NULL; 1695 } 1696 EXPORT_SYMBOL(xfrm_state_migrate); 1697 #endif 1698 = --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org --===============7893379319510841390==--