diff mbox series

[Resend,net-next] net: ethtool: Use hwprov under rcu_read_lock

Message ID 20250105084052.20694-1-lirongqing@baidu.com (mailing list archive)
State New
Delegated to: Netdev Maintainers
Headers show
Series [Resend,net-next] net: ethtool: Use hwprov under rcu_read_lock | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 1 this patch: 1
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers fail 3 blamed authors not CCed: edumazet@google.com kory.maincent@bootlin.com kuba@kernel.org; 5 maintainers not CCed: edumazet@google.com horms@kernel.org pabeni@redhat.com kuba@kernel.org kory.maincent@bootlin.com
netdev/build_clang success Errors and warnings before: 3 this patch: 3
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 1 this patch: 1
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 17 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 2 this patch: 2
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2025-01-05--15-00 (tests: 887)

Commit Message

Li RongQing Jan. 5, 2025, 8:40 a.m. UTC
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 mbox series

Patch

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,