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, 24 Mar 2009 16:12:43 -0500
From:	stoyboyker@...il.com
To:	linux-kernel@...r.kernel.org
Cc:	Stoyan Gaydarov <stoyboyker@...il.com>, wim@...ana.be
Subject: [PATCH 08/13] [watchdog] changed ioctls to unlocked

From: Stoyan Gaydarov <stoyboyker@...il.com>

Signed-off-by: Stoyan Gaydarov <stoyboyker@...il.com>
---
 drivers/watchdog/riowd.c |   37 +++++++++++++++++++++++++++----------
 1 files changed, 27 insertions(+), 10 deletions(-)

diff --git a/drivers/watchdog/riowd.c b/drivers/watchdog/riowd.c
index 09cb183..44058c1 100644
--- a/drivers/watchdog/riowd.c
+++ b/drivers/watchdog/riowd.c
@@ -86,9 +86,10 @@ static int riowd_release(struct inode *inode, struct file *filp)
 	return 0;
 }
 
-static int riowd_ioctl(struct inode *inode, struct file *filp,
-		       unsigned int cmd, unsigned long arg)
+static long riowd_ioctl(struct file *filp, unsigned int cmd,
+		       unsigned long arg)
 {
+	lock_kernel();
 	static struct watchdog_info info = {
 		.options		= WDIOF_SETTIMEOUT,
 		.firmware_version	= 1,
@@ -101,14 +102,18 @@ static int riowd_ioctl(struct inode *inode, struct file *filp,
 
 	switch (cmd) {
 	case WDIOC_GETSUPPORT:
-		if (copy_to_user(argp, &info, sizeof(info)))
+		if (copy_to_user(argp, &info, sizeof(info))) {
+			unlock_kernel();
 			return -EFAULT;
+		}
 		break;
 
 	case WDIOC_GETSTATUS:
 	case WDIOC_GETBOOTSTATUS:
-		if (put_user(0, (int __user *)argp))
+		if (put_user(0, (int __user *)argp)) {
+			unlock_kernel();
 			return -EFAULT;
+		}
 		break;
 
 	case WDIOC_KEEPALIVE:
@@ -116,34 +121,46 @@ static int riowd_ioctl(struct inode *inode, struct file *filp,
 		break;
 
 	case WDIOC_SETOPTIONS:
-		if (copy_from_user(&options, argp, sizeof(options)))
+		if (copy_from_user(&options, argp, sizeof(options))) {
+			unlock_kernel();
 			return -EFAULT;
+		}
 
 		if (options & WDIOS_DISABLECARD)
 			riowd_writereg(p, 0, WDTO_INDEX);
 		else if (options & WDIOS_ENABLECARD)
 			riowd_writereg(p, riowd_timeout, WDTO_INDEX);
-		else
+		else {
+			unlock_kernel();
 			return -EINVAL;
+		}
 
 		break;
 
 	case WDIOC_SETTIMEOUT:
-		if (get_user(new_margin, (int __user *)argp))
+		if (get_user(new_margin, (int __user *)argp)) {
+			unlock_kernel();
 			return -EFAULT;
-		if ((new_margin < 60) || (new_margin > (255 * 60)))
+		}
+		if ((new_margin < 60) || (new_margin > (255 * 60))) {
+			unlock_kernel();
 			return -EINVAL;
+		}
 		riowd_timeout = (new_margin + 59) / 60;
 		riowd_writereg(p, riowd_timeout, WDTO_INDEX);
 		/* Fall */
 
 	case WDIOC_GETTIMEOUT:
-		return put_user(riowd_timeout * 60, (int __user *)argp);
+		long ret = put_user(riowd_timeout * 60, (int __user *)argp);
+		unlock_kernel();
+		return ret;
 
 	default:
+		unlock_kernel();
 		return -EINVAL;
 	};
 
+	unlock_kernel();
 	return 0;
 }
 
@@ -162,7 +179,7 @@ static ssize_t riowd_write(struct file *file, const char __user *buf, size_t cou
 static const struct file_operations riowd_fops = {
 	.owner =	THIS_MODULE,
 	.llseek =	no_llseek,
-	.ioctl =	riowd_ioctl,
+	.unlocked_ioctl =	riowd_ioctl,
 	.open =		riowd_open,
 	.write =	riowd_write,
 	.release =	riowd_release,
-- 
1.6.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ