From: Dany Madden <drt@linux.ibm.com>
To: netdev@vger.kernel.org
Cc: ljp@linux.ibm.com, sukadev@linux.ibm.com, linuxppc-dev@lists.ozlabs.org
Subject: [PATCH net v3 6/9] ibmvnic: track pending login
Date: Wed, 25 Nov 2020 18:04:29 -0600 [thread overview]
Message-ID: <20201126000432.29897-7-drt@linux.ibm.com> (raw)
In-Reply-To: <20201126000432.29897-1-drt@linux.ibm.com>
From: Sukadev Bhattiprolu <sukadev@linux.ibm.com>
If after ibmvnic sends a LOGIN it gets a FAILOVER, it is possible that
the worker thread will start reset process and free the login response
buffer before it gets a (now stale) LOGIN_RSP. The ibmvnic tasklet will
then try to access the login response buffer and crash.
Have ibmvnic track pending logins and discard any stale login responses.
Fixes: 032c5e82847a ("Driver for IBM System i/p VNIC protocol")
Signed-off-by: Sukadev Bhattiprolu <sukadev@linux.ibm.com>
---
drivers/net/ethernet/ibm/ibmvnic.c | 17 +++++++++++++++++
drivers/net/ethernet/ibm/ibmvnic.h | 1 +
2 files changed, 18 insertions(+)
diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c
index e2f9b0e9dea8..55b07bd4c741 100644
--- a/drivers/net/ethernet/ibm/ibmvnic.c
+++ b/drivers/net/ethernet/ibm/ibmvnic.c
@@ -3839,6 +3839,8 @@ static int send_login(struct ibmvnic_adapter *adapter)
crq.login.cmd = LOGIN;
crq.login.ioba = cpu_to_be32(buffer_token);
crq.login.len = cpu_to_be32(buffer_size);
+
+ adapter->login_pending = true;
ibmvnic_send_crq(adapter, &crq);
return 0;
@@ -4391,6 +4393,15 @@ static int handle_login_rsp(union ibmvnic_crq *login_rsp_crq,
u64 *size_array;
int i;
+ /* CHECK: Test/set of login_pending does not need to be atomic
+ * because only ibmvnic_tasklet tests/clears this.
+ */
+ if (!adapter->login_pending) {
+ netdev_warn(netdev, "Ignoring unexpected login response\n");
+ return 0;
+ }
+ adapter->login_pending = false;
+
dma_unmap_single(dev, adapter->login_buf_token, adapter->login_buf_sz,
DMA_TO_DEVICE);
dma_unmap_single(dev, adapter->login_rsp_buf_token,
@@ -4762,6 +4773,11 @@ static void ibmvnic_handle_crq(union ibmvnic_crq *crq,
case IBMVNIC_CRQ_INIT:
dev_info(dev, "Partner initialized\n");
adapter->from_passive_init = true;
+ /* Discard any stale login responses from prev reset.
+ * CHECK: should we clear even on INIT_COMPLETE?
+ */
+ adapter->login_pending = false;
+
if (!completion_done(&adapter->init_done)) {
complete(&adapter->init_done);
adapter->init_done_rc = -EIO;
@@ -5191,6 +5207,7 @@ static int ibmvnic_probe(struct vio_dev *dev, const struct vio_device_id *id)
dev_set_drvdata(&dev->dev, netdev);
adapter->vdev = dev;
adapter->netdev = netdev;
+ adapter->login_pending = false;
ether_addr_copy(adapter->mac_addr, mac_addr_p);
ether_addr_copy(netdev->dev_addr, adapter->mac_addr);
diff --git a/drivers/net/ethernet/ibm/ibmvnic.h b/drivers/net/ethernet/ibm/ibmvnic.h
index 217dcc7ded70..6f0a701c4a38 100644
--- a/drivers/net/ethernet/ibm/ibmvnic.h
+++ b/drivers/net/ethernet/ibm/ibmvnic.h
@@ -1087,6 +1087,7 @@ struct ibmvnic_adapter {
struct delayed_work ibmvnic_delayed_reset;
unsigned long resetting;
bool napi_enabled, from_passive_init;
+ bool login_pending;
bool failover_pending;
bool force_reset_recovery;
--
2.26.2
next prev parent reply other threads:[~2020-11-26 0:09 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-26 0:04 [PATCH net v3 0/9] ibmvnic: assorted bug fixes Dany Madden
2020-11-26 0:04 ` [PATCH net v3 1/9] ibmvnic: handle inconsistent login with reset Dany Madden
2020-11-26 0:04 ` [PATCH net v3 2/9] ibmvnic: stop free_all_rwi on failed reset Dany Madden
2020-11-26 0:04 ` [PATCH net v3 3/9] ibmvnic: avoid memset null scrq msgs Dany Madden
2020-11-26 0:04 ` [PATCH net v3 4/9] ibmvnic: restore adapter state on failed reset Dany Madden
2020-11-26 0:04 ` [PATCH net v3 5/9] ibmvnic: delay next reset if hard reset fails Dany Madden
2020-11-26 0:04 ` Dany Madden [this message]
2020-11-26 0:04 ` [PATCH net v3 7/9] ibmvnic: send_login should check for crq errors Dany Madden
2020-11-26 0:04 ` [PATCH net v3 8/9] ibmvnic: no reset timeout for 5 seconds after reset Dany Madden
2020-11-26 0:04 ` [PATCH net v3 9/9] ibmvnic: reduce wait for completion time Dany Madden
2020-11-28 21:32 ` [PATCH net v3 0/9] ibmvnic: assorted bug fixes Jakub Kicinski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201126000432.29897-7-drt@linux.ibm.com \
--to=drt@linux.ibm.com \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=ljp@linux.ibm.com \
--cc=netdev@vger.kernel.org \
--cc=sukadev@linux.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).