* [PATCH] hiddev: Switch to unlocked_ioctl
@ 2008-05-22 21:22 Alan Cox
2008-05-26 8:55 ` Jiri Kosina
0 siblings, 1 reply; 3+ messages in thread
From: Alan Cox @ 2008-05-22 21:22 UTC (permalink / raw)
To: linux-kernel, dmitry.torokhov, linux-usb
Push down the BKL. In some cases compat_ioctl already doesn't take the
BKL so we don't either. Some of the locking here seems already dubious
and object lifetimes want documenting
Signed-off-by: Alan Cox <alan@redhat.com>
diff --git a/drivers/hid/usbhid/hiddev.c b/drivers/hid/usbhid/hiddev.c
index 95cc192..fe4f364 100644
--- a/drivers/hid/usbhid/hiddev.c
+++ b/drivers/hid/usbhid/hiddev.c
@@ -406,6 +406,7 @@ static noinline int hiddev_ioctl_usage(struct hiddev *hiddev, unsigned int cmd,
uref_multi = kmalloc(sizeof(struct hiddev_usage_ref_multi), GFP_KERNEL);
if (!uref_multi)
return -ENOMEM;
+ lock_kernel();
uref = &uref_multi->uref;
if (cmd == HIDIOCGUSAGES || cmd == HIDIOCSUSAGES) {
if (copy_from_user(uref_multi, user_arg,
@@ -501,12 +502,15 @@ static noinline int hiddev_ioctl_usage(struct hiddev *hiddev, unsigned int cmd,
}
goodreturn:
+ unlock_kernel();
kfree(uref_multi);
return 0;
fault:
+ unlock_kernel();
kfree(uref_multi);
return -EFAULT;
inval:
+ unlock_kernel();
kfree(uref_multi);
return -EINVAL;
}
@@ -540,7 +544,7 @@ static noinline int hiddev_ioctl_string(struct hiddev *hiddev, unsigned int cmd,
return len;
}
-static int hiddev_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
+static long hiddev_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
struct hiddev_list *list = file->private_data;
struct hiddev *hiddev = list->hiddev;
@@ -555,7 +559,10 @@ static int hiddev_ioctl(struct inode *inode, struct file *file, unsigned int cmd
struct usbhid_device *usbhid = hid->driver_data;
void __user *user_arg = (void __user *)arg;
int i;
+
+ /* Called without BKL by compat methods so no BKL taken */
+ /* FIXME: Who or what stop this racing with a disconnect ?? */
if (!hiddev->exist)
return -EIO;
@@ -768,7 +775,7 @@ static const struct file_operations hiddev_fops = {
.poll = hiddev_poll,
.open = hiddev_open,
.release = hiddev_release,
- .ioctl = hiddev_ioctl,
+ .unlocked_ioctl = hiddev_ioctl,
.fasync = hiddev_fasync,
#ifdef CONFIG_COMPAT
.compat_ioctl = hiddev_compat_ioctl,
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] hiddev: Switch to unlocked_ioctl
2008-05-22 21:22 [PATCH] hiddev: Switch to unlocked_ioctl Alan Cox
@ 2008-05-26 8:55 ` Jiri Kosina
2008-05-26 10:07 ` Oliver Neukum
0 siblings, 1 reply; 3+ messages in thread
From: Jiri Kosina @ 2008-05-26 8:55 UTC (permalink / raw)
To: Alan Cox; +Cc: linux-kernel, Dmitry Torokhov, linux-usb, Oliver Neukum
On Thu, 22 May 2008, Alan Cox wrote:
> Push down the BKL. In some cases compat_ioctl already doesn't take the
> BKL so we don't either.
Thanks.
> @@ -555,7 +559,10 @@ static int hiddev_ioctl(struct inode *inode, struct file *file, unsigned int cmd
> struct usbhid_device *usbhid = hid->driver_data;
> void __user *user_arg = (void __user *)arg;
> int i;
> +
> + /* Called without BKL by compat methods so no BKL taken */
>
> + /* FIXME: Who or what stop this racing with a disconnect ?? */
> if (!hiddev->exist)
> return -EIO;
Oliver (added to CC) -- I vaguely remember you already fixing this race,
but I don't seem to be able to find the patch anywhere. Do I just remember
incorrectly?
Thanks,
--
Jiri Kosina
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] hiddev: Switch to unlocked_ioctl
2008-05-26 8:55 ` Jiri Kosina
@ 2008-05-26 10:07 ` Oliver Neukum
0 siblings, 0 replies; 3+ messages in thread
From: Oliver Neukum @ 2008-05-26 10:07 UTC (permalink / raw)
To: Jiri Kosina; +Cc: Alan Cox, linux-kernel, Dmitry Torokhov, linux-usb
Am Montag 26 Mai 2008 10:55:09 schrieb Jiri Kosina:
> On Thu, 22 May 2008, Alan Cox wrote:
>
> > Push down the BKL. In some cases compat_ioctl already doesn't take the
> > BKL so we don't either.
>
> Thanks.
>
> > @@ -555,7 +559,10 @@ static int hiddev_ioctl(struct inode *inode, struct file *file, unsigned int cmd
> > struct usbhid_device *usbhid = hid->driver_data;
> > void __user *user_arg = (void __user *)arg;
> > int i;
> > +
> > + /* Called without BKL by compat methods so no BKL taken */
> >
> > + /* FIXME: Who or what stop this racing with a disconnect ?? */
> > if (!hiddev->exist)
> > return -EIO;
>
> Oliver (added to CC) -- I vaguely remember you already fixing this race,
> but I don't seem to be able to find the patch anywhere. Do I just remember
> incorrectly?
I fixed a race between disconnect and open. Ioctl was not involved.
Regards
Oliver
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-05-26 10:08 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-22 21:22 [PATCH] hiddev: Switch to unlocked_ioctl Alan Cox
2008-05-26 8:55 ` Jiri Kosina
2008-05-26 10:07 ` Oliver Neukum
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox