lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue,  2 Feb 2021 21:06:50 -0800
From:   Sukadev Bhattiprolu <sukadev@...ux.ibm.com>
To:     netdev@...r.kernel.org
Cc:     Dany Madden <drt@...ux.ibm.com>, Lijun Pan <ljp@...ux.ibm.com>,
        Rick Lindsley <ricklind@...ux.ibm.com>, abdhalee@...ibm.com,
        sukadev@...ux.ibm.com
Subject: [PATCH v2 2/2] ibmvnic: fix race with multiple open/close

If two or more instances of 'ip link set' commands race and first one
already brings the interface up (or down), the subsequent instances
can simply return without redoing the up/down operation.

Fixes: ed651a10875f ("ibmvnic: Updated reset handling")
Reported-by: Abdul Haleem <abdhalee@...ibm.com>
Tested-by: Abdul Haleem <abdhalee@...ibm.com>
Signed-off-by: Sukadev Bhattiprolu <sukadev@...ux.ibm.com>

---
Changelog[v2] For consistency with ibmvnic_open() use "goto out" and return
	      from end of function.
---
 drivers/net/ethernet/ibm/ibmvnic.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c
index 78d244aeee69..df1b4884b4e8 100644
--- a/drivers/net/ethernet/ibm/ibmvnic.c
+++ b/drivers/net/ethernet/ibm/ibmvnic.c
@@ -1219,6 +1219,14 @@ static int ibmvnic_open(struct net_device *netdev)
 		goto out;
 	}
 
+	/* If adapter is already open, we don't have to do anything. */
+	if (adapter->state == VNIC_OPEN) {
+		netdev_dbg(netdev, "[S:%d] adapter already open\n",
+			   adapter->state);
+		rc = 0;
+		goto out;
+	}
+
 	if (adapter->state != VNIC_CLOSED) {
 		rc = ibmvnic_login(netdev);
 		if (rc)
@@ -1392,6 +1400,12 @@ static int ibmvnic_close(struct net_device *netdev)
 		return 0;
 	}
 
+	/* If adapter is already closed, we don't have to do anything. */
+	if (adapter->state == VNIC_CLOSED) {
+		netdev_dbg(netdev, "[S:%d] adapter already closed\n",
+			   adapter->state);
+		return 0;
+	}
 	rc = __ibmvnic_close(netdev);
 	ibmvnic_cleanup(netdev);
 
-- 
2.26.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ