linux-stable/drivers/scsi/qla2xxx
Dmitry Bogdanov 4a8f71014b scsi: qla2xxx: Fix unmap of already freed sgl
The sgl is freed in the target stack in target_release_cmd_kref() before
calling qlt_free_cmd() but there is an unmap of sgl in qlt_free_cmd() that
causes a panic if sgl is not yet DMA unmapped:

NIP dma_direct_unmap_sg+0xdc/0x180
LR  dma_direct_unmap_sg+0xc8/0x180
Call Trace:
 ql_dbg_prefix+0x68/0xc0 [qla2xxx] (unreliable)
 dma_unmap_sg_attrs+0x54/0xf0
 qlt_unmap_sg.part.19+0x54/0x1c0 [qla2xxx]
 qlt_free_cmd+0x124/0x1d0 [qla2xxx]
 tcm_qla2xxx_release_cmd+0x4c/0xa0 [tcm_qla2xxx]
 target_put_sess_cmd+0x198/0x370 [target_core_mod]
 transport_generic_free_cmd+0x6c/0x1b0 [target_core_mod]
 tcm_qla2xxx_complete_free+0x6c/0x90 [tcm_qla2xxx]

The sgl may be left unmapped in error cases of response sending.  For
instance, qlt_rdy_to_xfer() maps sgl and exits when session is being
deleted keeping the sgl mapped.

This patch removes use-after-free of the sgl and ensures that the sgl is
unmapped for any command that was not sent to firmware.

Link: https://lore.kernel.org/r/20211018122650.11846-1-d.bogdanov@yadro.com
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Dmitry Bogdanov <d.bogdanov@yadro.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2021-10-18 23:19:44 -04:00
..
Kconfig
Makefile scsi: qla2xxx: edif: Add start + stop bsgs 2021-07-27 00:06:42 -04:00
qla_attr.c scsi: qla2xxx: Fix NVMe session down detection 2021-08-23 22:36:54 -04:00
qla_bsg.c scsi: qla2xxx: Fix a memory leak in an error path of qla2x00_process_els() 2021-10-18 23:04:31 -04:00
qla_bsg.h scsi: qla2xxx: edif: Add start + stop bsgs 2021-07-27 00:06:42 -04:00
qla_dbg.c scsi: qla2xxx: Changes to support FCP2 Target 2021-08-11 23:17:42 -04:00
qla_dbg.h scsi: qla2xxx: edif: Add start + stop bsgs 2021-07-27 00:06:42 -04:00
qla_def.h scsi: qla2xxx: Fix NVMe retry 2021-08-23 22:36:54 -04:00
qla_devtbl.h
qla_dfs.c scsi: qla2xxx: Remove unnecessary NULL check 2021-01-22 22:04:16 -05:00
qla_dsd.h
qla_edif.c scsi: qla2xxx: edif: Fix returnvar.cocci warnings 2021-08-23 22:36:54 -04:00
qla_edif.h scsi: qla2xxx: edif: Add N2N support for EDIF 2021-08-23 22:36:53 -04:00
qla_edif_bsg.h scsi: qla2xxx: edif: Add start + stop bsgs 2021-07-27 00:06:42 -04:00
qla_fw.h scsi: qla2xxx: edif: Add N2N support for EDIF 2021-08-23 22:36:53 -04:00
qla_gbl.h scsi: qla2xxx: edif: Add N2N support for EDIF 2021-08-23 22:36:53 -04:00
qla_gs.c scsi: qla2xxx: Fix NVMe retry 2021-08-23 22:36:54 -04:00
qla_init.c scsi: qla2xxx: Restore initiator in dual mode 2021-09-21 23:58:57 -04:00
qla_inline.h scsi: qla2xxx: edif: Add N2N support for EDIF 2021-08-23 22:36:53 -04:00
qla_iocb.c scsi: qla2xxx: edif: Do secure PLOGI when auth app is present 2021-08-23 22:36:53 -04:00
qla_isr.c scsi: qla2xxx: Fix excessive messages during device logout 2021-09-28 22:49:25 -04:00
qla_mbx.c scsi: qla2xxx: Fix NVMe session down detection 2021-08-23 22:36:54 -04:00
qla_mid.c scsi: qla2xxx: Fix unsafe removal from linked list 2021-08-11 23:17:56 -04:00
qla_mr.c scsi: qla2xxx: Suppress Coverity complaints about dseg_r* 2021-03-24 21:47:20 -04:00
qla_mr.h scsi: qla2xxx: Suppress Coverity complaints about dseg_r* 2021-03-24 21:47:20 -04:00
qla_nvme.c scsi: qla2xxx: Fix hang on NVMe command timeouts 2021-08-23 22:36:54 -04:00
qla_nvme.h SPDX patches for 5.10-rc1 2020-10-14 16:19:42 -07:00
qla_nx.c scsi: qla2xxx: Remove unused variable 'status' 2021-07-27 00:06:42 -04:00
qla_nx.h scsi/qla2xxx: Convert to SPDX license identifiers 2020-09-16 14:31:50 +02:00
qla_nx2.c scsi: qla2xxx: Simplify qla8044_minidump_process_control() 2021-03-24 21:47:21 -04:00
qla_nx2.h scsi/qla2xxx: Convert to SPDX license identifiers 2020-09-16 14:31:50 +02:00
qla_os.c scsi: qla2xxx: Return -ENOMEM if kzalloc() fails 2021-10-18 23:01:10 -04:00
qla_settings.h scsi/qla2xxx: Convert to SPDX license identifiers 2020-09-16 14:31:50 +02:00
qla_sup.c scsi: qla2xxx: Remove redundant continue statement in a for-loop 2021-07-18 21:31:28 -04:00
qla_target.c scsi: qla2xxx: Fix unmap of already freed sgl 2021-10-18 23:19:44 -04:00
qla_target.h scsi: qla2xxx: edif: Add encryption to I/O path 2021-07-27 00:06:43 -04:00
qla_tmpl.c SCSI misc on 20201216 2020-12-16 13:34:31 -08:00
qla_tmpl.h scsi: qla2xxx: Fix crash during driver load on big endian machines 2020-12-09 11:34:17 -05:00
qla_version.h scsi: qla2xxx: Update version to 10.02.06.200-k 2021-08-23 22:36:54 -04:00
tcm_qla2xxx.c Merge branch '5.12/scsi-fixes' into 5.13/scsi-staging 2021-04-05 22:57:29 -04:00
tcm_qla2xxx.h