netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH][Resend][net-next] net: ethtool: Use hwprov under rcu_read_lock
@ 2025-01-05  8:40 Li RongQing
  2025-01-08  1:39 ` Jakub Kicinski
  0 siblings, 1 reply; 3+ messages in thread
From: Li RongQing @ 2025-01-05  8:40 UTC (permalink / raw)
  To: netdev; +Cc: Li RongQing

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>
---
 net/ethtool/common.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/ethtool/common.c b/net/ethtool/common.c
index 2607aea..b200e53 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 ret;
 
 	rcu_read_lock();
 	hwprov = rcu_dereference(dev->hwprov);
@@ -892,8 +893,9 @@ int __ethtool_get_ts_info(struct net_device *dev,
 		return err;
 	}
 
+	ret = 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 ret;
 }
 
 bool net_support_hwtstamp_qualifier(struct net_device *dev,
-- 
2.9.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH][Resend][net-next] net: ethtool: Use hwprov under rcu_read_lock
  2025-01-05  8:40 [PATCH][Resend][net-next] net: ethtool: Use hwprov under rcu_read_lock Li RongQing
@ 2025-01-08  1:39 ` Jakub Kicinski
  2025-01-08  1:40   ` Jakub Kicinski
  0 siblings, 1 reply; 3+ messages in thread
From: Jakub Kicinski @ 2025-01-08  1:39 UTC (permalink / raw)
  To: Li RongQing; +Cc: netdev

On Sun,  5 Jan 2025 16:40:52 +0800 Li RongQing wrote:
> 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>

In the future please make sure you CC the appropriate authors and
maintainers. Always use get_maintainer.pl on the generated patch file.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH][Resend][net-next] net: ethtool: Use hwprov under rcu_read_lock
  2025-01-08  1:39 ` Jakub Kicinski
@ 2025-01-08  1:40   ` Jakub Kicinski
  0 siblings, 0 replies; 3+ messages in thread
From: Jakub Kicinski @ 2025-01-08  1:40 UTC (permalink / raw)
  To: Li RongQing; +Cc: netdev

On Tue, 7 Jan 2025 17:39:43 -0800 Jakub Kicinski wrote:
> On Sun,  5 Jan 2025 16:40:52 +0800 Li RongQing wrote:
> > 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>  
> 
> In the future please make sure you CC the appropriate authors and
> maintainers. Always use get_maintainer.pl on the generated patch file.

Actually, the code could be improved, too.

Don't declare ret, move the declaration of int err instead.
-- 
pw-bot: cr

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-01-08  1:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-05  8:40 [PATCH][Resend][net-next] net: ethtool: Use hwprov under rcu_read_lock Li RongQing
2025-01-08  1:39 ` Jakub Kicinski
2025-01-08  1:40   ` Jakub Kicinski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).