Commit 95f8f6a9 authored by David Disseldorp's avatar David Disseldorp Committed by Martin K. Petersen

scsi: target: fix SendTargets=All string compares

strncmp is currently used for "SendTargets" key and "All" value matching
without checking for trailing garbage. This means that Text request PDUs
with garbage such as "SendTargetsPlease=All" and "SendTargets=Alle" are
processed successfully as if they were "SendTargets=All" requests.
Reviewed-by: default avatarMike Christie <mchristi@redhat.com>
Signed-off-by: default avatarDavid Disseldorp <ddiss@suse.de>
Link: https://lore.kernel.org/r/20190912095547.22427-3-ddiss@suse.deSigned-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 9cef2a79
...@@ -2189,24 +2189,22 @@ iscsit_process_text_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd, ...@@ -2189,24 +2189,22 @@ iscsit_process_text_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd,
} }
goto empty_sendtargets; goto empty_sendtargets;
} }
if (strncmp("SendTargets", text_in, 11) != 0) { if (strncmp("SendTargets=", text_in, 12) != 0) {
pr_err("Received Text Data that is not" pr_err("Received Text Data that is not"
" SendTargets, cannot continue.\n"); " SendTargets, cannot continue.\n");
goto reject; goto reject;
} }
/* '=' confirmed in strncmp */
text_ptr = strchr(text_in, '='); text_ptr = strchr(text_in, '=');
if (!text_ptr) { BUG_ON(!text_ptr);
pr_err("No \"=\" separator found in Text Data," if (!strncmp("=All", text_ptr, 5)) {
" cannot continue.\n");
goto reject;
}
if (!strncmp("=All", text_ptr, 4)) {
cmd->cmd_flags |= ICF_SENDTARGETS_ALL; cmd->cmd_flags |= ICF_SENDTARGETS_ALL;
} else if (!strncmp("=iqn.", text_ptr, 5) || } else if (!strncmp("=iqn.", text_ptr, 5) ||
!strncmp("=eui.", text_ptr, 5)) { !strncmp("=eui.", text_ptr, 5)) {
cmd->cmd_flags |= ICF_SENDTARGETS_SINGLE; cmd->cmd_flags |= ICF_SENDTARGETS_SINGLE;
} else { } else {
pr_err("Unable to locate valid SendTargets=%s value\n", text_ptr); pr_err("Unable to locate valid SendTargets%s value\n",
text_ptr);
goto reject; goto reject;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment