Skip to content

Commit 3e00974

Browse files
hreineckemartinkpetersen
authored andcommitted
scsi: sg: fixup infoleak when using SG_GET_REQUEST_TABLE
When calling SG_GET_REQUEST_TABLE ioctl only a half-filled table is returned; the remaining part will then contain stale kernel memory information. This patch zeroes out the entire table to avoid this issue. Signed-off-by: Hannes Reinecke <[email protected]> Reviewed-by: Bart Van Assche <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Reviewed-by: Eric Dumazet <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 4759df9 commit 3e00974

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

drivers/scsi/sg.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -839,7 +839,6 @@ sg_fill_request_table(Sg_fd *sfp, sg_req_info_t *rinfo)
839839
list_for_each_entry(srp, &sfp->rq_list, entry) {
840840
if (val > SG_MAX_QUEUE)
841841
break;
842-
memset(&rinfo[val], 0, SZ_SG_REQ_INFO);
843842
rinfo[val].req_state = srp->done + 1;
844843
rinfo[val].problem =
845844
srp->header.masked_status &
@@ -1047,8 +1046,8 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
10471046
else {
10481047
sg_req_info_t *rinfo;
10491048

1050-
rinfo = kmalloc(SZ_SG_REQ_INFO * SG_MAX_QUEUE,
1051-
GFP_KERNEL);
1049+
rinfo = kzalloc(SZ_SG_REQ_INFO * SG_MAX_QUEUE,
1050+
GFP_KERNEL);
10521051
if (!rinfo)
10531052
return -ENOMEM;
10541053
read_lock_irqsave(&sfp->rq_list_lock, iflags);

0 commit comments

Comments
 (0)