public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] scsi: aacraid: reading out of bounds
@ 2017-07-25 19:49 Dan Carpenter
  2017-07-25 19:51 ` [PATCH 2/2] scsi: aacraid: Off by one NUL terminator Dan Carpenter
  2017-07-27  2:10 ` [PATCH 1/2] scsi: aacraid: reading out of bounds Martin K. Petersen
  0 siblings, 2 replies; 11+ messages in thread
From: Dan Carpenter @ 2017-07-25 19:49 UTC (permalink / raw)
  To: Adaptec OEM Raid Solutions
  Cc: James E.J. Bottomley, Martin K. Petersen, linux-scsi,
	kernel-janitors

"qd.id" comes directly from the copy_from_user() on the line before so
we should verify that it's within bounds.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
This bug predates git.

diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c
index 707ee2f5954d..4591113c49de 100644
--- a/drivers/scsi/aacraid/aachba.c
+++ b/drivers/scsi/aacraid/aachba.c
@@ -3198,10 +3198,11 @@ static int query_disk(struct aac_dev *dev, void __user *arg)
 		return -EBUSY;
 	if (copy_from_user(&qd, arg, sizeof (struct aac_query_disk)))
 		return -EFAULT;
-	if (qd.cnum == -1)
+	if (qd.cnum == -1) {
+		if (qd.id < 0 || qd.id >= dev->maximum_num_containers)
+			return -EINVAL;
 		qd.cnum = qd.id;
-	else if ((qd.bus == -1) && (qd.id == -1) && (qd.lun == -1))
-	{
+	} else if ((qd.bus == -1) && (qd.id == -1) && (qd.lun == -1)) {
 		if (qd.cnum < 0 || qd.cnum >= dev->maximum_num_containers)
 			return -EINVAL;
 		qd.instance = dev->scsi_host_ptr->host_no;

^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2017-07-27 16:51 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-07-25 19:49 [PATCH 1/2] scsi: aacraid: reading out of bounds Dan Carpenter
2017-07-25 19:51 ` [PATCH 2/2] scsi: aacraid: Off by one NUL terminator Dan Carpenter
2017-07-25 21:19   ` Bart Van Assche
2017-07-27  3:08   ` Martin K. Petersen
2017-07-27  9:00     ` Dan Carpenter
2017-07-27 12:55       ` Martin K. Petersen
2017-07-27 16:26     ` Dave Carroll
2017-07-27 16:30       ` Martin K. Petersen
2017-07-27 16:51         ` Dave Carroll
2017-07-27  2:10 ` [PATCH 1/2] scsi: aacraid: reading out of bounds Martin K. Petersen
2017-07-27 16:12   ` Dave Carroll

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox