]> 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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 17 Aug 2022 12:23:58 +0000 (14:23 +0200)
commitd335ad2e68ee3ebce83f7da70ba7ac051c27ae79
tree1a15f5984a33d3e8a94749d6ab68fa7598fd3b56
parent40e1a1d69569b4f0ef5cdc40f48859f4b4fda565
platform/olpc: Fix uninitialized data in debugfs write

[ Upstream commit d3537f7dfa6a146f510c28a78f35829334f7a071 ]

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: a3fdc9110d10 ("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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/platform/olpc/olpc-ec.c