ethtool: fix error paths in ethnl_set_channels()
Subsystems (3)
PATCH 1/1 ethtool: fix error paths in ethnl_set_channels()
Fix two error paths in ethnl_set_channels() to avoid lock-up caused but unreleased RTNL.
Fixes e19c591eafad ("ethtool: set device channel counts with CHANNELS_SET request")
Cc Michal Kubecek <[email protected]>
Reported-by LiLiang <[email protected]>
Signed-off-by Ivan Vecera <[email protected]>
--- net/ethtool/channels.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
net/ethtool/channels.c +4 -2
@@ -194,8 +194,9 @@ int ethnl_set_channels(struct sk_buff *skb, struct genl_info *info)if (netif_is_rxfh_configured (dev) && !ethtool_get_max_rxfh_channel (dev, &max_rx_in_use) && (channels.combined_count + channels.rx_count) <= max_rx_in_use) { + ret = -EINVAL ;GENL_SET_ERR_MSG (info,"requested channel counts are too low for existing indirection table settings" ); -return -EINVAL ; + goto out_ops; }/* Disabling channels, query zero-copy AF_XDP sockets */
@@ -203,8 +204,9 @@ int ethnl_set_channels(struct sk_buff *skb, struct genl_info *info)min (channels.rx_count, channels.tx_count);for (i = from_channel; i < old_total; i++)if (xsk_get_pool_from_qid (dev, i)) { + ret = -EINVAL ;GENL_SET_ERR_MSG (info,"requested channel counts are too low for existing zerocopy AF_XDP sockets" ); -return -EINVAL ; + goto out_ops; } ret = dev->ethtool_ops->set_channels (dev, &channels);
Signature · 1 line
2.26.2
Quoted 27 lines · Ivan Vecera
Fix two error paths in
ethnl_set_channels()to avoid lock-up caused but unreleased RTNL.Fixes e19c591eafad ("ethtool: set device channel counts with CHANNELS_SET request")Cc Michal Kubecek <[email protected]>Reported-by LiLiang <[email protected]>Signed-off-by Ivan Vecera <[email protected]>--- net/ethtool/channels.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)net/ethtool/channels.c +2
-1@@ -194,8 +194,9 @@ int ethnl_set_channels(struct sk_buff *skb, struct genl_info *info)if (netif_is_rxfh_configured (dev) && !ethtool_get_max_rxfh_channel (dev, &max_rx_in_use) && (channels.combined_count + channels.rx_count) <= max_rx_in_use) { + ret = -EINVAL ;GENL_SET_ERR_MSG (info,"requested channel counts are too low for existing indirection table settings" ); -return -EINVAL ; + goto out_ops; }/* Disabling channels, query zero-copy AF_XDP sockets */
net/ethtool/channels.c int ethnl_set_channels(struct sk_buff *skb, struct genl_info *info) · line 212
Quoted 10 lines
net/ethtool/channels.c +2
-1@@ -203,8 +204,9 @@ int ethnl_set_channels(struct sk_buff *skb, struct genl_info *info)min (channels.rx_count, channels.tx_count);for (i = from_channel; i < old_total; i++)if (xsk_get_pool_from_qid (dev, i)) { + ret = -EINVAL ;GENL_SET_ERR_MSG (info,"requested channel counts are too low for existing zerocopy AF_XDP sockets" ); -return -EINVAL ; + goto out_ops; } ret = dev->ethtool_ops->set_channels (dev, &channels);
Oh, the joys of mindless copy and paste... :-(
Reviewed-by Michal Kubecek <[email protected]>
Quoted 10 lines · On Tue, 15 Dec 2020 11:09:21 +0100 Michal Kubecek wrote:
Quoted 7 lines · Ivan Vecera
Fix two error paths in
ethnl_set_channels()to avoid lock-up caused but unreleased RTNL.Fixes e19c591eafad ("ethtool: set device channel counts with CHANNELS_SET request")Cc Michal Kubecek <[email protected]>Reported-by LiLiang <[email protected]>Signed-off-by Ivan Vecera <[email protected]>Oh, the joys of mindless copy and paste... :-(
I wish sparse was able to catch rtnl_lock leaks. I tried to annotate it a couple of weeks back but couldn't get it to work well even within rtnetlink.c
Quoted 1 line
Reviewed-by Michal Kubecek <[email protected]>
Applied, thanks!