From: Cornelia Huck <cornelia.huck@de.ibm.com>
To: "Markus Rechberger" <markus.rechberger@amd.com>
Cc: "Alan Stern" <stern@rowland.harvard.edu>,
"USB development list" <linux-usb-devel@lists.sourceforge.net>,
"Kernel development list" <linux-kernel@vger.kernel.org>
Subject: Re: How should an exit routine wait for release() callbacks?
Date: Fri, 13 Apr 2007 16:27:01 +0200 [thread overview]
Message-ID: <20070413162701.4e7342a9@gondolin.boeblingen.de.ibm.com> (raw)
In-Reply-To: <461F9076.4070209@amd.com>
On Fri, 13 Apr 2007 16:15:18 +0200,
"Markus Rechberger" <markus.rechberger@amd.com> wrote:
> most dvb usb drivers call the device node unregistration when a device
> gets unplugged (when
> At this time the filehandle can still be open, the patch on that site
> sets a flag that disallows
> any further access to the device node (in the DVB framework there are 4
> of such nodes)
> This can happen any time, so while someone is reading or accessing the
> device some structures
> might have gone away already and this could cause an oops.
> The problem of the DVB framework is file operation related, the last
> user calls fops_put on the existing
> structure and sets the pointer to NULL before it wakes up the other
> function which frees the file operation
> structure.
OK, thanks for the explanation.
> In Alan's case isn't there any users flag available that shows that the
> structure is still beeing accessed?
> If that would be the case he could set a flag when he enters my_exit
> which would disable access to all other
> functions by returning an error value at the beginning of the other
> functions, the only way out would be
> to call my_release for existing users and wake up my_exit when the last
> reference to that structure is gone.
>
> Some more information about the whole driver/scenario would be helpful.
In this case the race is not a user space vs. kernel object one (where
you can track users). Basically the problem is as follows:
- A module registers a device. The device's release function is defined
in the module.
- Since the device can now be looked up in the device tree, someone can
obtain a reference to it (e. g. by walking the tree).
- The module is unloaded. In its exit function, it deregisters the
device. The module has now given up any reference to the device it
held, however the someone from above still holds a reference. While no
new reference to the device can be obtained, the device still exists.
- After the module is unloaded, the device's release function goes away.
- The last reference to the device is given up. The driver core now
tries to call the device's release function, which was in the deleted
module. Oops.
The completion approach unfortunately still leaves a race window, as
Alan explained in his original mail.
next prev parent reply other threads:[~2007-04-13 14:24 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-04-12 21:23 Alan Stern
2007-04-13 9:03 ` Cornelia Huck
2007-04-13 11:42 ` Markus Rechberger
2007-04-13 13:24 ` Cornelia Huck
2007-04-13 14:15 ` Markus Rechberger
2007-04-13 14:27 ` Cornelia Huck [this message]
2007-04-13 15:24 ` Alan Stern
2007-04-16 8:53 ` Cornelia Huck
2007-04-16 14:43 ` Alan Stern
2007-04-16 14:51 ` [linux-usb-devel] " Robert Marquardt
2007-04-16 15:05 ` Cornelia Huck
2007-04-16 22:12 ` [linux-usb-devel] " Greg KH
2007-04-17 7:26 ` Cornelia Huck
2007-04-17 15:59 ` Alan Stern
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=20070413162701.4e7342a9@gondolin.boeblingen.de.ibm.com \
--to=cornelia.huck@de.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb-devel@lists.sourceforge.net \
--cc=markus.rechberger@amd.com \
--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®