Skip to content

Commit

Permalink
ethtool: netlink: Add missing ethnl_ops_begin/complete
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
ludvigpa authored and Paolo Abeni committed Jan 18, 2024
1 parent dd2d40a commit f1172f3
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions net/ethtool/features.c
Original file line number Diff line number Diff line change
Expand Up @@ -234,17 +234,20 @@ int ethnl_set_features(struct sk_buff *skb, struct genl_info *info)
dev = req_info.dev;

rtnl_lock();
ret = ethnl_ops_begin(dev);
if (ret < 0)
goto out_rtnl;
ethnl_features_to_bitmap(old_active, dev->features);
ethnl_features_to_bitmap(old_wanted, dev->wanted_features);
ret = ethnl_parse_bitset(req_wanted, req_mask, NETDEV_FEATURE_COUNT,
tb[ETHTOOL_A_FEATURES_WANTED],
netdev_features_strings, info->extack);
if (ret < 0)
goto out_rtnl;
goto out_ops;
if (ethnl_bitmap_to_features(req_mask) & ~NETIF_F_ETHTOOL_BITS) {
GENL_SET_ERR_MSG(info, "attempt to change non-ethtool features");
ret = -EINVAL;
goto out_rtnl;
goto out_ops;
}

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

out_ops:
ethnl_ops_complete(dev);
out_rtnl:
rtnl_unlock();
ethnl_parse_header_dev_put(&req_info);
Expand Down

0 comments on commit f1172f3

Please sign in to comment.