From: Greg KH <greg@kroah.com>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: Patrick Mochel <mochel@osdl.org>, linux-kernel@vger.kernel.org
Subject: Re: Flaw in the driver-model implementation of attributes
Date: Mon, 16 Jun 2003 10:08:26 -0700 [thread overview]
Message-ID: <20030616170825.GB24986@kroah.com> (raw)
In-Reply-To: <Pine.LNX.4.44L0.0306151221190.32270-100000@netrider.rowland.org>
On Sun, Jun 15, 2003 at 12:42:26PM -0400, Alan Stern wrote:
> If you're already aware of this, please forgive the intrusion.
>
> There's a general problem in the driver model's implementation of
> attribute files, in connection with loadable kernel modules. The
> sysfs_ops structure stores function pointers with no means for identifying
> the module that contains the corresponding code. As a result, it's
> possible to call through one of these pointers even after the module has
> been unloaded, causing an oops.
That's why CONFIG_MODULE_UNLOAD is a new option, if you don't want to
take the risk, don't enable it :)
> It's not hard to provoke this sort of situation. A user process can
> open a sysfs device file, for instance, and delay trying to read it until
> the module containing the device driver has been removed. When the read
> does occur, it runs into trouble.
Then don't let your module unload until _all_ instances of your
structures are gone. You can tell if this is true or not, it's just up
to the implementor :)
Look at the new pcmcia code for just such an example.
If this is in regards to the scsi usage of sysfs, I've been talking to
Mike Anderson a lot about this recently. People are having to realize a
few new things with regards to kernel programming that previously they
have not had to worry about:
- in the past, the only thing that could ever go away while a kernel
was running was a module. So people worried about module reference
counts, and hence the /proc useage of module counts.
- With the advent of hotplug devices, we now have to worry about
individual devices going away, not so much modules. This is causing
layers like the scsi one to be changed a lot to accommodate this
(any pci scsi device can be removed at any time thanks to pci
hotplug systems, and the scsi layer can't really handle this very
well at all until very recently.)
So, the driver model helps out with handling the fact that devices can
go away at any time a lot easier than anything we've had before. It's
now up to the individual kernel modules to control their own module
reference counts to handle if they want to be able to be unloaded before
all of their references are gone now or not.
Look at the usb hid drivers, they _never_ set their reference count :)
Hope this helps,
greg k-h
next prev parent reply other threads:[~2003-06-16 16:55 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-06-15 16:42 Alan Stern
2003-06-15 17:40 ` Jeremy Fitzhardinge
2003-06-16 14:05 ` Alan Stern
2003-06-16 17:08 ` Greg KH [this message]
2003-06-16 17:20 ` Russell King
2003-06-16 17:54 ` Alan Stern
2003-06-16 18:00 ` Patrick Mochel
2003-06-16 18:03 ` viro
2003-06-16 18:23 ` Alan Stern
2003-06-16 18:38 ` Patrick Mochel
2003-06-16 19:06 ` Alan Stern
2003-06-16 18:00 ` Martin Diehl
2003-06-16 18:15 ` viro
[not found] <20030616194446.H13312@flint.arm.linux.org.uk>
2003-06-16 19:36 ` Alan Stern
2003-06-16 20:49 ` Patrick Mochel
2003-06-16 21:29 ` Alan Stern
2003-06-16 22:43 ` Patrick Mochel
2003-06-17 19:49 ` Alan Stern
2003-06-18 1:38 ` Kevin P. Fleming
2003-06-16 23:36 ` Greg KH
2003-06-17 17:29 ` Alan Stern
2003-06-17 17:33 ` Greg KH
2003-06-17 20:20 ` Alan Stern
2003-06-18 3:44 Perez-Gonzalez, Inaky
2003-06-18 4:18 ` viro
2003-06-18 7:48 Perez-Gonzalez, Inaky
2003-06-18 8:12 ` viro
2003-06-18 14:32 ` Alan Stern
2003-06-18 17:15 ` Greg KH
2003-06-18 19:50 ` Alan Stern
2003-06-19 16:42 ` Patrick Mochel
2003-06-19 21:18 ` Alan Stern
2003-06-19 14:13 ` Alan Stern
2003-06-19 17:07 ` Patrick Mochel
2003-06-19 21:14 ` Alan Stern
2003-06-19 21:31 ` Greg KH
2003-06-20 14:22 ` Alan Stern
2003-06-20 18:32 ` Greg KH
2003-07-02 22:12 ` Greg KH
2003-07-03 14:51 ` Alan Stern
2003-06-19 17:26 ` Mike Anderson
2003-06-18 19:52 Perez-Gonzalez, Inaky
2003-06-19 0:06 Clayton Weaver
2003-06-19 0:20 ` Kevin P. Fleming
2003-06-19 16:46 ` Patrick Mochel
2003-06-19 21:18 Perez-Gonzalez, Inaky
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=20030616170825.GB24986@kroah.com \
--to=greg@kroah.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mochel@osdl.org \
--cc=stern@rowland.harvard.edu \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®