summaryrefslogtreecommitdiffstats
path: root/drivers/platform/olpc
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@oracle.com>2022-07-20 21:23:38 +0300
committerHans de Goede <hdegoede@redhat.com>2022-07-28 20:40:15 +0200
commit40ec787e1adf302c11668d4cc69838f4d584187d (patch)
tree1365d7f84e2a05bb9ec039ea0ee48ea3bdd266e8 /drivers/platform/olpc
parentb4b830a34d8046633231b7fe87f6f2cb6240dc9f (diff)
downloadlinux-40ec787e1adf302c11668d4cc69838f4d584187d.tar.bz2
platform/olpc: Fix uninitialized data in debugfs write
The call to: size = simple_write_to_buffer(cmdbuf, sizeof(cmdbuf), ppos, buf, size); will succeed if at least one byte is written to the "cmdbuf" buffer. The "*ppos" value controls which byte is written. Another problem is that this code does not check for errors so it's possible for the entire buffer to be uninitialized. Inintialize the struct to zero to prevent reading uninitialized stack data. Debugfs is normally only writable by root so the impact of this bug is very minimal. Fixes: 6cca83d498bd ("Platform: OLPC: move debugfs support from x86 EC driver") Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Link: https://lore.kernel.org/r/YthIKn+TfZSZMEcM@kili Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Diffstat (limited to 'drivers/platform/olpc')
-rw-r--r--drivers/platform/olpc/olpc-ec.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/platform/olpc/olpc-ec.c b/drivers/platform/olpc/olpc-ec.c
index 4ff5c3a12991..921520475ff6 100644
--- a/drivers/platform/olpc/olpc-ec.c
+++ b/drivers/platform/olpc/olpc-ec.c
@@ -264,7 +264,7 @@ static ssize_t ec_dbgfs_cmd_write(struct file *file, const char __user *buf,
int i, m;
unsigned char ec_cmd[EC_MAX_CMD_ARGS];
unsigned int ec_cmd_int[EC_MAX_CMD_ARGS];
- char cmdbuf[64];
+ char cmdbuf[64] = "";
int ec_cmd_bytes;
mutex_lock(&ec_dbgfs_lock);