aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorMike Christie <michaelc@cs.wisc.edu>2005-11-30 03:27:19 -0500
committerJames Bottomley <jejb@mulgrave.(none)>2005-12-13 20:12:03 -0500
commit8a47cd340b4a299087f926ff2780d1eb08513f04 (patch)
treefab368465f0e187c0f3708385a4618eb115c76e0 /drivers
parent4d841d6bd94d55642f8dbb11d6b672b3b50ff82e (diff)
[SCSI] iscsi: check header digests for mgmt tasks
From Wang Zhenyu: check header digest for cmd and mgmt tasks Signed-off-by: Wang Zhenyu <zhenyu.z.wang@intel.com> Signed-off-by: Mike Christie <michaelc@cs.wisc.edu> Signed-off-by: Alex Aizman <itn780@yahoo.com> Signed-off-by: Dmitry Yusupov <dmitry_yus@yahoo.com> Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/scsi/iscsi_tcp.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c
index feb8731907c7..2d12355eed33 100644
--- a/drivers/scsi/iscsi_tcp.c
+++ b/drivers/scsi/iscsi_tcp.c
@@ -581,6 +581,12 @@ iscsi_hdr_recv(struct iscsi_conn *conn)
581 crypto_digest_digest(conn->rx_tfm, &sg, 1, (u8 *)&cdgst); 581 crypto_digest_digest(conn->rx_tfm, &sg, 1, (u8 *)&cdgst);
582 rdgst = *(uint32_t*)((char*)hdr + sizeof(struct iscsi_hdr) + 582 rdgst = *(uint32_t*)((char*)hdr + sizeof(struct iscsi_hdr) +
583 conn->in.ahslen); 583 conn->in.ahslen);
584 if (cdgst != rdgst) {
585 printk(KERN_ERR "iscsi_tcp: itt %x: hdrdgst error "
586 "recv 0x%x calc 0x%x\n", conn->in.itt, rdgst,
587 cdgst);
588 return ISCSI_ERR_HDR_DGST;
589 }
584 } 590 }
585 591
586 /* save opcode for later */ 592 /* save opcode for later */
@@ -610,13 +616,6 @@ iscsi_hdr_recv(struct iscsi_conn *conn)
610 conn->in.ahslen, conn->in.datalen); 616 conn->in.ahslen, conn->in.datalen);
611 617
612 if (conn->in.itt < session->cmds_max) { 618 if (conn->in.itt < session->cmds_max) {
613 if (conn->hdrdgst_en && cdgst != rdgst) {
614 printk(KERN_ERR "iscsi_tcp: itt %x: hdrdgst error "
615 "recv 0x%x calc 0x%x\n", conn->in.itt, rdgst,
616 cdgst);
617 return ISCSI_ERR_HDR_DGST;
618 }
619
620 ctask = (struct iscsi_cmd_task *)session->cmds[conn->in.itt]; 619 ctask = (struct iscsi_cmd_task *)session->cmds[conn->in.itt];
621 620
622 if (!ctask->sc) { 621 if (!ctask->sc) {
@@ -1128,8 +1127,7 @@ more:
1128 */ 1127 */
1129 rc = iscsi_hdr_recv(conn); 1128 rc = iscsi_hdr_recv(conn);
1130 if (!rc && conn->in.datalen) { 1129 if (!rc && conn->in.datalen) {
1131 if (conn->datadgst_en && 1130 if (conn->datadgst_en) {
1132 conn->in.opcode != ISCSI_OP_LOGIN_RSP) {
1133 BUG_ON(!conn->data_rx_tfm); 1131 BUG_ON(!conn->data_rx_tfm);
1134 crypto_digest_init(conn->data_rx_tfm); 1132 crypto_digest_init(conn->data_rx_tfm);
1135 } 1133 }
@@ -1179,8 +1177,7 @@ more:
1179 } 1177 }
1180 conn->in.copy -= conn->in.padding; 1178 conn->in.copy -= conn->in.padding;
1181 conn->in.offset += conn->in.padding; 1179 conn->in.offset += conn->in.padding;
1182 if (conn->datadgst_en && 1180 if (conn->datadgst_en) {
1183 conn->in.opcode != ISCSI_OP_LOGIN_RSP) {
1184 if (conn->in.padding) { 1181 if (conn->in.padding) {
1185 debug_tcp("padding -> %d\n", conn->in.padding); 1182 debug_tcp("padding -> %d\n", conn->in.padding);
1186 memset(pad, 0, conn->in.padding); 1183 memset(pad, 0, conn->in.padding);
@@ -2875,8 +2872,11 @@ iscsi_conn_stop(iscsi_connh_t connh, int flag)
2875 * in hdr_extract() and will be re-negotiated at 2872 * in hdr_extract() and will be re-negotiated at
2876 * set_param() time. 2873 * set_param() time.
2877 */ 2874 */
2878 if (flag == STOP_CONN_RECOVER) 2875 if (flag == STOP_CONN_RECOVER) {
2879 conn->hdr_size = sizeof(struct iscsi_hdr); 2876 conn->hdr_size = sizeof(struct iscsi_hdr);
2877 conn->hdrdgst_en = 0;
2878 conn->datadgst_en = 0;
2879 }
2880 } 2880 }
2881 up(&conn->xmitsema); 2881 up(&conn->xmitsema);
2882} 2882}