Bug 1418 - usbfs does not honor devgid and friends
Summary: usbfs does not honor devgid and friends
Status: RESOLVED CODE_FIX
Alias: None
Product: Drivers
Classification: Unclassified
Component: USB (show other bugs)
Hardware: i386 Linux
: P2 normal
Assignee: Greg Kroah-Hartman
URL:
Keywords:
: 2575 (view as bug list)
Depends on:
Blocks:
 
Reported: 2003-10-24 12:47 UTC by Miek Gieben
Modified: 2004-08-23 00:40 UTC (History)
6 users (show)

See Also:
Kernel Version: 2.6.0-test8
Subsystem:
Regression: ---
Bisected commit-id:


Attachments
partial fix (702 bytes, patch)
2003-12-19 21:42 UTC, Tyler Nielsen
Details | Diff
Gives users access to usb devices (279 bytes, application/octet-stream)
2004-03-20 16:52 UTC, James Kyle
Details

Description Miek Gieben 2003-10-24 12:47:23 UTC
Distribution: Debian 
Hardware Environment: Athlon XP 
Software Environment:  
Problem Description:  
The usbfs filesystem does not seem to honor the devuid and devgid and what not 
from the mount option. 
 
Steps to reproduce: just try to mount /proc/bus/usb with devuid and devgid it 
will always by root.root
Comment 1 Stian Jordet 2003-12-08 05:47:35 UTC
This is a terribly annoying bug, I have to agree. Too bad it has been ignored
for so long :(
Comment 2 Greg Kroah-Hartman 2003-12-08 11:11:09 UTC
I agree, got time to work on a fix?  Right now I don't sorry...
Comment 3 Miek Gieben 2003-12-09 01:10:41 UTC
Work on a fix, why didn't I think of that :-) I will try to look at it 
this week. But as I'm a total newbie in kernel programming, I can not  
garantee anything. If one looks in inode.c all the option parsing seems to  
be present - but it is just not activated somehow. Anyway I will take a peek. 
Comment 4 Stian Jordet 2003-12-10 16:18:43 UTC
Sorry for sounding rude here. I really didn't mean it that way. I might try to
see if I can trace it down a bit. Sorry.
Comment 5 Tyler Nielsen 2003-12-19 21:42:33 UTC
Created attachment 1703 [details]
partial fix
Comment 6 Tyler Nielsen 2003-12-19 21:53:45 UTC
It looks like the problem is that there is some buffering going on.  Thhe code 
that pulls out options isn't called after the first time through.  When you 
modprobe *-hcd, it calls the code at that point.  When you mount it with 
options that part of the code is skipped (because the superblock is already 
setup). 
 
There is a workaround for what is in 2.6.0.  modprobe usbcore.  
mount /proc/bus/usb with options, then modprobe *-hcd. 
 
The patch should fix the problem for any device plugged in after the mount 
command is executed.  You can then just do a rmmod *-hcd, then a modprobe *-hcd 
(which does the remove-attach for everything else). 
 
What remains to be done is applying the options to devices already plugged in.  
I have started looking at it, but I don't know when I will get time to figure 
something out. 
Comment 7 Randy Dunlap 2004-01-28 22:05:02 UTC
In testing, I noticed that the previous values of *uid, *gid, *mode are
used in subsequent mounts.  This doesn't seem desirable.  Is it,
or should they be cleared to 0 on each (new) mount?
Comment 8 James Kyle 2004-03-20 16:52:25 UTC
Created attachment 2374 [details]
Gives users access to usb devices

Of course you can modify the script to give any combination of
user:group:others permissions that you want.
Comment 9 Domen Puncer Kugler 2004-03-21 07:58:55 UTC
I investigated this a little.

usbfs is not mounted on mount from userspace, but before, when the first bus is
added:
 [<c0305c34>] usb_get_sb+0x14/0xa0
 [<c0181c66>] do_kern_mount+0x56/0xd0
 [<c01a84f2>] simple_pin_fs+0x1d2/0x350
 [<c0305d13>] create_special_files+0x23/0x1c0
 [<c0305fb9>] usbfs_add_bus+0x19/0x120

So this makes hard to process dev[ug]id options, because the files are already
created. (Tyler's fix works only for devices added after mounting)

Options for solving this:
- drop dev[ug]id, do this from userspace like James suggested
- chown files from kernel on each mount
- rearrange code to mount only when we want to mount (don't know how this would
work for files already created)

Suggestions?
Comment 10 Tyler Nielsen 2004-03-21 10:05:49 UTC
In my opinion, chown/chmod files from kernel on each mount is the correct way to
handle this.  I looked at it for a bit, but I don't have very much experiance in
the kernel, and couldn't find a good way to do it.
Comment 11 Greg Kroah-Hartman 2004-04-22 22:42:55 UTC
*** Bug 2575 has been marked as a duplicate of this bug. ***
Comment 12 Greg Kroah-Hartman 2004-08-23 00:40:57 UTC
Should be now fixed in 2.6.8

Note You need to log in before you can comment on or make changes to this bug.