]> git.baikalelectronics.ru Git - kernel.git/commit
platform/olpc: Fix uninitialized data in debugfs write
authorDan Carpenter <dan.carpenter@oracle.com>
Wed, 20 Jul 2022 18:23:38 +0000 (21:23 +0300)
committerHans de Goede <hdegoede@redhat.com>
Thu, 28 Jul 2022 18:40:15 +0000 (20:40 +0200)
commit7c7de66ffb678ed8d39ff1c82cb7fd4bccfea8f6
tree1365d7f84e2a05bb9ec039ea0ee48ea3bdd266e8
parenta266b99635865297652f29551185371b37d009db
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: 253ff100d2a7 ("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>
drivers/platform/olpc/olpc-ec.c