Skip to content

Commit

Permalink
crypto: msm: check length before copying to buf in _debug_stats_read
Browse files Browse the repository at this point in the history
Make sure that `len` is not larger than `count` before copying data
to userspace `buf` in _debug_stats_read().

Change-Id: Iafb7cfa3828653f8c28183c812797c3d9a183da1
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
  • Loading branch information
Zhen Kong authored and andi34 committed Jul 29, 2017
1 parent 9a3f8e6 commit ea8606e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions drivers/crypto/msm/ota_crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -744,8 +744,8 @@ static ssize_t _debug_stats_read(struct file *file, char __user *buf,
int len;

len = _disp_stats();

rc = simple_read_from_buffer((void __user *) buf, len,
if (len <= count)
rc = simple_read_from_buffer((void __user *) buf, len,
ppos, (void *) _debug_read_buf, len);

return rc;
Expand Down
4 changes: 2 additions & 2 deletions drivers/crypto/msm/qcedev.c
Original file line number Diff line number Diff line change
Expand Up @@ -2230,9 +2230,9 @@ static ssize_t _debug_stats_read(struct file *file, char __user *buf,

len = _disp_stats(qcedev);

rc = simple_read_from_buffer((void __user *) buf, len,
if (len <= count)
rc = simple_read_from_buffer((void __user *) buf, len,
ppos, (void *) _debug_read_buf, len);

return rc;
}

Expand Down
4 changes: 2 additions & 2 deletions drivers/crypto/msm/qcrypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -4918,9 +4918,9 @@ static ssize_t _debug_stats_read(struct file *file, char __user *buf,

len = _disp_stats(qcrypto);

rc = simple_read_from_buffer((void __user *) buf, len,
if (len <= count)
rc = simple_read_from_buffer((void __user *) buf, len,
ppos, (void *) _debug_read_buf, len);

return rc;
}

Expand Down

0 comments on commit ea8606e

Please sign in to comment.