Commit e5332d54 authored by Bartosz Golaszewski's avatar Bartosz Golaszewski Committed by Linus Walleij

gpiolib: don't allow userspace to set values of input lines

User space can currently both read and set values of input lines using
the character device. This was not allowed by the old sysfs interface
nor is it a correct behavior.

Check the first descriptor in the set for the OUT flag when asked to
set values and return -EPERM if the line is input.
Signed-off-by: default avatarBartosz Golaszewski <brgl@bgdev.pl>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent ad817297
...@@ -449,7 +449,13 @@ static long linehandle_ioctl(struct file *filep, unsigned int cmd, ...@@ -449,7 +449,13 @@ static long linehandle_ioctl(struct file *filep, unsigned int cmd,
return 0; return 0;
} else if (cmd == GPIOHANDLE_SET_LINE_VALUES_IOCTL) { } else if (cmd == GPIOHANDLE_SET_LINE_VALUES_IOCTL) {
/* TODO: check if descriptors are really output */ /*
* All line descriptors were created at once with the same
* flags so just check if the first one is really output.
*/
if (!test_bit(FLAG_IS_OUT, &lh->descs[0]->flags))
return -EPERM;
if (copy_from_user(&ghd, ip, sizeof(ghd))) if (copy_from_user(&ghd, ip, sizeof(ghd)))
return -EFAULT; return -EFAULT;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment