diff options
author | Roland Dreier <roland@purestorage.com> | 2013-02-08 18:18:40 -0500 |
---|---|---|
committer | Nicholas Bellinger <nab@linux-iscsi.org> | 2013-02-13 15:16:11 -0500 |
commit | 71f41fe1fafae2e407ef19d8174207f7ff80b387 (patch) | |
tree | e780f1e3fcfec59f5ff3f876d8850843d52b442c /drivers/target | |
parent | bb992e72f9b751fceb04afeb7736b6a3e50effcf (diff) |
target: Fix parameter list length checking in MODE SELECT
An empty parameter list (length == 0) is not an error, so succeed MODE
SELECT in this case. If the parameter list length is too small,
return the correct sense code of PARAMETER LIST LENGTH ERROR.
Signed-off-by: Roland Dreier <roland@purestorage.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'drivers/target')
-rw-r--r-- | drivers/target/target_core_spc.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/drivers/target/target_core_spc.c b/drivers/target/target_core_spc.c index 803339516fb9..4cb667d720a7 100644 --- a/drivers/target/target_core_spc.c +++ b/drivers/target/target_core_spc.c | |||
@@ -1000,6 +1000,14 @@ static sense_reason_t spc_emulate_modeselect(struct se_cmd *cmd) | |||
1000 | int ret = 0; | 1000 | int ret = 0; |
1001 | int i; | 1001 | int i; |
1002 | 1002 | ||
1003 | if (!cmd->data_length) { | ||
1004 | target_complete_cmd(cmd, GOOD); | ||
1005 | return 0; | ||
1006 | } | ||
1007 | |||
1008 | if (cmd->data_length < off + 2) | ||
1009 | return TCM_PARAMETER_LIST_LENGTH_ERROR; | ||
1010 | |||
1003 | buf = transport_kmap_data_sg(cmd); | 1011 | buf = transport_kmap_data_sg(cmd); |
1004 | if (!buf) | 1012 | if (!buf) |
1005 | return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; | 1013 | return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; |
@@ -1024,6 +1032,11 @@ static sense_reason_t spc_emulate_modeselect(struct se_cmd *cmd) | |||
1024 | goto out; | 1032 | goto out; |
1025 | 1033 | ||
1026 | check_contents: | 1034 | check_contents: |
1035 | if (cmd->data_length < off + length) { | ||
1036 | ret = TCM_PARAMETER_LIST_LENGTH_ERROR; | ||
1037 | goto out; | ||
1038 | } | ||
1039 | |||
1027 | if (memcmp(buf + off, tbuf, length)) | 1040 | if (memcmp(buf + off, tbuf, length)) |
1028 | ret = TCM_INVALID_PARAMETER_LIST; | 1041 | ret = TCM_INVALID_PARAMETER_LIST; |
1029 | 1042 | ||