linux/drivers/target
Nicholas Bellinger 057085e522 target: Fix race for SCF_COMPARE_AND_WRITE_POST checking
This patch addresses a race + use after free where the first
stage of COMPARE_AND_WRITE in compare_and_write_callback()
is rescheduled after the backend sends the secondary WRITE,
resulting in second stage compare_and_write_post() callback
completing in target_complete_ok_work() before the first
can return.

Because current code depends on checking se_cmd->se_cmd_flags
after return from se_cmd->transport_complete_callback(),
this results in first stage having SCF_COMPARE_AND_WRITE_POST
set, which incorrectly falls through into second stage CAW
processing code, eventually triggering a NULL pointer
dereference due to use after free.

To address this bug, pass in a new *post_ret parameter into
se_cmd->transport_complete_callback(), and depend upon this
value instead of ->se_cmd_flags to determine when to return
or fall through into ->queue_status() code for CAW.

Cc: Sagi Grimberg <sagig@mellanox.com>
Cc: <stable@vger.kernel.org> # v3.12+
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
2015-11-28 19:33:15 -08:00
..
iscsi iscsi-target: Fix rx_login_comp hang after login failure 2015-11-28 19:33:08 -08:00
loopback SCSI misc on 20151113 2015-11-13 20:35:54 -08:00
sbp target: use per-attribute show and store methods 2015-10-13 22:17:49 -07:00
tcm_fc target: use per-attribute show and store methods 2015-10-13 22:17:49 -07:00
Kconfig target: Put TCMU under a new config option 2015-04-19 22:41:12 -07:00
Makefile target: Put TCMU under a new config option 2015-04-19 22:41:12 -07:00
target_core_alua.c Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending 2015-07-04 14:13:43 -07:00
target_core_alua.h target: Subsume se_port + t10_alua_tg_pt_gp_member into se_lun 2015-06-01 00:26:38 -07:00
target_core_configfs.c target: use per-attribute show and store methods 2015-10-13 22:17:49 -07:00
target_core_device.c target: Make TCM_WRITE_PROTECT failure honor D_SENSE bit 2015-09-24 23:17:27 -07:00
target_core_fabric_configfs.c target: use per-attribute show and store methods 2015-10-13 22:17:49 -07:00
target_core_fabric_lib.c Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending 2015-07-04 14:13:43 -07:00
target_core_file.c Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending 2015-07-04 14:13:43 -07:00
target_core_file.h target/file: Remove fd_prot bounce buffer 2015-05-30 22:41:42 -07:00
target_core_hba.c target: Fix target_sense_desc_format NULL pointer dereference 2015-09-24 23:17:23 -07:00
target_core_iblock.c block: Consolidate static integrity profile properties 2015-10-21 14:42:38 -06:00
target_core_iblock.h
target_core_internal.h target: use per-attribute show and store methods 2015-10-13 22:17:49 -07:00
target_core_pr.c target: Fix PR registration + APTPL RCU conversion regression 2015-09-24 23:17:07 -07:00
target_core_pr.h target: use 64-bit LUNs 2015-06-15 23:26:01 -07:00
target_core_pscsi.c block: add a bi_error field to struct bio 2015-07-29 08:55:15 -06:00
target_core_pscsi.h SCSI misc on 20150622 2015-06-23 15:55:44 -07:00
target_core_rd.c Merge branch 'for-4.3/sg' of git://git.kernel.dk/linux-block 2015-09-02 13:22:38 -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 race for SCF_COMPARE_AND_WRITE_POST checking 2015-11-28 19:33:15 -08:00
target_core_spc.c Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending 2015-09-11 19:00:42 -07:00
target_core_stat.c target: use per-attribute show and store methods 2015-10-13 22:17:49 -07:00
target_core_tmr.c Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending 2015-07-04 14:13:43 -07:00
target_core_tpg.c target: Propigate backend read-only to core_tpg_add_lun 2015-09-24 23:17:21 -07:00
target_core_transport.c target: Fix race for SCF_COMPARE_AND_WRITE_POST checking 2015-11-28 19:33:15 -08:00
target_core_ua.c Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending 2015-07-04 14:13:43 -07:00
target_core_ua.h target: Send UA when changing LUN inventory 2015-06-23 00:43:02 -07:00
target_core_user.c target/user: Do not set unused fields in tcmu_ops 2015-11-28 19:32:52 -08:00
target_core_xcopy.c target: Attach EXTENDED_COPY local I/O descriptors to xcopy_pt_sess 2015-09-11 00:32:26 -07:00
target_core_xcopy.h target: Add support for EXTENDED_COPY copy offload emulation 2013-09-10 16:48:43 -07:00