lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 18 May 2021 18:50:12 +0300
From:   Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To:     Kent Gibson <warthog618@...il.com>,
        Bartosz Golaszewski <bgolaszewski@...libre.com>,
        Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
        linux-gpio@...r.kernel.org, linux-kernel@...r.kernel.org
Cc:     Linus Walleij <linus.walleij@...aro.org>,
        Suresh Balakrishnan <suresh.balakrishnan@...el.com>
Subject: [PATCH v1 1/2] gpiolib: Never return internal error codes to user space

Currently it's possible that character device interface may return
the error codes which are not supposed to be seen by user space.
In this case it's EPROBE_DEFER.

Wrap it to return -ENODEV instead as sysfs does.

Fixes: d7c51b47ac11 ("gpio: userspace ABI for reading/writing GPIO lines")
Fixes: 61f922db7221 ("gpio: userspace ABI for reading GPIO line events")
Fixes: 3c0d9c635ae2 ("gpiolib: cdev: support GPIO_V2_GET_LINE_IOCTL and GPIO_V2_LINE_GET_VALUES_IOCTL")
Reported-by: Suresh Balakrishnan <suresh.balakrishnan@...el.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
---
 drivers/gpio/gpiolib-cdev.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/drivers/gpio/gpiolib-cdev.c b/drivers/gpio/gpiolib-cdev.c
index 1631727bf0da..1d8f66880d63 100644
--- a/drivers/gpio/gpiolib-cdev.c
+++ b/drivers/gpio/gpiolib-cdev.c
@@ -331,8 +331,11 @@ static int linehandle_create(struct gpio_device *gdev, void __user *ip)
 		}
 
 		ret = gpiod_request(desc, lh->label);
-		if (ret)
+		if (ret) {
+			if (ret == -EPROBE_DEFER)
+				ret = -ENODEV;
 			goto out_free_lh;
+		}
 		lh->descs[i] = desc;
 		linehandle_flags_to_desc_flags(handlereq.flags, &desc->flags);
 
@@ -1379,8 +1382,11 @@ static int linereq_create(struct gpio_device *gdev, void __user *ip)
 		}
 
 		ret = gpiod_request(desc, lr->label);
-		if (ret)
+		if (ret) {
+			if (ret == -EPROBE_DEFER)
+				ret = -ENODEV;
 			goto out_free_linereq;
+		}
 
 		lr->lines[i].desc = desc;
 		flags = gpio_v2_line_config_flags(lc, i);
@@ -1765,8 +1771,11 @@ static int lineevent_create(struct gpio_device *gdev, void __user *ip)
 	}
 
 	ret = gpiod_request(desc, le->label);
-	if (ret)
+	if (ret) {
+		if (ret == -EPROBE_DEFER)
+			ret = -ENODEV;
 		goto out_free_le;
+	}
 	le->desc = desc;
 	le->eflags = eflags;
 
-- 
2.30.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ