From d6af861c5770bc2d442aa4b129073402bb74748b Mon Sep 17 00:00:00 2001 From: Peter Lieven Date: Thu, 10 Jul 2014 14:44:16 +0200 Subject: [PATCH] iscsi-test: check for invalid descriptors offsets in get_lba_status Dell Equallogic sans report an invalid LBA offset in the descriptor when using 4k LUNs. Check the descriptor for consistency with the request. Signed-off-by: Peter Lieven --- test-tool/iscsi-support.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/test-tool/iscsi-support.c b/test-tool/iscsi-support.c index 92c7e72..4758f92 100644 --- a/test-tool/iscsi-support.c +++ b/test-tool/iscsi-support.c @@ -1894,6 +1894,8 @@ struct scsi_task *get_lba_status_task(struct iscsi_context *iscsi, int lun, uint int get_lba_status(struct iscsi_context *iscsi, int lun, uint64_t lba, uint32_t len) { struct scsi_task *task; + struct scsi_get_lba_status *lbas = NULL; + struct scsi_lba_status_descriptor *lbasd = NULL; logging(LOG_VERBOSE, "Send GET_LBA_STATUS LBA:%" PRIu64 " alloc_len:%d", lba, len); @@ -1919,6 +1921,21 @@ int get_lba_status(struct iscsi_context *iscsi, int lun, uint64_t lba, uint32_t scsi_free_scsi_task(task); return -1; } + lbas = scsi_datain_unmarshall(task); + if (lbas == NULL) { + logging(LOG_NORMAL, "[FAILED] GET_LBA_STATUS command: " + "failed to unmarschall data."); + scsi_free_scsi_task(task); + return -1; + } + lbasd = &lbas->descriptors[0]; + if (lbasd->lba != lba) { + logging(LOG_NORMAL, "[FAILED] GET_LBA_STATUS command: " + "lba offset in first descriptor does not match request (0x%" PRIx64 " != 0x%" PRIx64 ").", + lbasd->lba, lba); + scsi_free_scsi_task(task); + return -1; + } scsi_free_scsi_task(task); logging(LOG_VERBOSE, "[OK] GET_LBA_STATUS returned SUCCESS.");