Skip to content

Commit f1172f3

Browse files
ludvigpaPaolo Abeni
authored andcommitted
ethtool: netlink: Add missing ethnl_ops_begin/complete
Accessing an ethernet device that is powered off or clock gated might cause the CPU to hang. Add ethnl_ops_begin/complete in ethnl_set_features() to protect against this. Fixes: 0980bfc ("ethtool: set netdev features with FEATURES_SET request") Signed-off-by: Ludvig Pärsson <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
1 parent dd2d40a commit f1172f3

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

net/ethtool/features.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,17 +234,20 @@ int ethnl_set_features(struct sk_buff *skb, struct genl_info *info)
234234
dev = req_info.dev;
235235

236236
rtnl_lock();
237+
ret = ethnl_ops_begin(dev);
238+
if (ret < 0)
239+
goto out_rtnl;
237240
ethnl_features_to_bitmap(old_active, dev->features);
238241
ethnl_features_to_bitmap(old_wanted, dev->wanted_features);
239242
ret = ethnl_parse_bitset(req_wanted, req_mask, NETDEV_FEATURE_COUNT,
240243
tb[ETHTOOL_A_FEATURES_WANTED],
241244
netdev_features_strings, info->extack);
242245
if (ret < 0)
243-
goto out_rtnl;
246+
goto out_ops;
244247
if (ethnl_bitmap_to_features(req_mask) & ~NETIF_F_ETHTOOL_BITS) {
245248
GENL_SET_ERR_MSG(info, "attempt to change non-ethtool features");
246249
ret = -EINVAL;
247-
goto out_rtnl;
250+
goto out_ops;
248251
}
249252

250253
/* set req_wanted bits not in req_mask from old_wanted */
@@ -281,6 +284,8 @@ int ethnl_set_features(struct sk_buff *skb, struct genl_info *info)
281284
if (mod)
282285
netdev_features_change(dev);
283286

287+
out_ops:
288+
ethnl_ops_complete(dev);
284289
out_rtnl:
285290
rtnl_unlock();
286291
ethnl_parse_header_dev_put(&req_info);

0 commit comments

Comments
 (0)