summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEwan D. Milne <emilne@redhat.com>2020-07-29 19:10:11 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-08-21 13:07:39 +0200
commit4c6b5e4fff8ba115f96167a9ee6e23350d76bb0b (patch)
tree95d3711f9e0ae0762dff711268cdf5a0406b3321
parentdcce29b71001dab8af7dde8aefeeec7ea0f309fb (diff)
downloadlinux-4c6b5e4fff8ba115f96167a9ee6e23350d76bb0b.tar.gz
linux-4c6b5e4fff8ba115f96167a9ee6e23350d76bb0b.tar.bz2
linux-4c6b5e4fff8ba115f96167a9ee6e23350d76bb0b.zip
scsi: lpfc: nvmet: Avoid hang / use-after-free again when destroying targetport
[ Upstream commit af6de8c60fe9433afa73cea6fcccdccd98ad3e5e ] We cannot wait on a completion object in the lpfc_nvme_targetport structure in the _destroy_targetport() code path because the NVMe/fc transport will free that structure immediately after the .targetport_delete() callback. This results in a use-after-free, and a crash if slub_debug=FZPU is enabled. An earlier fix put put the completion on the stack, but commit 2a0fb340fcc8 ("scsi: lpfc: Correct localport timeout duration error") subsequently changed the code to reference the completion through a pointer in the object rather than the local stack variable. Fix this by using the stack variable directly. Link: https://lore.kernel.org/r/20200729231011.13240-1-emilne@redhat.com Fixes: 2a0fb340fcc8 ("scsi: lpfc: Correct localport timeout duration error") Reviewed-by: James Smart <james.smart@broadcom.com> Signed-off-by: Ewan D. Milne <emilne@redhat.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r--drivers/scsi/lpfc/lpfc_nvmet.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/scsi/lpfc/lpfc_nvmet.c b/drivers/scsi/lpfc/lpfc_nvmet.c
index 565419bf8d74..40b2df6e304a 100644
--- a/drivers/scsi/lpfc/lpfc_nvmet.c
+++ b/drivers/scsi/lpfc/lpfc_nvmet.c
@@ -1914,7 +1914,7 @@ lpfc_nvmet_destroy_targetport(struct lpfc_hba *phba)
}
tgtp->tport_unreg_cmp = &tport_unreg_cmp;
nvmet_fc_unregister_targetport(phba->targetport);
- if (!wait_for_completion_timeout(tgtp->tport_unreg_cmp,
+ if (!wait_for_completion_timeout(&tport_unreg_cmp,
msecs_to_jiffies(LPFC_NVMET_WAIT_TMO)))
lpfc_printf_log(phba, KERN_ERR, LOG_NVME,
"6179 Unreg targetport x%px timeout "