From: Roland Dreier <roland@kernel.org>
To: "Nicholas A. Bellinger" <nab@linux-iscsi.org>
Cc: target-devel@vger.kernel.org, linux-scsi@vger.kernel.org,
Roland Dreier <roland@purestorage.com>
Subject: [PATCH 3/3] target: Fix parameter list length checking in MODE SELECT
Date: Fri, 8 Feb 2013 15:18:40 -0800 [thread overview]
Message-ID: <1360365520-11972-3-git-send-email-roland@kernel.org> (raw)
In-Reply-To: <1360365520-11972-1-git-send-email-roland@kernel.org>
From: Roland Dreier <roland@purestorage.com>
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>
---
drivers/target/target_core_spc.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/drivers/target/target_core_spc.c b/drivers/target/target_core_spc.c
index 2d88f08..73c5d53 100644
--- a/drivers/target/target_core_spc.c
+++ b/drivers/target/target_core_spc.c
@@ -983,6 +983,14 @@ static sense_reason_t spc_emulate_modeselect(struct se_cmd *cmd)
int ret = 0;
int i;
+ if (!cmd->data_length) {
+ target_complete_cmd(cmd, GOOD);
+ return 0;
+ }
+
+ if (cmd->data_length < off + 2)
+ return TCM_PARAMETER_LIST_LENGTH_ERROR;
+
buf = transport_kmap_data_sg(cmd);
if (!buf)
return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
@@ -1007,6 +1015,11 @@ static sense_reason_t spc_emulate_modeselect(struct se_cmd *cmd)
goto out;
check_contents:
+ if (cmd->data_length < off + length) {
+ ret = TCM_PARAMETER_LIST_LENGTH_ERROR;
+ goto out;
+ }
+
if (memcmp(buf + off, tbuf, length))
ret = TCM_INVALID_PARAMETER_LIST;
--
1.8.1.2
next prev parent reply other threads:[~2013-02-08 23:18 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-08 23:18 [PATCH 1/3] target: Fix sense data for out-of-bounds IO operations Roland Dreier
2013-02-08 23:18 ` [PATCH 2/3] target: Fix error checking for UNMAP commands Roland Dreier
2013-02-09 9:23 ` Chris Boot
2013-02-09 19:27 ` Roland Dreier
2013-02-13 20:27 ` Nicholas A. Bellinger
2013-02-08 23:18 ` Roland Dreier [this message]
2013-02-13 20:27 ` [PATCH 3/3] target: Fix parameter list length checking in MODE SELECT Nicholas A. Bellinger
2013-02-13 20:26 ` [PATCH 1/3] target: Fix sense data for out-of-bounds IO operations Nicholas A. Bellinger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1360365520-11972-3-git-send-email-roland@kernel.org \
--to=roland@kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=nab@linux-iscsi.org \
--cc=roland@purestorage.com \
--cc=target-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).