aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars-Peter Clausen <lars@metafoo.de>2016-10-18 10:54:03 -0400
committerLinus Walleij <linus.walleij@linaro.org>2016-10-21 08:41:38 -0400
commitb8b0e3d303654b3bb7b31b0266c513fd6f4132ce (patch)
tree3033c7c4ba27e0a24c1384809decb1ea97653677
parentd82aa4a8f2e8df9673ddb099262355da4c9b99b1 (diff)
gpio: GPIO_GET_LINEEVENT_IOCTL: Validate line offset
The line offset that is used as an index into the descs array is provided by userspace and might go beyond the bounds of the array. If that happens undefined behavior will occur. Make sure that the offset is within the bounds of the desc array and reject any requests that specify a value outside of it. Cc: stable@vger.kernel.org Fixes: 61f922db7221 ("gpio: userspace ABI for reading GPIO line events") Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
-rw-r--r--drivers/gpio/gpiolib.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 4ed26bcf054c..db44a7da5eb4 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -733,6 +733,11 @@ static int lineevent_create(struct gpio_device *gdev, void __user *ip)
733 lflags = eventreq.handleflags; 733 lflags = eventreq.handleflags;
734 eflags = eventreq.eventflags; 734 eflags = eventreq.eventflags;
735 735
736 if (offset >= gdev->ngpio) {
737 ret = -EINVAL;
738 goto out_free_label;
739 }
740
736 /* This is just wrong: we don't look for events on output lines */ 741 /* This is just wrong: we don't look for events on output lines */
737 if (lflags & GPIOHANDLE_REQUEST_OUTPUT) { 742 if (lflags & GPIOHANDLE_REQUEST_OUTPUT) {
738 ret = -EINVAL; 743 ret = -EINVAL;