Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

net: ethtool: Use hwprov under rcu_read_lock

hwprov should be protected by rcu_read_lock to prevent possible UAF

Fixes: 4c61d809cf60 ("net: ethtool: Fix suspicious rcu_dereference usage")
Signed-off-by: Li RongQing <lirongqing@baidu.com>
Acked-by: Kory Maincent <kory.maincent@bootlin.com>

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/20250109111057.4746-1-lirongqing@baidu.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Li RongQing and committed by
Jakub Kicinski
b493f881 8d460ac7

+3 -2
+3 -2
net/ethtool/common.c
··· 869 869 struct kernel_ethtool_ts_info *info) 870 870 { 871 871 struct hwtstamp_provider *hwprov; 872 + int err = 0; 872 873 873 874 rcu_read_lock(); 874 875 hwprov = rcu_dereference(dev->hwprov); ··· 877 876 if (!hwprov) { 878 877 const struct ethtool_ops *ops = dev->ethtool_ops; 879 878 struct phy_device *phydev = dev->phydev; 880 - int err = 0; 881 879 882 880 ethtool_init_tsinfo(info); 883 881 if (phy_is_default_hwtstamp(phydev) && ··· 892 892 return err; 893 893 } 894 894 895 + err = ethtool_get_ts_info_by_phc(dev, info, &hwprov->desc); 895 896 rcu_read_unlock(); 896 - return ethtool_get_ts_info_by_phc(dev, info, &hwprov->desc); 897 + return err; 897 898 } 898 899 899 900 bool net_support_hwtstamp_qualifier(struct net_device *dev,