mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-08 03:40:35 +09:00
gpiolib: cdev: add gpio_device locking wrapper around gpio_ioctl()
[ Upstream commit 1d656bd259edb89dc1d9938ec5c5389867088546 ] While the GPIO cdev gpio_ioctl() call is in progress, the kernel can call gpiochip_remove() which will set gdev->chip to NULL, after which any subsequent access will cause a crash. gpio_ioctl() was overlooked by the previous fix to protect syscalls (bdbbae241a), so add protection for that. Fixes:bdbbae241a("gpiolib: protect the GPIO device against being dropped while in use by user-space") Fixes:d7c51b47ac("gpio: userspace ABI for reading/writing GPIO lines") Fixes:3c0d9c635a("gpiolib: cdev: support GPIO_V2_GET_LINE_IOCTL and GPIO_V2_LINE_GET_VALUES_IOCTL") Fixes:aad955842d("gpiolib: cdev: support GPIO_V2_GET_LINEINFO_IOCTL and GPIO_V2_GET_LINEINFO_WATCH_IOCTL") Signed-off-by: Kent Gibson <warthog618@gmail.com> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
8bdcedfdb0
commit
c0c4e9767e
@@ -2224,10 +2224,7 @@ static int lineinfo_unwatch(struct gpio_chardev_data *cdev, void __user *ip)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
static long gpio_ioctl_unlocked(struct file *file, unsigned int cmd, unsigned long arg)
|
||||||
* gpio_ioctl() - ioctl handler for the GPIO chardev
|
|
||||||
*/
|
|
||||||
static long gpio_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
|
|
||||||
{
|
{
|
||||||
struct gpio_chardev_data *cdev = file->private_data;
|
struct gpio_chardev_data *cdev = file->private_data;
|
||||||
struct gpio_device *gdev = cdev->gdev;
|
struct gpio_device *gdev = cdev->gdev;
|
||||||
@@ -2264,6 +2261,17 @@ static long gpio_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* gpio_ioctl() - ioctl handler for the GPIO chardev
|
||||||
|
*/
|
||||||
|
static long gpio_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
|
||||||
|
{
|
||||||
|
struct gpio_chardev_data *cdev = file->private_data;
|
||||||
|
|
||||||
|
return call_ioctl_locked(file, cmd, arg, cdev->gdev,
|
||||||
|
gpio_ioctl_unlocked);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_COMPAT
|
#ifdef CONFIG_COMPAT
|
||||||
static long gpio_ioctl_compat(struct file *file, unsigned int cmd,
|
static long gpio_ioctl_compat(struct file *file, unsigned int cmd,
|
||||||
unsigned long arg)
|
unsigned long arg)
|
||||||
|
|||||||
Reference in New Issue
Block a user