diff options
author | Lars-Peter Clausen <lars@metafoo.de> | 2016-10-18 16:54:01 +0200 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2016-10-21 14:39:18 +0200 |
commit | e405f9fcb63602d35f7a419ededa3f952a395a72 (patch) | |
tree | 8ccb8cecafdc1b92ddfcdcfe9be26c71e07a45dd /drivers/gpio | |
parent | 0f4bbb233743bdfd51d47688b0bc2561f310488b (diff) | |
download | talos-obmc-linux-e405f9fcb63602d35f7a419ededa3f952a395a72.tar.gz talos-obmc-linux-e405f9fcb63602d35f7a419ededa3f952a395a72.zip |
gpio: GPIO_GET_LINEHANDLE_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: d7c51b47ac11 ("gpio: userspace ABI for reading/writing GPIO lines")
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/gpio')
-rw-r--r-- | drivers/gpio/gpiolib.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 7a01969169e8..d287cb4e97c4 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -444,6 +444,11 @@ static int linehandle_create(struct gpio_device *gdev, void __user *ip) u32 lflags = handlereq.flags; struct gpio_desc *desc; + if (offset >= gdev->ngpio) { + ret = -EINVAL; + goto out_free_descs; + } + desc = &gdev->descs[offset]; ret = gpiod_request(desc, lh->label); if (ret) |