From: Vishnu Dasa <vdasa@vmware.com>
To: aditr@vmware.com, jgg@nvidia.com, dledford@redhat.com,
linux-rdma@vger.kernel.org, stable@vger.kernel.org
Cc: Vishnu Dasa <vdasa@vmware.com>, pv-drivers@vmware.com
Subject: [PATCH for-rc] RDMA/vmw_pvrdma: Correctly set and check device ib_active status
Date: Fri, 18 Sep 2020 02:38:59 +0000 [thread overview]
Message-ID: <20200918023859.22181-1-vdasa@vmware.com> (raw)
Avoid calling ib_dispatch_event on an inactive device in order to
prevent writing to invalid I/O mapped addresses which could cause a
guest crash.
Also, set the ib_active status to 'false' in pvrdma_pci_remove and
in the failure path of pvrdma_pci_probe.
Fixes: 29c8d9eba550 ("IB: Add vmw_pvrdma driver")
Acked-by: Adit Ranadive <aditr@vmware.com>
Signed-off-by: Vishnu Dasa <vdasa@vmware.com>
---
drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c b/drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c
index 780fd2dfc07e..ff4fd6e078e7 100644
--- a/drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c
+++ b/drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c
@@ -692,6 +692,16 @@ static void pvrdma_netdevice_event_handle(struct pvrdma_dev *dev,
struct pci_dev *pdev_net;
unsigned int slot;
+ /*
+ * Do not dispatch events if the device is inactive. Otherwise
+ * we'll try to ib_dispatch_event() on an invalid device.
+ */
+ if (!dev->ib_active) {
+ dev_dbg(&dev->pdev->dev, "ignore netdev event %ld on %s\n",
+ event, dev->ib_dev.name);
+ return;
+ }
+
switch (event) {
case NETDEV_REBOOT:
case NETDEV_DOWN:
@@ -1049,6 +1059,7 @@ static int pvrdma_pci_probe(struct pci_dev *pdev,
return 0;
err_unreg_ibdev:
+ dev->ib_active = false;
ib_unregister_device(&dev->ib_dev);
err_disable_intr:
pvrdma_disable_intrs(dev);
@@ -1108,6 +1119,7 @@ static void pvrdma_pci_remove(struct pci_dev *pdev)
}
/* Unregister ib device */
+ dev->ib_active = false;
ib_unregister_device(&dev->ib_dev);
mutex_lock(&pvrdma_device_list_lock);
--
2.18.4
next reply other threads:[~2020-09-18 2:39 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-18 2:38 Vishnu Dasa [this message]
2020-09-21 14:16 ` [PATCH for-rc] RDMA/vmw_pvrdma: Correctly set and check device ib_active status Jason Gunthorpe
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=20200918023859.22181-1-vdasa@vmware.com \
--to=vdasa@vmware.com \
--cc=aditr@vmware.com \
--cc=dledford@redhat.com \
--cc=jgg@nvidia.com \
--cc=linux-rdma@vger.kernel.org \
--cc=pv-drivers@vmware.com \
--cc=stable@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.