Skip to content

Commit b493f88

Browse files
lrq-maxkuba-moo
authored andcommitted
net: ethtool: Use hwprov under rcu_read_lock
hwprov should be protected by rcu_read_lock to prevent possible UAF Fixes: 4c61d80 ("net: ethtool: Fix suspicious rcu_dereference usage") Signed-off-by: Li RongQing <[email protected]> Acked-by: Kory Maincent <[email protected]> diff with v1: move and use err varialbe, instead of define a new variable net/ethtool/common.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 8d460ac commit b493f88

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

net/ethtool/common.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -869,14 +869,14 @@ int __ethtool_get_ts_info(struct net_device *dev,
869869
struct kernel_ethtool_ts_info *info)
870870
{
871871
struct hwtstamp_provider *hwprov;
872+
int err = 0;
872873

873874
rcu_read_lock();
874875
hwprov = rcu_dereference(dev->hwprov);
875876
/* No provider specified, use default behavior */
876877
if (!hwprov) {
877878
const struct ethtool_ops *ops = dev->ethtool_ops;
878879
struct phy_device *phydev = dev->phydev;
879-
int err = 0;
880880

881881
ethtool_init_tsinfo(info);
882882
if (phy_is_default_hwtstamp(phydev) &&
@@ -892,8 +892,9 @@ int __ethtool_get_ts_info(struct net_device *dev,
892892
return err;
893893
}
894894

895+
err = ethtool_get_ts_info_by_phc(dev, info, &hwprov->desc);
895896
rcu_read_unlock();
896-
return ethtool_get_ts_info_by_phc(dev, info, &hwprov->desc);
897+
return err;
897898
}
898899

899900
bool net_support_hwtstamp_qualifier(struct net_device *dev,

0 commit comments

Comments
 (0)