public inbox for linuxppc-dev@ozlabs.org 
 help / color / mirror / Atom feed
From: Tyrel Datwyler <tyreld@linux•vnet.ibm.com>
To: james.bottomley@hansenpartnership•com
Cc: martin.petersen@oracle•com, linux-scsi@vger•kernel.org,
	stable@vger•kernel.org,
	Tyrel Datwyler <tyreld@linux•vnet.ibm.com>,
	brking@linux•vnet.ibm.com, linuxppc-dev@lists•ozlabs.org
Subject: [PATCH 1/2] ibmvscsi: Protect ibmvscsi_head from concurrent modificaiton
Date: Wed, 20 Mar 2019 13:41:50 -0500	[thread overview]
Message-ID: <20190320184151.31321-1-tyreld@linux.vnet.ibm.com> (raw)

For each ibmvscsi host created during a probe or destroyed during a
remove we either add or remove that host to/from the global ibmvscsi_head
list. This runs the risk of concurrent modification.

This patch adds a simple spinlock around the list modification calls to
prevent concurrent updates as is done similarly in the ibmvfc driver and
ipr driver.

Fixes: 32d6e4b6e4ea ("scsi: ibmvscsi: add vscsi hosts to global list_head")
Cc: <stable@vger•kernel.org> # v4.10+
Signed-off-by: Tyrel Datwyler <tyreld@linux•vnet.ibm.com>
---
 drivers/scsi/ibmvscsi/ibmvscsi.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/scsi/ibmvscsi/ibmvscsi.c b/drivers/scsi/ibmvscsi/ibmvscsi.c
index 1135e74646e2..2b22969f3f63 100644
--- a/drivers/scsi/ibmvscsi/ibmvscsi.c
+++ b/drivers/scsi/ibmvscsi/ibmvscsi.c
@@ -96,6 +96,7 @@ static int client_reserve = 1;
 static char partition_name[96] = "UNKNOWN";
 static unsigned int partition_number = -1;
 static LIST_HEAD(ibmvscsi_head);
+static DEFINE_SPINLOCK(ibmvscsi_driver_lock);
 
 static struct scsi_transport_template *ibmvscsi_transport_template;
 
@@ -2270,7 +2271,9 @@ static int ibmvscsi_probe(struct vio_dev *vdev, const struct vio_device_id *id)
 	}
 
 	dev_set_drvdata(&vdev->dev, hostdata);
+	spin_lock(&ibmvscsi_driver_lock);
 	list_add_tail(&hostdata->host_list, &ibmvscsi_head);
+	spin_unlock(&ibmvscsi_driver_lock);
 	return 0;
 
       add_srp_port_failed:
@@ -2292,7 +2295,9 @@ static int ibmvscsi_probe(struct vio_dev *vdev, const struct vio_device_id *id)
 static int ibmvscsi_remove(struct vio_dev *vdev)
 {
 	struct ibmvscsi_host_data *hostdata = dev_get_drvdata(&vdev->dev);
+	spin_lock(&ibmvscsi_driver_lock);
 	list_del(&hostdata->host_list);
+	spin_unlock(&ibmvscsi_driver_lock);
 	unmap_persist_bufs(hostdata);
 	release_event_pool(&hostdata->pool, hostdata);
 	ibmvscsi_release_crq_queue(&hostdata->queue, hostdata,
-- 
2.12.3


             reply	other threads:[~2019-03-20 23:51 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-20 18:41 Tyrel Datwyler [this message]
2019-03-20 18:41 ` [PATCH 2/2] ibmvscsi: Fix empty event pool access during host removal Tyrel Datwyler
2019-03-21  0:14   ` Martin K. Petersen
2019-03-21  0:13 ` [PATCH 1/2] ibmvscsi: Protect ibmvscsi_head from concurrent modificaiton Martin K. Petersen

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=20190320184151.31321-1-tyreld@linux.vnet.ibm.com \
    --to=tyreld@linux$(echo .)vnet.ibm.com \
    --cc=brking@linux$(echo .)vnet.ibm.com \
    --cc=james.bottomley@hansenpartnership$(echo .)com \
    --cc=linux-scsi@vger$(echo .)kernel.org \
    --cc=linuxppc-dev@lists$(echo .)ozlabs.org \
    --cc=martin.petersen@oracle$(echo .)com \
    --cc=stable@vger$(echo .)kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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