diff options
author | Hannes Reinecke <hare@suse.de> | 2017-09-15 08:05:16 -0400 |
---|---|---|
committer | Martin K. Petersen <martin.petersen@oracle.com> | 2017-09-15 15:16:49 -0400 |
commit | 3e0097499839e0fe3af380410eababe5a47c4cf9 (patch) | |
tree | 6832509ca4b548ac72e54b000c58b00847dbb835 | |
parent | 4759df905a474d245752c9dc94288e779b8734dd (diff) |
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 <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>
-rw-r--r-- | drivers/scsi/sg.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c index 1acdb6e03999..0419c2298eab 100644 --- a/drivers/scsi/sg.c +++ b/drivers/scsi/sg.c | |||
@@ -839,7 +839,6 @@ sg_fill_request_table(Sg_fd *sfp, sg_req_info_t *rinfo) | |||
839 | list_for_each_entry(srp, &sfp->rq_list, entry) { | 839 | list_for_each_entry(srp, &sfp->rq_list, entry) { |
840 | if (val > SG_MAX_QUEUE) | 840 | if (val > SG_MAX_QUEUE) |
841 | break; | 841 | break; |
842 | memset(&rinfo[val], 0, SZ_SG_REQ_INFO); | ||
843 | rinfo[val].req_state = srp->done + 1; | 842 | rinfo[val].req_state = srp->done + 1; |
844 | rinfo[val].problem = | 843 | rinfo[val].problem = |
845 | srp->header.masked_status & | 844 | srp->header.masked_status & |
@@ -1047,8 +1046,8 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg) | |||
1047 | else { | 1046 | else { |
1048 | sg_req_info_t *rinfo; | 1047 | sg_req_info_t *rinfo; |
1049 | 1048 | ||
1050 | rinfo = kmalloc(SZ_SG_REQ_INFO * SG_MAX_QUEUE, | 1049 | rinfo = kzalloc(SZ_SG_REQ_INFO * SG_MAX_QUEUE, |
1051 | GFP_KERNEL); | 1050 | GFP_KERNEL); |
1052 | if (!rinfo) | 1051 | if (!rinfo) |
1053 | return -ENOMEM; | 1052 | return -ENOMEM; |
1054 | read_lock_irqsave(&sfp->rq_list_lock, iflags); | 1053 | read_lock_irqsave(&sfp->rq_list_lock, iflags); |