linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] scsi: sg: allocate with __GFP_ZERO in sg_build_indirect()
@ 2018-05-18 14:23 Alexander Potapenko
  2018-05-18 14:31 ` Martin K. Petersen
  2018-05-18 16:15 ` Christoph Hellwig
  0 siblings, 2 replies; 3+ messages in thread
From: Alexander Potapenko @ 2018-05-18 14:23 UTC (permalink / raw)
  To: jthumshirn, jejb, dgilbert
  Cc: linux-kernel, stable, linux-scsi, dvyukov, hare, torvalds

This shall help avoid copying uninitialized memory to the userspace
when calling ioctl(fd, SG_IO) with an empty command.

Reported-by: syzbot+7d26fc1eea198488deab@syzkaller.appspotmail.com
Cc: stable@vger.kernel.org
Signed-off-by: Alexander Potapenko <glider@google.com>
Acked-by: Douglas Gilbert <dgilbert@interlog.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
---
 drivers/scsi/sg.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index c198b96368dd..5c40d809830f 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -1894,7 +1894,7 @@ sg_build_indirect(Sg_scatter_hold * schp, Sg_fd * sfp, int buff_size)
 		num = (rem_sz > scatter_elem_sz_prev) ?
 			scatter_elem_sz_prev : rem_sz;
 
-		schp->pages[k] = alloc_pages(gfp_mask, order);
+		schp->pages[k] = alloc_pages(gfp_mask | __GFP_ZERO, order);
 		if (!schp->pages[k])
 			goto out;
 
-- 
2.17.0.441.gb46fe60e1d-goog

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

* Re: [PATCH] scsi: sg: allocate with __GFP_ZERO in sg_build_indirect()
  2018-05-18 14:23 [PATCH] scsi: sg: allocate with __GFP_ZERO in sg_build_indirect() Alexander Potapenko
@ 2018-05-18 14:31 ` Martin K. Petersen
  2018-05-18 16:15 ` Christoph Hellwig
  1 sibling, 0 replies; 3+ messages in thread
From: Martin K. Petersen @ 2018-05-18 14:31 UTC (permalink / raw)
  To: Alexander Potapenko
  Cc: jthumshirn, jejb, dgilbert, linux-kernel, stable, linux-scsi,
	dvyukov, hare, torvalds


Alexander,

> This shall help avoid copying uninitialized memory to the userspace
> when calling ioctl(fd, SG_IO) with an empty command.

Applied to 4.17/scsi-fixes. Thank you!

-- 
Martin K. Petersen	Oracle Linux Engineering

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

* Re: [PATCH] scsi: sg: allocate with __GFP_ZERO in sg_build_indirect()
  2018-05-18 14:23 [PATCH] scsi: sg: allocate with __GFP_ZERO in sg_build_indirect() Alexander Potapenko
  2018-05-18 14:31 ` Martin K. Petersen
@ 2018-05-18 16:15 ` Christoph Hellwig
  1 sibling, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2018-05-18 16:15 UTC (permalink / raw)
  To: Alexander Potapenko
  Cc: jthumshirn, jejb, dgilbert, linux-kernel, stable, linux-scsi,
	dvyukov, hare, torvalds

On Fri, May 18, 2018 at 04:23:18PM +0200, Alexander Potapenko wrote:
> This shall help avoid copying uninitialized memory to the userspace
> when calling ioctl(fd, SG_IO) with an empty command.

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

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

end of thread, other threads:[~2018-05-18 16:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-05-18 14:23 [PATCH] scsi: sg: allocate with __GFP_ZERO in sg_build_indirect() Alexander Potapenko
2018-05-18 14:31 ` Martin K. Petersen
2018-05-18 16:15 ` Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).