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-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230427133350.31064-6-oneukum@suse.com>
Date:   Thu, 27 Apr 2023 15:33:47 +0200
From:   Oliver Neukum <oneukum@...e.com>
To:     wim@...ux-watchdog.org, linux@...ck-us.net,
        linux-watchdog@...r.kernel.org, linux-kernel@...r.kernel.org
Cc:     Oliver Neukum <oneukum@...e.com>
Subject: [PATCH 5/8] pcwd_usb: usb_pcwd_ioctl: return IO errors

Reporting back to user space that a watchdog
is disabled although it is not due to an IO error
is evil. Pass through errors.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Oliver Neukum <oneukum@...e.com>
---
 drivers/watchdog/pcwd_usb.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/drivers/watchdog/pcwd_usb.c b/drivers/watchdog/pcwd_usb.c
index fe58ec84ce8c..b99b8fee2873 100644
--- a/drivers/watchdog/pcwd_usb.c
+++ b/drivers/watchdog/pcwd_usb.c
@@ -420,22 +420,30 @@ static long usb_pcwd_ioctl(struct file *file, unsigned int cmd,
 
 	case WDIOC_SETOPTIONS:
 	{
-		int new_options, retval = -EINVAL;
+		int new_options, retval = 0;
+		int r;
+		bool specified_something = false;
 
 		if (get_user(new_options, p))
 			return -EFAULT;
 
 		if (new_options & WDIOS_DISABLECARD) {
-			usb_pcwd_stop(usb_pcwd_device);
-			retval = 0;
+			r = usb_pcwd_stop(usb_pcwd_device);
+			retval = r < 0 ? -EIO : 0;
+			specified_something = true;
 		}
 
+		/*
+		 * technically both options are combinable
+		 * that makes error reporting tricky
+		 */
 		if (new_options & WDIOS_ENABLECARD) {
-			usb_pcwd_start(usb_pcwd_device);
-			retval = 0;
+			r = usb_pcwd_start(usb_pcwd_device);
+			retval = retval < 0 ? retval : (r < 0 ? -EIO : 0);
+			specified_something = true;
 		}
 
-		return retval;
+		return specified_something ? retval : -EINVAL;
 	}
 
 	case WDIOC_KEEPALIVE:
-- 
2.40.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ