1 From 3e0097499839e0fe3af380410eababe5a47c4cf9 Mon Sep 17 00:00:00 2001
2 From: Hannes Reinecke <hare@suse.de>
3 Date: Fri, 15 Sep 2017 14:05:16 +0200
4 Subject: scsi: sg: fixup infoleak when using SG_GET_REQUEST_TABLE
6 From: Hannes Reinecke <hare@suse.de>
8 commit 3e0097499839e0fe3af380410eababe5a47c4cf9 upstream.
10 When calling SG_GET_REQUEST_TABLE ioctl only a half-filled table is
11 returned; the remaining part will then contain stale kernel memory
12 information. This patch zeroes out the entire table to avoid this
15 Signed-off-by: Hannes Reinecke <hare@suse.com>
16 Reviewed-by: Bart Van Assche <bart.vanassche@wdc.com>
17 Reviewed-by: Christoph Hellwig <hch@lst.de>
18 Reviewed-by: Eric Dumazet <edumazet@google.com>
19 Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
20 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
23 drivers/scsi/sg.c | 5 ++---
24 1 file changed, 2 insertions(+), 3 deletions(-)
26 --- a/drivers/scsi/sg.c
27 +++ b/drivers/scsi/sg.c
28 @@ -839,7 +839,6 @@ sg_fill_request_table(Sg_fd *sfp, sg_req
29 list_for_each_entry(srp, &sfp->rq_list, entry) {
30 if (val > SG_MAX_QUEUE)
32 - memset(&rinfo[val], 0, SZ_SG_REQ_INFO);
33 rinfo[val].req_state = srp->done + 1;
35 srp->header.masked_status &
36 @@ -1057,8 +1056,8 @@ sg_ioctl(struct file *filp, unsigned int
40 - rinfo = kmalloc(SZ_SG_REQ_INFO * SG_MAX_QUEUE,
42 + rinfo = kzalloc(SZ_SG_REQ_INFO * SG_MAX_QUEUE,
46 read_lock_irqsave(&sfp->rq_list_lock, iflags);