Skip to content

Commit 72896ca

Browse files
hreineckegregkh
authored andcommitted
scsi: sg: fixup infoleak when using SG_GET_REQUEST_TABLE
commit 3e0097499839e0fe3af380410eababe5a47c4cf9 upstream. 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 <hare@suse.com> Reviewed-by: Bart Van Assche <bart.vanassche@wdc.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Eric Dumazet <edumazet@google.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent c04996a commit 72896ca

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

drivers/scsi/sg.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -850,7 +850,6 @@ sg_fill_request_table(Sg_fd *sfp, sg_req_info_t *rinfo)
850850
list_for_each_entry(srp, &sfp->rq_list, entry) {
851851
if (val > SG_MAX_QUEUE)
852852
break;
853-
memset(&rinfo[val], 0, SZ_SG_REQ_INFO);
854853
rinfo[val].req_state = srp->done + 1;
855854
rinfo[val].problem =
856855
srp->header.masked_status &
@@ -1067,8 +1066,8 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
10671066
else {
10681067
sg_req_info_t *rinfo;
10691068

1070-
rinfo = kmalloc(SZ_SG_REQ_INFO * SG_MAX_QUEUE,
1071-
GFP_KERNEL);
1069+
rinfo = kzalloc(SZ_SG_REQ_INFO * SG_MAX_QUEUE,
1070+
GFP_KERNEL);
10721071
if (!rinfo)
10731072
return -ENOMEM;
10741073
read_lock_irqsave(&sfp->rq_list_lock, iflags);

0 commit comments

Comments
 (0)