Right now, a user which has read privileges to usbdevfs devices can't get
the driver bound to an interface via the usbdevfs interface.

However, it is exposed via the devices file so I don't think this is on
purpose.

Would a patch like this be acceptable? (Untested, but it compiles)

JE

===== devio.c 1.16 vs edited =====
--- 1.16/drivers/usb/devio.c    Fri Nov 29 01:16:17 2002
+++ edited/devio.c      Thu Dec  5 15:21:39 2002
@@ -1139,13 +1139,32 @@
        struct dev_state *ps = (struct dev_state *)file->private_data;
        int ret = -ENOIOCTLCMD;
 
-       if (!(file->f_mode & FMODE_WRITE))
-               return -EPERM;
        down_read(&ps->devsem);
        if (!ps->dev) {
                up_read(&ps->devsem);
                return -ENODEV;
        }
+
+       switch (cmd) {
+       case USBDEVFS_GETDRIVER:
+               ret = proc_getdriver(ps, (void *)arg);
+               break;
+
+       case USBDEVFS_CONNECTINFO:
+               ret = proc_connectinfo(ps, (void *)arg);
+               break;
+
+       case USBDEVFS_DISCSIGNAL:
+               ret = proc_disconnectsignal(ps, (void *)arg);
+               break;
+       }
+
+       if (!(file->f_mode & FMODE_WRITE))
+               ret = -EPERM;
+
+       if (ret != -ENOIOCTLCMD)
+               goto out;
+
        switch (cmd) {
        case USBDEVFS_CONTROL:
                ret = proc_control(ps, (void *)arg);
@@ -1175,14 +1194,6 @@
                        inode->i_mtime = CURRENT_TIME;
                break;
 
-       case USBDEVFS_GETDRIVER:
-               ret = proc_getdriver(ps, (void *)arg);
-               break;
-
-       case USBDEVFS_CONNECTINFO:
-               ret = proc_connectinfo(ps, (void *)arg);
-               break;
-
        case USBDEVFS_SETINTERFACE:
                ret = proc_setintf(ps, (void *)arg);
                break;
@@ -1209,10 +1220,6 @@
                ret = proc_reapurbnonblock(ps, (void *)arg);
                break;
 
-       case USBDEVFS_DISCSIGNAL:
-               ret = proc_disconnectsignal(ps, (void *)arg);
-               break;
-
        case USBDEVFS_CLAIMINTERFACE:
                ret = proc_claiminterface(ps, (void *)arg);
                break;
@@ -1225,6 +1232,8 @@
                ret = proc_ioctl(ps, (void *) arg);
                break;
        }
+
+out:
        up_read(&ps->devsem);
        if (ret >= 0)
                inode->i_atime = CURRENT_TIME;

Reply via email to