From e283c385e71ce1522119a6935bc25277b907e236 Mon Sep 17 00:00:00 2001 From: Daniel Verkamp Date: Wed, 12 Jul 2017 17:50:19 -0700 Subject: [PATCH] iscsi: fix AHS handling Previously, we had a pdu->ahs pointer that was always NULL (never set anywhere), and we would try to read data into this NULL pointer if the initiator ever sent a PDU with a non-zero TotalAHSLength. Rename the existing ahs_data array in the PDU to just "ahs" to minimize the necessary changes. We never actually dereference the ahs structure, so its type is not important. (We can cast it later if we add support for anything that requires an AHS.) Change-Id: I10d19a6e0d99f326794cbe6469eacedadc634c67 Signed-off-by: Daniel Verkamp Reviewed-on: https://review.gerrithub.io/369315 Tested-by: SPDK Automated Test System Reviewed-by: Ben Walker Reviewed-by: Jim Harris --- lib/iscsi/iscsi.h | 3 +-- lib/iscsi/iscsi_subsystem.c | 2 +- test/unit/lib/iscsi/common.c | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/iscsi/iscsi.h b/lib/iscsi/iscsi.h index fe7af26f8..b75b6bd29 100644 --- a/lib/iscsi/iscsi.h +++ b/lib/iscsi/iscsi.h @@ -153,7 +153,6 @@ struct spdk_mobj { struct spdk_iscsi_pdu { struct iscsi_bhs bhs; - struct iscsi_ahs *ahs; struct spdk_mobj *mobj; uint8_t *data_buf; uint8_t *data; @@ -178,7 +177,7 @@ struct spdk_iscsi_pdu { * This should always be at the end of PDU data structure. * we need to not zero this out when doing memory clear. */ - uint8_t ahs_data[ISCSI_AHS_LEN]; + uint8_t ahs[ISCSI_AHS_LEN]; struct { uint16_t length; /* iSCSI SenseLength (big-endian) */ diff --git a/lib/iscsi/iscsi_subsystem.c b/lib/iscsi/iscsi_subsystem.c index 01872dadb..4e5a6a127 100644 --- a/lib/iscsi/iscsi_subsystem.c +++ b/lib/iscsi/iscsi_subsystem.c @@ -531,7 +531,7 @@ struct spdk_iscsi_pdu *spdk_get_pdu(void) } /* we do not want to zero out the last part of the structure reserved for AHS and sense data */ - memset(pdu, 0, offsetof(struct spdk_iscsi_pdu, ahs_data)); + memset(pdu, 0, offsetof(struct spdk_iscsi_pdu, ahs)); pdu->ref = 1; return pdu; diff --git a/test/unit/lib/iscsi/common.c b/test/unit/lib/iscsi/common.c index dfdb12325..b03bc8d3a 100644 --- a/test/unit/lib/iscsi/common.c +++ b/test/unit/lib/iscsi/common.c @@ -59,7 +59,7 @@ spdk_get_pdu(void) return NULL; } - memset(pdu, 0, offsetof(struct spdk_iscsi_pdu, ahs_data)); + memset(pdu, 0, offsetof(struct spdk_iscsi_pdu, ahs)); pdu->ref = 1; return pdu;