summaryrefslogtreecommitdiff
path: root/drivers/video/fbdev
diff options
context:
space:
mode:
authorHarsh Sahu <hsahu@codeaurora.org>2018-03-23 00:15:52 -0700
committerGerrit - the friendly Code Review server <code-review@localhost>2018-04-04 16:36:01 -0700
commitd24de74649b3e993556e76f84f219913731dd80c (patch)
tree7fc99d6ca9242372b71fd8fa229786ba804c374e /drivers/video/fbdev
parent7405e11851da69bb4f4773036090948008e575cd (diff)
fbdev: msm: check buffer size before writing to user buffer
Check the number of bytes to copy against the size of the user buffer before copy to user to avoid buffer overflow. Change-Id: Icdd3d4e755deca19fa431e903620bd9e4c701c89 Signed-off-by: Harsh Sahu <hsahu@codeaurora.org>
Diffstat (limited to 'drivers/video/fbdev')
-rw-r--r--drivers/video/fbdev/msm/mdss_debug_xlog.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/drivers/video/fbdev/msm/mdss_debug_xlog.c b/drivers/video/fbdev/msm/mdss_debug_xlog.c
index aeefc81657b0..10d747962a91 100644
--- a/drivers/video/fbdev/msm/mdss_debug_xlog.c
+++ b/drivers/video/fbdev/msm/mdss_debug_xlog.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014-2017, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2014-2018, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@@ -755,6 +755,11 @@ static ssize_t mdss_xlog_dump_read(struct file *file, char __user *buff,
if (__mdss_xlog_dump_calc_range()) {
len = mdss_xlog_dump_entry(xlog_buf, MDSS_XLOG_BUF_MAX);
+ if (len < 0 || len > count) {
+ pr_err("len is more than the size of user buffer\n");
+ return 0;
+ }
+
if (copy_to_user(buff, xlog_buf, len))
return -EFAULT;
*ppos += len;