summaryrefslogtreecommitdiffstats
path: root/drivers/platform/chrome
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@oracle.com>2022-08-19 08:20:36 +0300
committerTzung-Bi Shih <tzungbi@kernel.org>2022-08-22 06:56:45 +0000
commit8a07b45fd3c2dda24fad43639be5335a4595196a (patch)
tree316b17ad4b9ece0d4aa10d59bec0ce4ce94cb2be /drivers/platform/chrome
parent6ad4194d6a1e1d11b285989cd648ef695b4a93c0 (diff)
downloadlinux-8a07b45fd3c2dda24fad43639be5335a4595196a.tar.bz2
platform/chrome: fix memory corruption in ioctl
If "s_mem.bytes" is larger than the buffer size it leads to memory corruption. Fixes: eda2e30c6684 ("mfd / platform: cros_ec: Miscellaneous character device to talk with the EC") Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Reviewed-by: Guenter Roeck <groeck@chromium.org> Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org> Link: https://lore.kernel.org/r/Yv8dpCFZJdbUT5ye@kili
Diffstat (limited to 'drivers/platform/chrome')
-rw-r--r--drivers/platform/chrome/cros_ec_chardev.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/platform/chrome/cros_ec_chardev.c b/drivers/platform/chrome/cros_ec_chardev.c
index fd33de546aee..0de7c255254e 100644
--- a/drivers/platform/chrome/cros_ec_chardev.c
+++ b/drivers/platform/chrome/cros_ec_chardev.c
@@ -327,6 +327,9 @@ static long cros_ec_chardev_ioctl_readmem(struct cros_ec_dev *ec,
if (copy_from_user(&s_mem, arg, sizeof(s_mem)))
return -EFAULT;
+ if (s_mem.bytes > sizeof(s_mem.buffer))
+ return -EINVAL;
+
num = ec_dev->cmd_readmem(ec_dev, s_mem.offset, s_mem.bytes,
s_mem.buffer);
if (num <= 0)