Blame SOURCES/0099-scsi-scsi-qla2xxx-Avoid-that-qlt_send_resp_ctio-corr.patch

3d7c23
From af7b3fbefd45cd9cba7e46e451eb64e1b7bbe7b0 Mon Sep 17 00:00:00 2001
3d7c23
From: Himanshu Madhani <hmadhani@redhat.com>
3d7c23
Date: Thu, 1 Aug 2019 15:55:59 -0400
3d7c23
Subject: [PATCH 099/124] [scsi] scsi: qla2xxx: Avoid that qlt_send_resp_ctio()
3d7c23
 corrupts memory
3d7c23
3d7c23
Message-id: <20190801155618.12650-100-hmadhani@redhat.com>
3d7c23
Patchwork-id: 267894
3d7c23
O-Subject: [RHEL 7.8 e-stor PATCH 099/118] scsi: qla2xxx: Avoid that qlt_send_resp_ctio() corrupts memory
3d7c23
Bugzilla: 1729270
3d7c23
RH-Acked-by: Jarod Wilson <jarod@redhat.com>
3d7c23
RH-Acked-by: Tony Camuso <tcamuso@redhat.com>
3d7c23
3d7c23
From: Bart Van Assche <bvanassche@acm.org>
3d7c23
3d7c23
Bugzilla 1729270
3d7c23
3d7c23
The "(&ctio->u.status1.sense_data)[i]" where i >= 0 expressions in
3d7c23
qlt_send_resp_ctio() are probably typos and should have been
3d7c23
"(&ctio->u.status1.sense_data[4 * i])" instead. Instead of only fixing
3d7c23
these typos, modify the code for storing sense data such that it becomes
3d7c23
easy to read. This patch fixes a Coverity complaint about accessing an
3d7c23
array outside its bounds.
3d7c23
3d7c23
Cc: Himanshu Madhani <hmadhani@marvell.com>
3d7c23
Cc: Giridhar Malavali <gmalavali@marvell.com>
3d7c23
Fixes: be25152c0d9e ("qla2xxx: Improve T10-DIF/PI handling in driver.") # v4.11.
3d7c23
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
3d7c23
Acked-by: Himanshu Madhani <hmadhani@marvell.com>
3d7c23
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3d7c23
(cherry picked from commit a861b49273578e255426a499842cf7f465456351)
3d7c23
Signed-off-by: Himanshu Madhani <hmadhani@redhat.com>
3d7c23
Signed-off-by: Jan Stancek <jstancek@redhat.com>
3d7c23
---
3d7c23
 drivers/scsi/qla2xxx/qla_target.c | 12 ++++++------
3d7c23
 1 file changed, 6 insertions(+), 6 deletions(-)
3d7c23
3d7c23
diff --git a/drivers/scsi/qla2xxx/qla_target.c b/drivers/scsi/qla2xxx/qla_target.c
3d7c23
index 398a8d6b4db6..f79b51fcbca3 100644
3d7c23
--- a/drivers/scsi/qla2xxx/qla_target.c
3d7c23
+++ b/drivers/scsi/qla2xxx/qla_target.c
3d7c23
@@ -2328,14 +2328,14 @@ void qlt_send_resp_ctio(struct qla_qpair *qpair, struct qla_tgt_cmd *cmd,
3d7c23
 		ctio->u.status1.scsi_status |=
3d7c23
 		    cpu_to_le16(SS_RESIDUAL_UNDER);
3d7c23
 
3d7c23
-	/* Response code and sense key */
3d7c23
-	put_unaligned_le32(((0x70 << 24) | (sense_key << 8)),
3d7c23
-	    (&ctio->u.status1.sense_data)[0]);
3d7c23
+	/* Fixed format sense data. */
3d7c23
+	ctio->u.status1.sense_data[0] = 0x70;
3d7c23
+	ctio->u.status1.sense_data[2] = sense_key;
3d7c23
 	/* Additional sense length */
3d7c23
-	put_unaligned_le32(0x0a, (&ctio->u.status1.sense_data)[1]);
3d7c23
+	ctio->u.status1.sense_data[7] = 0xa;
3d7c23
 	/* ASC and ASCQ */
3d7c23
-	put_unaligned_le32(((asc << 24) | (ascq << 16)),
3d7c23
-	    (&ctio->u.status1.sense_data)[3]);
3d7c23
+	ctio->u.status1.sense_data[12] = asc;
3d7c23
+	ctio->u.status1.sense_data[13] = ascq;
3d7c23
 
3d7c23
 	/* Memory Barrier */
3d7c23
 	wmb();
3d7c23
-- 
3d7c23
2.13.6
3d7c23