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]
Message-ID: <20230411213018.0b5b37ec@kernel.org>
Date:   Tue, 11 Apr 2023 21:30:18 -0700
From:   Jakub Kicinski <kuba@...nel.org>
To:     Hangbin Liu <liuhangbin@...il.com>
Cc:     netdev@...r.kernel.org, Jay Vosburgh <j.vosburgh@...il.com>,
        "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: [PATCHv3 net-next] bonding: add software tx timestamping
 support

On Mon, 10 Apr 2023 16:23:51 +0800 Hangbin Liu wrote:
> @@ -5707,10 +5711,38 @@ 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 rx/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);

Do we _really_ need to hold RCU lock over this?
Imposing atomic context restrictions on driver callbacks should not be
taken lightly. I'm 75% sure .ethtool_get_ts_info can only be called
under rtnl lock off the top of my head, is that not the case?

> +			if (!ret && (ts_info.so_timestamping & SOF_TIMESTAMPING_SOFTRXTX) ==
> +				    SOF_TIMESTAMPING_SOFTRXTX) {

You could check in this loop if TX is supported...

> +				soft_support = true;
> +				continue;
> +			}
> +
> +			soft_support = false;
> +			break;
> +		}
> +		rcu_read_unlock();
>  	}
>  
> -	info->so_timestamping = SOF_TIMESTAMPING_RX_SOFTWARE |
> -				SOF_TIMESTAMPING_SOFTWARE;
> +	ret = 0;
> +	if (soft_support) {
> +		info->so_timestamping = SOF_TIMESTAMPING_SOFTRXTX;
> +	} else {
> +		info->so_timestamping = SOF_TIMESTAMPING_RX_SOFTWARE |
> +					SOF_TIMESTAMPING_SOFTWARE;

...make this unconditional and conditionally add TX...

> +	}
>  	info->phc_index = -1;
>  
>  out:
> diff --git a/include/uapi/linux/net_tstamp.h b/include/uapi/linux/net_tstamp.h
> index a2c66b3d7f0f..2adaa0008434 100644
> --- a/include/uapi/linux/net_tstamp.h
> +++ b/include/uapi/linux/net_tstamp.h
> @@ -48,6 +48,9 @@ enum {
>  					 SOF_TIMESTAMPING_TX_SCHED | \
>  					 SOF_TIMESTAMPING_TX_ACK)
>  
> +#define SOF_TIMESTAMPING_SOFTRXTX (SOF_TIMESTAMPING_TX_SOFTWARE | \
> +				   SOF_TIMESTAMPING_RX_SOFTWARE | \
> +				   SOF_TIMESTAMPING_SOFTWARE)

..then you won't need this define in uAPI.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ