scsi: lpfc: nvmet: Avoid hang / use-after-free again when destroying targetport
commitda14c05ad875337cc73aa806f35e8f4297c28623
authorEwan D. Milne <emilne@redhat.com>
Wed, 29 Jul 2020 23:10:11 +0000 (29 19:10 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 21 Aug 2020 11:05:35 +0000 (21 13:05 +0200)
tree456d8eeeef9f25bd99131feec5aa5ab71b5f33a2
parentc9220ff3b9cc39e6f2607ee0ddd65d2b9d774cfb
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>
drivers/scsi/lpfc/lpfc_nvmet.c