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-Url: https://git.stricted.de/?a=commitdiff_plain;h=ad2518320bc440ed3db072e2444a1bb226a9cf7a;p=GitHub%2FLineageOS%2FG12%2Fandroid_kernel_amlogic_linux-4.9.git scsi: sg: allocate with __GFP_ZERO in sg_build_indirect() commit a45b599ad808c3c982fdcdc12b0b8611c2f92824 upstream. 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 Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c index f61b37109e5c..0f81d739f9e9 100644 --- a/drivers/scsi/sg.c +++ b/drivers/scsi/sg.c @@ -1893,7 +1893,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;