diff options
author | Nicholas Bellinger <nab@linux-iscsi.org> | 2016-03-06 01:24:23 +0000 |
---|---|---|
committer | Sasha Levin <sasha.levin@oracle.com> | 2016-03-05 22:11:41 -0500 |
commit | 5dd73bb38031a5d8f81bf7d9b4f10135ab950f64 (patch) | |
tree | 943c52bcd76822fb63c05dc965bff018dd44cdac /include | |
parent | 4b4bc57ac1c2fd740f39e5849d45b9bcf6fbaf8b (diff) | |
download | lwn-5dd73bb38031a5d8f81bf7d9b4f10135ab950f64.tar.gz lwn-5dd73bb38031a5d8f81bf7d9b4f10135ab950f64.zip |
target: Fix race for SCF_COMPARE_AND_WRITE_POST checking
[ Upstream commit 057085e522f8bf94c2e691a5b76880f68060f8ba ]
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>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/target/target_core_base.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h index 480e9f82dfea..b7a0594efc7e 100644 --- a/include/target/target_core_base.h +++ b/include/target/target_core_base.h @@ -522,7 +522,7 @@ struct se_cmd { sense_reason_t (*execute_cmd)(struct se_cmd *); sense_reason_t (*execute_rw)(struct se_cmd *, struct scatterlist *, u32, enum dma_data_direction); - sense_reason_t (*transport_complete_callback)(struct se_cmd *, bool); + sense_reason_t (*transport_complete_callback)(struct se_cmd *, bool, int *); unsigned char *t_task_cdb; unsigned char __t_task_cdb[TCM_MAX_COMMAND_SIZE]; |