diff options
| author | Nicholas Bellinger <nab@linux-iscsi.org> | 2015-11-05 23:37:59 -0800 |
|---|---|---|
| committer | Luis Henriques <luis.henriques@canonical.com> | 2015-12-18 16:06:38 +0000 |
| commit | 2f3897ea9496058fa0a43e126bf886aae8ea9751 (patch) | |
| tree | 28a448e50ff778e33b410ef5a785b5bb52dbc0b5 /include | |
| parent | 74191936167ed0d79904ef1b4319aab4dfc5e9d8 (diff) | |
target: Fix race for SCF_COMPARE_AND_WRITE_POST checking
commit 057085e522f8bf94c2e691a5b76880f68060f8ba upstream.
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>
[ luis: backported to 3.16: adjusted context ]
Signed-off-by: Luis Henriques <luis.henriques@canonical.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 edfd69a25884..0c37d70a4f57 100644 --- a/include/target/target_core_base.h +++ b/include/target/target_core_base.h @@ -518,7 +518,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]; |
