]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.9.52/scsi-sg-fixup-infoleak-when-using-sg_get_request_table.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.9.52 / scsi-sg-fixup-infoleak-when-using-sg_get_request_table.patch
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
5
6 From: Hannes Reinecke <hare@suse.de>
7
8 commit 3e0097499839e0fe3af380410eababe5a47c4cf9 upstream.
9
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
13 issue.
14
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>
21
22 ---
23 drivers/scsi/sg.c | 5 ++---
24 1 file changed, 2 insertions(+), 3 deletions(-)
25
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)
31 break;
32 - memset(&rinfo[val], 0, SZ_SG_REQ_INFO);
33 rinfo[val].req_state = srp->done + 1;
34 rinfo[val].problem =
35 srp->header.masked_status &
36 @@ -1057,8 +1056,8 @@ sg_ioctl(struct file *filp, unsigned int
37 else {
38 sg_req_info_t *rinfo;
39
40 - rinfo = kmalloc(SZ_SG_REQ_INFO * SG_MAX_QUEUE,
41 - GFP_KERNEL);
42 + rinfo = kzalloc(SZ_SG_REQ_INFO * SG_MAX_QUEUE,
43 + GFP_KERNEL);
44 if (!rinfo)
45 return -ENOMEM;
46 read_lock_irqsave(&sfp->rq_list_lock, iflags);