[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250109111057.4746-1-lirongqing@baidu.com>
Date: Thu, 9 Jan 2025 19:10:57 +0800
From: lirongqing <lirongqing@...du.com>
To: <davem@...emloft.net>, <edumazet@...gle.com>, <kuba@...nel.org>,
<pabeni@...hat.com>, <horms@...nel.org>, <kory.maincent@...tlin.com>,
<willemb@...gle.com>, <aleksander.lobakin@...el.com>, <hkallweit1@...il.com>,
<ecree.xilinx@...il.com>, <daniel.zahka@...il.com>, <almasrymina@...gle.com>,
<gal@...dia.com>, <netdev@...r.kernel.org>
CC: Li RongQing <lirongqing@...du.com>
Subject: [PATCH][net-next][v2] net: ethtool: Use hwprov under rcu_read_lock
From: Li RongQing <lirongqing@...du.com>
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@...du.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(-)
diff --git a/net/ethtool/common.c b/net/ethtool/common.c
index 2607aea..2bd77c9 100644
--- a/net/ethtool/common.c
+++ b/net/ethtool/common.c
@@ -869,6 +869,7 @@ int __ethtool_get_ts_info(struct net_device *dev,
struct kernel_ethtool_ts_info *info)
{
struct hwtstamp_provider *hwprov;
+ int err = 0;
rcu_read_lock();
hwprov = rcu_dereference(dev->hwprov);
@@ -876,7 +877,6 @@ int __ethtool_get_ts_info(struct net_device *dev,
if (!hwprov) {
const struct ethtool_ops *ops = dev->ethtool_ops;
struct phy_device *phydev = dev->phydev;
- int err = 0;
ethtool_init_tsinfo(info);
if (phy_is_default_hwtstamp(phydev) &&
@@ -892,8 +892,9 @@ int __ethtool_get_ts_info(struct net_device *dev,
return err;
}
+ err = ethtool_get_ts_info_by_phc(dev, info, &hwprov->desc);
rcu_read_unlock();
- return ethtool_get_ts_info_by_phc(dev, info, &hwprov->desc);
+ return err;
}
bool net_support_hwtstamp_qualifier(struct net_device *dev,
--
2.9.4
Powered by blists - more mailing lists