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: <1268162386-2745-2-git-send-email-cascardo@holoscopio.com>
Date:	Tue,  9 Mar 2010 16:19:45 -0300
From:	Thadeu Lima de Souza Cascardo <cascardo@...oscopio.com>
To:	Dmitry Torokhov <dmitry.torokhov@...il.com>
Cc:	linux-input@...r.kernel.org, linux-kernel@...r.kernel.org,
	Arnd Bergmann <arnd@...db.de>, John Kacur <jkacur@...il.com>,
	Thadeu Lima de Souza Cascardo <cascardo@...oscopio.com>
Subject: [PATCH 2/3] input: use input_mutex instead of BKL when opening input device

There are three types of input character devices: mousedev, joydev and
evdev. They all use the same major device and, then, their opening is
multiplexed in input_open_file.

After the BKL pushdown, this multiplexing is protected by the BKL. But
there's already a mutex used for adding and removing to the table
indexed by input_open_file.

So, we use this mutex instead of the BKL. Since it will call the
handlers' open function under the mutex, I've checked that the current
functions do not call input_{un,}register_{handler,device}, which are
the only other functions to take the mutex.

Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@...oscopio.com>
---
 drivers/input/input.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/input/input.c b/drivers/input/input.c
index 41168d5..af9c246 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -23,7 +23,6 @@
 #include <linux/device.h>
 #include <linux/mutex.h>
 #include <linux/rcupdate.h>
-#include <linux/smp_lock.h>
 #include "input-compat.h"
 
 MODULE_AUTHOR("Vojtech Pavlik <vojtech@...e.cz>");
@@ -1881,7 +1880,7 @@ static int input_open_file(struct inode *inode, struct file *file)
 	const struct file_operations *old_fops, *new_fops = NULL;
 	int err;
 
-	lock_kernel();
+	mutex_lock(&input_mutex);
 	/* No load-on-demand here? */
 	handler = input_table[iminor(inode) >> 5];
 	if (!handler || !(new_fops = fops_get(handler->fops))) {
@@ -1909,7 +1908,7 @@ static int input_open_file(struct inode *inode, struct file *file)
 	}
 	fops_put(old_fops);
 out:
-	unlock_kernel();
+	mutex_unlock(&input_mutex);
 	return err;
 }
 
-- 
1.6.6.1

--
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