gpio: Fix kernel stack leak to userspace
authorLinus Walleij <linus.walleij@linaro.org>
Mon, 22 Jan 2018 12:19:28 +0000 (13:19 +0100)
committerLinus Walleij <linus.walleij@linaro.org>
Tue, 23 Jan 2018 13:43:45 +0000 (14:43 +0100)
The GPIO event descriptor was leaking kernel stack to
userspace because we don't zero the variable before
use. Ooops. Fix this.

Cc: stable@vger.kernel.org
Reported-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Bartosz Golaszewski <brgl@bgdev.pl>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/gpio/gpiolib.c

index 37e31ba..754836e 100644 (file)
@@ -744,6 +744,9 @@ static irqreturn_t lineevent_irq_thread(int irq, void *p)
        struct gpioevent_data ge;
        int ret, level;
 
+       /* Do not leak kernel stack to userspace */
+       memset(&ge, 0, sizeof(ge));
+
        ge.timestamp = ktime_get_real_ns();
        level = gpiod_get_value_cansleep(le->desc);