linux/drivers/target
Nicholas Bellinger 690309746f target: Fix COMPARE_AND_WRITE ref leak for non GOOD status
commit 9b2792c3da upstream.

This patch addresses a long standing bug where the commit phase
of COMPARE_AND_WRITE would result in a se_cmd->cmd_kref reference
leak if se_cmd->scsi_status returned non SAM_STAT_GOOD.

This would manifest first as a lost SCSI response, and eventual
hung task during fabric driver logout or re-login, as existing
shutdown logic waited for the COMPARE_AND_WRITE se_cmd->cmd_kref
to reach zero.

To address this bug, compare_and_write_post() has been changed
to drop the incorrect !cmd->scsi_status conditional that was
preventing *post_ret = 1 for being set during non SAM_STAT_GOOD
status.

This patch has been tested with SAM_STAT_CHECK_CONDITION status
from normal target_complete_cmd() callback path, as well as the
incoming __target_execute_cmd() submission failure path when
se_cmd->execute_cmd() returns non zero status.

Reported-by: Donald White <dew@datera.io>
Cc: Donald White <dew@datera.io>
Tested-by: Gary Guo <ghg@datera.io>
Cc: Gary Guo <ghg@datera.io>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
History 2017-03-16 02:27:11 +00:00
..
iscsi target/iscsi: Fix double free in lio_target_tiqn_addtpg() 2017-03-16 02:26:37 +00:00
loopback tcm_loop: Fixup tag handling 2015-01-22 16:33:35 +00:00
sbp target: Pass in transport supported PI at session initialization 2014-04-07 01:48:54 -07:00
tcm_fc tcm_fc: missing curly braces in ft_invl_hw_context() 2015-03-30 11:11:42 +01:00
Kconfig target/iblock: Add blk_integrity + BIP passthrough support 2014-01-18 10:14:22 +00:00
Makefile target: Add support for EXTENDED_COPY copy offload emulation 2013-09-10 16:48:43 -07:00
target_core_alua.c Merge branch 'next' (accumulated 3.16 merge window patches) into master 2014-06-08 11:31:16 -07:00
target_core_alua.h target_core_alua: Referrals configfs integration 2014-01-09 21:48:35 -08:00
target_core_configfs.c target: Fix a memory leak in target_dev_lba_map_store() 2016-02-02 19:48:58 +00:00
target_core_device.c target: Fix max_unmap_lba_count calc overflow 2016-11-20 01:16:55 +00:00
target_core_fabric_configfs.c target: Fix sizeof in kmalloc for some default_groups arrays 2013-12-16 12:42:20 -08:00
target_core_fabric_lib.c target: Update copyright ownership/year information to 2013 2013-09-10 20:23:36 -07:00
target_core_file.c target: Fix max_unmap_lba_count calc overflow 2016-11-20 01:16:55 +00:00
target_core_file.h Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending 2014-01-31 15:31:23 -08:00
target_core_hba.c target: Update copyright ownership/year information to 2013 2013-09-10 20:23:36 -07:00
target_core_iblock.c target: Fix max_unmap_lba_count calc overflow 2016-11-20 01:16:55 +00:00
target_core_iblock.h target: kill struct se_subsystem_dev 2012-11-06 20:55:43 -08:00
target_core_internal.h target/configfs: Expose protection device attributes 2014-01-18 09:57:47 +00:00
target_core_pr.c target: Allow Write Exclusive non-reservation holders to READ 2015-03-03 14:24:08 +00:00
target_core_pr.h target: Fix APTPL metadata handling for dynamic MappedLUNs 2014-11-05 11:43:05 +00:00
target_core_pscsi.c target/pscsi: Don't leak scsi_host if hba is VIRTUAL_HOST 2015-06-03 14:30:06 +01:00
target_core_pscsi.h target/pscsi: Don't leak scsi_host if hba is VIRTUAL_HOST 2015-06-03 14:30:06 +01:00
target_core_rd.c target/rd: T10-Dif: RAM disk is allocating more space than required. 2014-04-07 01:48:53 -07:00
target_core_rd.h target/rd: Add support for protection SGL setup + release 2014-01-19 02:22:05 +00:00
target_core_sbc.c target: Fix COMPARE_AND_WRITE ref leak for non GOOD status 2017-03-16 02:27:11 +00:00
target_core_spc.c target: REPORT LUNS should return LUN 0 even for dynamic ACLs 2015-08-31 14:14:07 +01:00
target_core_stat.c target: Convert se_device statistics to atomic_long_t 2013-11-13 18:34:55 -08:00
target_core_tmr.c target: Drop incorrect ABORT_TASK put for completed commands 2016-03-24 10:01:10 +00:00
target_core_tpg.c target: Fix APTPL metadata handling for dynamic MappedLUNs 2014-11-05 11:43:05 +00:00
target_core_transport.c target: Fix early transport_generic_handle_tmr abort scenario 2017-03-16 02:27:11 +00:00
target_core_ua.c arch: Mass conversion of smp_mb__*() 2014-04-18 14:20:48 +02:00
target_core_ua.h target core: rename (ex,im)plict -> (ex,im)plicit 2013-11-20 11:24:40 -08:00
target_core_xcopy.c target: Use correct SCSI status during EXTENDED_COPY exception 2017-03-16 02:27:11 +00:00
target_core_xcopy.h target: Add support for EXTENDED_COPY copy offload emulation 2013-09-10 16:48:43 -07:00