From: Brian King <brking@linux.vnet.ibm.com> To: linux-scsi@vger.kernel.org Cc: tyreld@linux.ibm.com, linuxppc-dev@lists.ozlabs.org, martin.petersen@oracle.com, Brian King <brking@linux.vnet.ibm.com> Subject: [PATCH] ibmvfc: Protect vhost->task_set increment by the host lock Date: Wed, 16 Sep 2020 15:09:59 -0500 [thread overview] Message-ID: <1600286999-22059-1-git-send-email-brking@linux.vnet.ibm.com> (raw) In the discovery thread, ibmvfc does a vhost->task_set++ without any lock held. This could result in two targets getting the same cancel key, which could have strange effects in error recovery. The actual probability of this occurring should be extremely small, since this should all be done in a single threaded loop from the discovery thread, but let's fix it up anyway to be safe. Signed-off-by: Brian King <brking@linux.vnet.ibm.com> --- drivers/scsi/ibmvscsi/ibmvfc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/ibmvscsi/ibmvfc.c b/drivers/scsi/ibmvscsi/ibmvfc.c index 322bb30..b393587 100644 --- a/drivers/scsi/ibmvscsi/ibmvfc.c +++ b/drivers/scsi/ibmvscsi/ibmvfc.c @@ -4169,11 +4169,11 @@ static int ibmvfc_alloc_target(struct ibmvfc_host *vhost,struct ibmvfc_discover_ tgt->wwpn = wwpn; tgt->vhost = vhost; tgt->need_login = 1; - tgt->cancel_key = vhost->task_set++; timer_setup(&tgt->timer, ibmvfc_adisc_timeout, 0); kref_init(&tgt->kref); ibmvfc_init_tgt(tgt, ibmvfc_tgt_implicit_logout); spin_lock_irqsave(vhost->host->host_lock, flags); + tgt->cancel_key = vhost->task_set++; list_add_tail(&tgt->queue, &vhost->targets); unlock_out: -- 1.8.3.1
WARNING: multiple messages have this Message-ID (diff)
From: Brian King <brking@linux.vnet.ibm.com> To: linux-scsi@vger.kernel.org Cc: Brian King <brking@linux.vnet.ibm.com>, tyreld@linux.ibm.com, linuxppc-dev@lists.ozlabs.org, martin.petersen@oracle.com Subject: [PATCH] ibmvfc: Protect vhost->task_set increment by the host lock Date: Wed, 16 Sep 2020 15:09:59 -0500 [thread overview] Message-ID: <1600286999-22059-1-git-send-email-brking@linux.vnet.ibm.com> (raw) In the discovery thread, ibmvfc does a vhost->task_set++ without any lock held. This could result in two targets getting the same cancel key, which could have strange effects in error recovery. The actual probability of this occurring should be extremely small, since this should all be done in a single threaded loop from the discovery thread, but let's fix it up anyway to be safe. Signed-off-by: Brian King <brking@linux.vnet.ibm.com> --- drivers/scsi/ibmvscsi/ibmvfc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/ibmvscsi/ibmvfc.c b/drivers/scsi/ibmvscsi/ibmvfc.c index 322bb30..b393587 100644 --- a/drivers/scsi/ibmvscsi/ibmvfc.c +++ b/drivers/scsi/ibmvscsi/ibmvfc.c @@ -4169,11 +4169,11 @@ static int ibmvfc_alloc_target(struct ibmvfc_host *vhost,struct ibmvfc_discover_ tgt->wwpn = wwpn; tgt->vhost = vhost; tgt->need_login = 1; - tgt->cancel_key = vhost->task_set++; timer_setup(&tgt->timer, ibmvfc_adisc_timeout, 0); kref_init(&tgt->kref); ibmvfc_init_tgt(tgt, ibmvfc_tgt_implicit_logout); spin_lock_irqsave(vhost->host->host_lock, flags); + tgt->cancel_key = vhost->task_set++; list_add_tail(&tgt->queue, &vhost->targets); unlock_out: -- 1.8.3.1
next reply other threads:[~2020-09-16 20:11 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-09-16 20:09 Brian King [this message] 2020-09-16 20:09 ` [PATCH] ibmvfc: Protect vhost->task_set increment by the host lock Brian King 2020-09-22 21:39 ` Martin K. Petersen 2020-09-22 21:39 ` Martin K. Petersen 2020-09-30 3:34 ` Martin K. Petersen 2020-09-30 3:34 ` 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=1600286999-22059-1-git-send-email-brking@linux.vnet.ibm.com \ --to=brking@linux.vnet.ibm.com \ --cc=linux-scsi@vger.kernel.org \ --cc=linuxppc-dev@lists.ozlabs.org \ --cc=martin.petersen@oracle.com \ --cc=tyreld@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: linkBe 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.