From: Alexander Potapenko Date: Fri, 18 May 2018 14:23:18 +0000 (+0200) Subject: scsi: sg: allocate with __GFP_ZERO in sg_build_indirect() X-Git-Tag: v4.1.12-124.31.3~419 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=1f453d6998ac2c3d5d007ced75821dbdc9e5a982;p=users%2Fjedix%2Flinux-maple.git scsi: sg: allocate with __GFP_ZERO in sg_build_indirect() 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 Acked-by: Douglas Gilbert Reviewed-by: Johannes Thumshirn Signed-off-by: Martin K. Petersen (cherry picked from commit a45b599ad808c3c982fdcdc12b0b8611c2f92824) Orabug: 28892656 CVE: CVE-2018-1000204 Reviewed-by: Darren Kenny Signed-off-by: Allen Pais Signed-off-by: Brian Maly --- diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c index 470a90e0eae2..f0a3175025f2 100644 --- a/drivers/scsi/sg.c +++ b/drivers/scsi/sg.c @@ -1912,7 +1912,7 @@ retry: 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;