OrangePi_CM5/drivers/scsi/pm8001
John Garry fe9ac3eaa2 scsi: pm8001: Fix use-after-free for aborted SSP/STP sas_task
[ Upstream commit df7abcaa1246e2537ab4016077b5443bb3c09378 ]

Currently a use-after-free may occur if a sas_task is aborted by the upper
layer before we handle the I/O completion in mpi_ssp_completion() or
mpi_sata_completion().

In this case, the following are the two steps in handling those I/O
completions:

 - Call complete() to inform the upper layer handler of completion of
   the I/O.

 - Release driver resources associated with the sas_task in
   pm8001_ccb_task_free() call.

When complete() is called, the upper layer may free the sas_task. As such,
we should not touch the associated sas_task afterwards, but we do so in the
pm8001_ccb_task_free() call.

Fix by swapping the complete() and pm8001_ccb_task_free() calls ordering.

Link: https://lore.kernel.org/r/1643289172-165636-4-git-send-email-john.garry@huawei.com
Reviewed-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
Acked-by: Jack Wang <jinpu.wang@ionos.com>
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-02-23 12:00:59 +01:00
..
Makefile
…
pm80xx_hwi.c scsi: pm8001: Fix use-after-free for aborted SSP/STP sas_task 2022-02-23 12:00:59 +01:00
pm80xx_hwi.h scsi: pm8001: Fix bogus FW crash for maxcpus=1 2022-02-16 12:54:19 +01:00
pm8001_chips.h
…
pm8001_ctl.c scsi: pm8001: Neaten debug logging macros and uses 2021-03-25 09:04:11 +01:00
pm8001_ctl.h
…
pm8001_defs.h
…
pm8001_hwi.c scsi: pm80xx: Update WARN_ON check in pm8001_mpi_build_cmd() 2022-01-27 10:54:04 +01:00
pm8001_hwi.h
…
pm8001_init.c scsi: pm80xx: Do not call scsi_remove_host() in pm8001_alloc() 2021-12-14 11:32:40 +01:00
pm8001_sas.c scsi: pm8001: Fix use-after-free for aborted TMF sas_task 2022-02-23 12:00:59 +01:00
pm8001_sas.h scsi: pm8001: Neaten debug logging macros and uses 2021-03-25 09:04:11 +01:00