public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] scsi: sg: off by one in sg_ioctl()
@ 2017-08-17  7:09 Dan Carpenter
  2017-08-23  1:50 ` Douglas Gilbert
  2017-08-23  2:24 ` Martin K. Petersen
  0 siblings, 2 replies; 3+ messages in thread
From: Dan Carpenter @ 2017-08-17  7:09 UTC (permalink / raw)
  To: Doug Gilbert, Hannes Reinecke
  Cc: James E.J. Bottomley, Martin K. Petersen, linux-scsi,
	kernel-janitors

If "val" is SG_MAX_QUEUE then we are one element beyond the end of the
"rinfo" array so the > should be >=.

Fixes: 109bade9c625 ("scsi: sg: use standard lists for sg_requests")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index d7ff71e0c85c..84e782d8e7c3 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -1021,7 +1021,7 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
 			read_lock_irqsave(&sfp->rq_list_lock, iflags);
 			val = 0;
 			list_for_each_entry(srp, &sfp->rq_list, entry) {
-				if (val > SG_MAX_QUEUE)
+				if (val >= SG_MAX_QUEUE)
 					break;
 				memset(&rinfo[val], 0, SZ_SG_REQ_INFO);
 				rinfo[val].req_state = srp->done + 1;

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

* Re: [PATCH] scsi: sg: off by one in sg_ioctl()
  2017-08-17  7:09 [PATCH] scsi: sg: off by one in sg_ioctl() Dan Carpenter
@ 2017-08-23  1:50 ` Douglas Gilbert
  2017-08-23  2:24 ` Martin K. Petersen
  1 sibling, 0 replies; 3+ messages in thread
From: Douglas Gilbert @ 2017-08-23  1:50 UTC (permalink / raw)
  To: Dan Carpenter, Hannes Reinecke
  Cc: James E.J. Bottomley, Martin K. Petersen, linux-scsi,
	kernel-janitors

On 2017-08-17 03:09 AM, Dan Carpenter wrote:
> If "val" is SG_MAX_QUEUE then we are one element beyond the end of the
> "rinfo" array so the > should be >=.
> 
> Fixes: 109bade9c625 ("scsi: sg: use standard lists for sg_requests")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Douglas Gilbert <dgilbert@interlog.com>

Thanks.

> 
> diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
> index d7ff71e0c85c..84e782d8e7c3 100644
> --- a/drivers/scsi/sg.c
> +++ b/drivers/scsi/sg.c
> @@ -1021,7 +1021,7 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
>   			read_lock_irqsave(&sfp->rq_list_lock, iflags);
>   			val = 0;
>   			list_for_each_entry(srp, &sfp->rq_list, entry) {
> -				if (val > SG_MAX_QUEUE)
> +				if (val >= SG_MAX_QUEUE)
>   					break;
>   				memset(&rinfo[val], 0, SZ_SG_REQ_INFO);
>   				rinfo[val].req_state = srp->done + 1;
> 

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

* Re: [PATCH] scsi: sg: off by one in sg_ioctl()
  2017-08-17  7:09 [PATCH] scsi: sg: off by one in sg_ioctl() Dan Carpenter
  2017-08-23  1:50 ` Douglas Gilbert
@ 2017-08-23  2:24 ` Martin K. Petersen
  1 sibling, 0 replies; 3+ messages in thread
From: Martin K. Petersen @ 2017-08-23  2:24 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Doug Gilbert, Hannes Reinecke, James E.J. Bottomley,
	Martin K. Petersen, linux-scsi, kernel-janitors


Dan,

> If "val" is SG_MAX_QUEUE then we are one element beyond the end of the
> "rinfo" array so the > should be >=.

Applied to 4.13/scsi-fixes. Thanks!

-- 
Martin K. Petersen	Oracle Linux Engineering

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

end of thread, other threads:[~2017-08-23  2:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-17  7:09 [PATCH] scsi: sg: off by one in sg_ioctl() Dan Carpenter
2017-08-23  1:50 ` Douglas Gilbert
2017-08-23  2:24 ` Martin K. Petersen

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