From: Lars-Peter Clausen Date: Tue, 18 Oct 2016 14:54:02 +0000 (+0200) Subject: gpio: GPIOHANDLE_GET_LINE_VALUES_IOCTL: Fix information leak X-Git-Tag: v4.8.7~127 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=49bdfb21e37d786e0426d00665c9db9a926cce24;p=thirdparty%2Fkernel%2Fstable.git gpio: GPIOHANDLE_GET_LINE_VALUES_IOCTL: Fix information leak commit 3eded5d83bf4e36ad78775c7ceb44a45480b0abd upstream. The GPIOHANDLE_GET_LINE_VALUES_IOCTL handler allocates a gpiohandle_data struct on the stack and then passes it to copy_to_user(). But depending on the number of requested line handles the struct is only partially initialized. This exposes the previous, potentially sensitive, stack content to the issuing userspace application. To avoid this make sure that the struct is fully initialized. Fixes: d7c51b47ac11 ("gpio: userspace ABI for reading/writing GPIO lines") Signed-off-by: Lars-Peter Clausen Signed-off-by: Linus Walleij Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index ee20b46d798e7..87545384af97c 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -342,6 +342,8 @@ static long linehandle_ioctl(struct file *filep, unsigned int cmd, if (cmd == GPIOHANDLE_GET_LINE_VALUES_IOCTL) { int val; + memset(&ghd, 0, sizeof(ghd)); + /* TODO: check if descriptors are really input */ for (i = 0; i < lh->numdescs; i++) { val = gpiod_get_value_cansleep(lh->descs[i]);