aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Seppanen <eric@purestorage.com>2013-11-20 17:19:52 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-12-04 13:56:15 -0500
commit6aec95b47deb9e3dad4cb2e6db87f3b03544224d (patch)
treecbcd2847d3c3b246b2697bf2dab3eb16157c0c44
parente97f132f0e66893138f64b681cddff2d2ff37b53 (diff)
iscsi-target: chap auth shouldn't match username with trailing garbage
commit 86784c6bdeeef78eed94d298be7a8879f6a97ee2 upstream. In iSCSI negotiations with initiator CHAP enabled, usernames with trailing garbage are permitted, because the string comparison only checks the strlen of the configured username. e.g. "usernameXXXXX" will be permitted to match "username". Just check one more byte so the trailing null char is also matched. Signed-off-by: Eric Seppanen <eric@purestorage.com> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/target/iscsi/iscsi_target_auth.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/target/iscsi/iscsi_target_auth.c b/drivers/target/iscsi/iscsi_target_auth.c
index cee17543278c..130a1e4f96a1 100644
--- a/drivers/target/iscsi/iscsi_target_auth.c
+++ b/drivers/target/iscsi/iscsi_target_auth.c
@@ -148,6 +148,7 @@ static int chap_server_compute_md5(
148 unsigned char client_digest[MD5_SIGNATURE_SIZE]; 148 unsigned char client_digest[MD5_SIGNATURE_SIZE];
149 unsigned char server_digest[MD5_SIGNATURE_SIZE]; 149 unsigned char server_digest[MD5_SIGNATURE_SIZE];
150 unsigned char chap_n[MAX_CHAP_N_SIZE], chap_r[MAX_RESPONSE_LENGTH]; 150 unsigned char chap_n[MAX_CHAP_N_SIZE], chap_r[MAX_RESPONSE_LENGTH];
151 size_t compare_len;
151 struct iscsi_chap *chap = conn->auth_protocol; 152 struct iscsi_chap *chap = conn->auth_protocol;
152 struct crypto_hash *tfm; 153 struct crypto_hash *tfm;
153 struct hash_desc desc; 154 struct hash_desc desc;
@@ -186,7 +187,9 @@ static int chap_server_compute_md5(
186 goto out; 187 goto out;
187 } 188 }
188 189
189 if (memcmp(chap_n, auth->userid, strlen(auth->userid)) != 0) { 190 /* Include the terminating NULL in the compare */
191 compare_len = strlen(auth->userid) + 1;
192 if (strncmp(chap_n, auth->userid, compare_len) != 0) {
190 pr_err("CHAP_N values do not match!\n"); 193 pr_err("CHAP_N values do not match!\n");
191 goto out; 194 goto out;
192 } 195 }