Skip to contentSkip to conversation

ice: double lock on adev_mutex

PATCH Superseded Michal Swiatkowski 3 participants 4 messages Jan 11, 2023 – Jan 19, 2023

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ice: double lock on adev_mutex

Call trace:

ice_set_channel() --> mutex_lock(adev_mutex) ice_vsi_recfg_qs()
ice_pf_dcb_recfg()
ice_send_event_to_aux() --> another mutex_lock(adev_mutex)

This call trace is reached when user try to change queues amount using ethtool:

$ ethtool -L enp24s0f0np0 tx 64 rx 32

Avoid double lock by unlocking after checking if RDMA is active.

Fixes a49a2713f00e ("ice: Prevent set_channel from changing queues while RDMA active")
---
 drivers/net/ethernet/intel/ice/ice_ethtool.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/net/ethernet/intel/ice/ice_ethtool.c +4 -5
index 263d59929602..54fc2ca823f5 100644
@@ -3729,22 +3729,21 @@ static int ice_set_channels(struct net_device *dev, struct ethtool_channels *ch)
 	mutex_lock(&pf->adev_mutex);
 	if (pf->adev && pf->adev->dev.driver) {
 		netdev_err(dev, "Cannot change channels when RDMA is active\n");
-		ret = -EINVAL;
-		goto adev_unlock;
+		mutex_unlock(&pf->adev_mutex);
+		return -EINVAL;
 	}
+	mutex_unlock(&pf->adev_mutex);
 
 	ice_vsi_recfg_qs(vsi, new_rx, new_tx);
 
 	if (!netif_is_rxfh_configured(dev)) {
 		ret = ice_vsi_set_dflt_rss_lut(vsi, new_rx);
-		goto adev_unlock;
+		return ret;
 	}
 
 	/* Update rss_size due to change in Rx queues */
 	vsi->rss_size = ice_get_valid_rss_size(&pf->hw, new_rx);
 
-adev_unlock:
-	mutex_unlock(&pf->adev_mutex);
 	return ret;
 }
 
Signature · 6 lines
2.36.1

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
#1 lore raw
Quoted 1 line · Michal Swiatkowski

Re: [Intel-wired-lan] [PATCH] ice: double lock on adev_mutex

Looks good but title should always contain PATCH net-next or PATCH net. Also doesn't hurt especially for net fixes to use --base net/master (assuming your remote for netdev net tree is 'net')

Quoted 5 lines
Call trace:

ice_set_channel() --> mutex_lock(adev_mutex) ice_vsi_recfg_qs()
ice_pf_dcb_recfg()
ice_send_event_to_aux() --> another mutex_lock(adev_mutex)

Ouch, didn't lockdep identify this? Let's hope it would find it if we turned it on.

Quoted 9 lines

This call trace is reached when user try to change queues amount using ethtool:

$ ethtool -L enp24s0f0np0 tx 64 rx 32

Avoid double lock by unlocking after checking if RDMA is active.

Fixes a49a2713f00e ("ice: Prevent set_channel from changing queues while RDMA active")

thanks for fixing this!

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

#2 lore raw
Quoted 8 lines · Jesse Brandeburg
Quoted 1 line · Michal Swiatkowski

Re: [Intel-wired-lan] [PATCH] ice: double lock on adev_mutex

Looks good but title should always contain PATCH net-next or PATCH net. Also doesn't hurt especially for net fixes to use --base net/master (assuming your remote for netdev net tree is 'net')

Sure, sorry, I forgot to add net tag, it is in v2. Will remember, thanks.

Quoted 9 lines
Quoted 5 lines
Call trace:

ice_set_channel() --> mutex_lock(adev_mutex) ice_vsi_recfg_qs()
ice_pf_dcb_recfg()
ice_send_event_to_aux() --> another mutex_lock(adev_mutex)

Ouch, didn't lockdep identify this? Let's hope it would find it if we turned it on.

I haven't got lockdep compiled into my kernel, probably I should start adding it.

Quoted 5 lines
Quoted 5 lines

This call trace is reached when user try to change queues amount using ethtool:

$ ethtool -L enp24s0f0np0 tx 64 rx 32
Quoted 7 lines
Quoted 4 lines

Avoid double lock by unlocking after checking if RDMA is active.

Fixes a49a2713f00e ("ice: Prevent set_channel from changing queues while RDMA active")

thanks for fixing this!

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

Tested-by on v1 1/1
#3 lore raw
In reply to Michal Swiatkowski
Quoted 19 lines

-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Michal Swiatkowski
Sent: Wednesday, January 11, 2023 4:31 PM
To: [email protected]
Subject: [Intel-wired-lan] [PATCH] ice: double lock on adev_mutex

Call trace:

ice_set_channel() --> mutex_lock(adev_mutex) ice_vsi_recfg_qs()
ice_pf_dcb_recfg()
ice_send_event_to_aux() --> another mutex_lock(adev_mutex)

This call trace is reached when user try to change queues amount using ethtool:

$ ethtool -L enp24s0f0np0 tx 64 rx 32
Quoted 9 lines

Avoid double lock by unlocking after checking if RDMA is active.

Fixes a49a2713f00e ("ice: Prevent set_channel from changing queues while

RDMA active")

---
 drivers/net/ethernet/intel/ice/ice_ethtool.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan