All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nikanth Karthikesan <knikanth@suse.de>
To: grant@torque.net, tim@cyberelk.net
Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: [PATCH] Change paride driver to use unlocked_ioctl instead of ioctl
Date: Wed, 09 Jan 2008 06:12:38 +0000	[thread overview]
Message-ID: <4785B7BC.5040106@suse.de> (raw)

The ioctl handler is called with the BKL held. Registering
unlocked_ioctl handler instead of registering ioctl handler.


Signed-off-by: Nikanth Karthikesan <knikanth@suse.de>

---

diff --git a/arch/x86/kernel/cpu/mcheck/mce_64.c
b/arch/x86/kernel/cpu/mcheck/mce_64.c
diff --git a/drivers/block/paride/pt.c b/drivers/block/paride/pt.c
index b91accf..d4fa468 100644
--- a/drivers/block/paride/pt.c
+++ b/drivers/block/paride/pt.c
@@ -236,7 +236,7 @@ static const struct file_operations pt_fops = {
 	.owner = THIS_MODULE,
 	.read = pt_read,
 	.write = pt_write,
-	.ioctl = pt_ioctl,
+	.unlocked_ioctl = pt_ioctl,
 	.open = pt_open,
 	.release = pt_release,
 };
@@ -685,36 +685,43 @@ out:
 	return err;
 }

-static int pt_ioctl(struct inode *inode, struct file *file,
-	 unsigned int cmd, unsigned long arg)
+static long pt_ioctl(struct file *file, unsigned int cmd, unsigned long
arg)
 {
 	struct pt_unit *tape = file->private_data;
 	struct mtop __user *p = (void __user *)arg;
 	struct mtop mtop;

+	lock_kernel();
+
 	switch (cmd) {
 	case MTIOCTOP:
-		if (copy_from_user(&mtop, p, sizeof(struct mtop)))
+		if (copy_from_user(&mtop, p, sizeof(struct mtop))) {
+			unlock_kernel();
 			return -EFAULT;
+		}

 		switch (mtop.mt_op) {

 		case MTREW:
 			pt_rewind(tape);
+			unlock_kernel();
 			return 0;

 		case MTWEOF:
 			pt_write_fm(tape);
+			unlock_kernel();
 			return 0;

 		default:
 			printk("%s: Unimplemented mt_op %d\n", tape->name,
 			       mtop.mt_op);
+			unlock_kernel();
 			return -EINVAL;
 		}

 	default:
 		printk("%s: Unimplemented ioctl 0x%x\n", tape->name, cmd);
+		unlock_kernel();
 		return -EINVAL;

 	}

WARNING: multiple messages have this Message-ID (diff)
From: Nikanth Karthikesan <knikanth@suse.de>
To: grant@torque.net, tim@cyberelk.net
Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: [PATCH] Change paride driver to use unlocked_ioctl instead of ioctl
Date: Thu, 10 Jan 2008 11:44:20 +0530	[thread overview]
Message-ID: <4785B7BC.5040106@suse.de> (raw)

The ioctl handler is called with the BKL held. Registering
unlocked_ioctl handler instead of registering ioctl handler.


Signed-off-by: Nikanth Karthikesan <knikanth@suse.de>

---

diff --git a/arch/x86/kernel/cpu/mcheck/mce_64.c
b/arch/x86/kernel/cpu/mcheck/mce_64.c
diff --git a/drivers/block/paride/pt.c b/drivers/block/paride/pt.c
index b91accf..d4fa468 100644
--- a/drivers/block/paride/pt.c
+++ b/drivers/block/paride/pt.c
@@ -236,7 +236,7 @@ static const struct file_operations pt_fops = {
 	.owner = THIS_MODULE,
 	.read = pt_read,
 	.write = pt_write,
-	.ioctl = pt_ioctl,
+	.unlocked_ioctl = pt_ioctl,
 	.open = pt_open,
 	.release = pt_release,
 };
@@ -685,36 +685,43 @@ out:
 	return err;
 }

-static int pt_ioctl(struct inode *inode, struct file *file,
-	 unsigned int cmd, unsigned long arg)
+static long pt_ioctl(struct file *file, unsigned int cmd, unsigned long
arg)
 {
 	struct pt_unit *tape = file->private_data;
 	struct mtop __user *p = (void __user *)arg;
 	struct mtop mtop;

+	lock_kernel();
+
 	switch (cmd) {
 	case MTIOCTOP:
-		if (copy_from_user(&mtop, p, sizeof(struct mtop)))
+		if (copy_from_user(&mtop, p, sizeof(struct mtop))) {
+			unlock_kernel();
 			return -EFAULT;
+		}

 		switch (mtop.mt_op) {

 		case MTREW:
 			pt_rewind(tape);
+			unlock_kernel();
 			return 0;

 		case MTWEOF:
 			pt_write_fm(tape);
+			unlock_kernel();
 			return 0;

 		default:
 			printk("%s: Unimplemented mt_op %d\n", tape->name,
 			       mtop.mt_op);
+			unlock_kernel();
 			return -EINVAL;
 		}

 	default:
 		printk("%s: Unimplemented ioctl 0x%x\n", tape->name, cmd);
+		unlock_kernel();
 		return -EINVAL;

 	}

             reply	other threads:[~2008-01-09  6:12 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-09  6:12 Nikanth Karthikesan [this message]
2008-01-10  6:14 ` [PATCH] Change paride driver to use unlocked_ioctl instead of ioctl Nikanth Karthikesan
2008-01-09  7:19 ` [PATCH] Change paride driver to use unlocked_ioctl instead of Nikanth Karthikesan
2008-01-10  7:23   ` [PATCH] Change paride driver to use unlocked_ioctl instead of ioctl Nikanth Karthikesan
2008-01-09 12:33   ` Matthew Wilcox
2008-01-09 12:33     ` Matthew Wilcox
2008-01-09 13:26     ` [PATCH] Change paride driver to use unlocked_ioctl instead of Jiri Kosina
2008-01-09 13:26       ` [PATCH] Change paride driver to use unlocked_ioctl instead of ioctl Jiri Kosina
2008-01-09 16:56       ` [PATCH] Change paride driver to use unlocked_ioctl instead of Alan Cox
2008-01-09 16:56         ` [PATCH] Change paride driver to use unlocked_ioctl instead of ioctl Alan Cox
2008-01-10 15:01         ` [PATCH] Change paride driver to use unlocked_ioctl instead of Jiri Kosina
2008-01-10 15:01           ` [PATCH] Change paride driver to use unlocked_ioctl instead of ioctl Jiri Kosina
2008-01-10 20:58           ` [PATCH] Change paride driver to use unlocked_ioctl instead of Alan Cox
2008-01-10 20:58             ` [PATCH] Change paride driver to use unlocked_ioctl instead of ioctl Alan Cox
     [not found]         ` <478681FE.BANGALORE.BLR.100.174746A.1.ECB1.1@1:7.BANGALORE.BLR.100.0.1.0.1@16>
2008-01-10 15:31           ` Nikanth Karthikesan
2008-01-10 15:43             ` [PATCH] Change paride driver to use unlocked_ioctl instead of Nikanth Karthikesan
2008-01-10 15:50             ` [PATCH] Change paride driver to use unlocked_ioctl instead of ioctl Matthew Wilcox
2008-01-10 15:50               ` Matthew Wilcox
     [not found]       ` <47854BF3.BANGALORE.BLR.100.174746A.1.EB89.1@1:7.BANGALORE.BLR.100.0.1.0.1@16>
2008-01-10  5:29         ` Nikanth Karthikesan
2008-01-10  5:41           ` [PATCH] Change paride driver to use unlocked_ioctl instead of Nikanth Karthikesan
2008-01-09  8:06 ` Christoph Hellwig
2008-01-09  8:06   ` [PATCH] Change paride driver to use unlocked_ioctl instead of ioctl Christoph Hellwig
2008-01-09  8:23   ` Valdis.Kletnieks
2008-01-09  8:23     ` Valdis.Kletnieks
     [not found]   ` <4784D3E0.BANGALORE.BLR.100.174746A.1.EABB.1@1:7.BANGALORE.BLR.100.0.1.0.1@16>
2008-01-09  8:52     ` [PATCH] Change paride driver to use unlocked_ioctl instead of Nikanth Karthikesan
2008-01-10  8:55       ` [PATCH] Change paride driver to use unlocked_ioctl instead of ioctl Nikanth Karthikesan
2008-01-09 12:14       ` [PATCH] Change paride driver to use unlocked_ioctl instead of Jan Engelhardt
2008-01-09 12:14         ` [PATCH] Change paride driver to use unlocked_ioctl instead of ioctl Jan Engelhardt
2008-01-09 12:20         ` [PATCH] Change paride driver to use unlocked_ioctl instead of Christoph Hellwig
2008-01-09 12:20           ` [PATCH] Change paride driver to use unlocked_ioctl instead of ioctl Christoph Hellwig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4785B7BC.5040106@suse.de \
    --to=knikanth@suse.de \
    --cc=grant@torque.net \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tim@cyberelk.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.