diff options
author | Nicholas Bellinger <nab@linux-iscsi.org> | 2015-11-05 23:37:59 -0800 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2016-03-03 15:06:49 -0800 |
commit | 99853deb97618d86d663b9e22ed9968f7461957b (patch) | |
tree | eb5f7787de1c2fa64d0442f2f41dad64cb000732 /include | |
parent | d2ac4bf5d05b52a428ee7f8cdadd09fc96d66537 (diff) | |
download | lwn-99853deb97618d86d663b9e22ed9968f7461957b.tar.gz lwn-99853deb97618d86d663b9e22ed9968f7461957b.zip |
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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
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 e4b9e011d2a1..42606764d830 100644 --- a/include/target/target_core_base.h +++ b/include/target/target_core_base.h @@ -513,7 +513,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]; |