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>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 17 Apr 2023 08:17:39 +0800
From:   Hangbin Liu <liuhangbin@...il.com>
To:     Jay Vosburgh <jay.vosburgh@...onical.com>,
        Jakub Kicinski <kuba@...nel.org>
Cc:     netdev@...r.kernel.org, "David S . Miller" <davem@...emloft.net>,
        Jonathan Toppins <jtoppins@...hat.com>,
        Paolo Abeni <pabeni@...hat.com>,
        Eric Dumazet <edumazet@...gle.com>,
        Liang Li <liali@...hat.com>,
        Simon Horman <simon.horman@...igine.com>,
        Miroslav Lichvar <mlichvar@...hat.com>
Subject: Re: [PATCHv4 net-next] bonding: add software tx timestamping support

On Fri, Apr 14, 2023 at 08:43:14PM -0700, Jay Vosburgh wrote:
> Jakub Kicinski <kuba@...nel.org> wrote:
> 
> >On Fri, 14 Apr 2023 16:35:26 +0800 Hangbin Liu wrote:
> >> v4: add ASSERT_RTNL to make sure bond_ethtool_get_ts_info() called via
> >>     RTNL. Only check _TX_SOFTWARE for the slaves.
> >
> >> +	ASSERT_RTNL();
> >> +
> >>  	rcu_read_lock();
> >>  	real_dev = bond_option_active_slave_get_rcu(bond);
> >>  	dev_hold(real_dev);
> >> @@ -5707,10 +5713,36 @@ static int bond_ethtool_get_ts_info(struct net_device *bond_dev,
> >>  			ret = ops->get_ts_info(real_dev, info);
> >>  			goto out;
> >>  		}
> >> +	} else {
> >> +		/* Check if all slaves support software tx timestamping */
> >> +		rcu_read_lock();
> >> +		bond_for_each_slave_rcu(bond, slave, iter) {
> >
> >> +			ret = -1;
> >> +			ops = slave->dev->ethtool_ops;
> >> +			phydev = slave->dev->phydev;
> >> +
> >> +			if (phy_has_tsinfo(phydev))
> >> +				ret = phy_ts_info(phydev, &ts_info);
> >> +			else if (ops->get_ts_info)
> >> +				ret = ops->get_ts_info(slave->dev, &ts_info);
> >
> >My comment about this path being under rtnl was to point out that we
> >don't need the RCU protection to iterate over the slaves. This is 
> >a bit of a guess, I don't know bonding, but can we not use
> >bond_for_each_slave() ?
> 
> 	Ah, I missed that nuance.  And, yes, you're correct,
> bond_for_each_slave() works with RTNL and we don't need RCU here if RTNL
> is held.

Hi Jay, Jakub,

I remember why I use bond_for_each_slave_rcu() here now. In commit
9b80ccda233f ("bonding: fix missed rcu protection"), I added the
rcu_read_lock() as syzbot reported[1] the following path doesn't hold
rtnl lock.
- sock_setsockopt
  - sock_set_timestamping
    - sock_timestamping_bind_phc
      - ethtool_get_phc_vclocks
        - __ethtool_get_ts_info
	  - bond_ethtool_get_ts_info

[1] https://lore.kernel.org/netdev/20220513084819.zrg4ssnw667rhndt@skbuf/T/

Thanks
Hangbin

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ