Re: device_remove_file and disconnect

From: Greg KH
Date: Wed Jun 29 2005 - 13:55:08 EST


On Wed, Jun 29, 2005 at 06:59:00PM +0200, matthieu castet wrote:
> Hi,
>
> I have a question about sysfs interface.
>
> If you open a sysfs file created by a module, then remove it (rmmoding
> the module that create this sysfs file), then try to read the opened
> file, you often get strange result (segdefault or oppps).

What file did you do this for? The module count should be incremented
if you do this, to prevent the module from being unloaded.

> I attach a small program to test it : open your sysfs file with it
> `wait_read /sysfs/file', rmmod the module, and press enter.
>
> I was wondering if it is to user of sysfs to prevent that (with mutex,
> ...) or it is a sysfs bug ?

Driver bug, odds are they don't set the module owner for the attribute
properly.

> If it is the first case, I fear that lot's of modules are broken.

Remember, only root can unload modules, so it really isn't _that_ big of
a deal (I can do a lot more damage as root than just oopsing the
kernel...)

thanks,

greg k-h
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/