From: Stephen Hemminger <shemminger@vyatta.com>
To: ebiederm@xmission.com (Eric W. Biederman)
Cc: Herbert Xu <herbert@gondor.apana.org.au>,
Patrick McHardy <kaber@trash.net>,
Linux Netdev List <netdev@vger.kernel.org>,
"David S. Miller" <davem@davemloft.net>
Subject: Re: IPv4/IPv6 sysctl unregistration deadlock
Date: Thu, 26 Feb 2009 08:49:24 -0800 [thread overview]
Message-ID: <20090226084924.16cb3e08@nehalam> (raw)
In-Reply-To: <m14oyhis31.fsf@fess.ebiederm.org>
On Wed, 25 Feb 2009 23:18:42 -0800
ebiederm@xmission.com (Eric W. Biederman) wrote:
> Herbert Xu <herbert@gondor.apana.org.au> writes:
>
> > On Wed, Feb 25, 2009 at 10:10:33PM -0800, Eric W. Biederman wrote:
> >>
> >> How does adding a rename operation to sysctl sound?
> >
> > Yes that would definitely help. Of course for the unregister case
> > we'd still need either an async removal or a no-op as Patrick
> > suggested.
>
> After having reread the thread and looking at the code I think
> I understand what is happening.
>
> sysctl, proc, and sysfs all need to wait until there are no
> more users before their unregister operation succeeds. So that
> we can guarantee that it is safe to remove a module that provides
> the callback function.
>
> Currently ndo_stop, NETDEV_DOWN, unlist_netdevice and I don't
> know how much other code is run from unregister_netdevice
> with the rtnl lock. If we do an asynchronous unregister
> we need to ensure that entire code path is safe without
> rtnl_lock. And we would need to run the unregister work
> from rtnl_lock.
>
> Ugh. netdev_store() and a few other functions in net-sysfs.c
> take rtnl_lock. The instance in netdev_store appears to date
> back to 21 May 2003 sometime during 2.5.
>
> So this is an old problem that we are just noticing now. Ugh.
>
> Currently rtnl_lock() protects the netdevice_notifier_chain.
> So it appears we need to hold rtnl_lock().
>
> Which leads me to conclude either we need to completely rewrite the
> locking rules for the networking stack, or we need to teach the sysfs,
> sysctl, and proc how to grab a subsystem lock around a callback.
>
> We already do this for netlink with netlink_create_kernel.
>
> So I guess we need a variants of:
> register_sysctl_table, proc_create, and class_create_file.
>
> What a pain, but at least it looks like it can work.
>
> Eric
What about something like this:
Subject: [PATCH] Avoid race between network down and sysfs
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
--- a/net/core/net-sysfs.c 2009-02-26 08:36:18.000000000 -0800
+++ b/net/core/net-sysfs.c 2009-02-26 08:37:51.000000000 -0800
@@ -77,7 +77,9 @@ static ssize_t netdev_store(struct devic
if (endp == buf)
goto err;
- rtnl_lock();
+ if (!rtnl_trylock())
+ return -ERESTARTSYS;
+
if (dev_isalive(net)) {
if ((ret = (*set)(net, new)) == 0)
ret = len;
next prev parent reply other threads:[~2009-02-26 16:49 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-25 5:23 IPv4/IPv6 sysctl unregistration deadlock Patrick McHardy
2009-02-25 6:19 ` Herbert Xu
2009-02-25 6:23 ` Patrick McHardy
2009-02-25 7:18 ` Patrick McHardy
2009-02-25 8:43 ` Herbert Xu
2009-02-26 6:06 ` Eric W. Biederman
2009-02-26 6:10 ` Eric W. Biederman
2009-02-26 6:22 ` Herbert Xu
2009-02-26 7:18 ` Eric W. Biederman
2009-02-26 16:49 ` Stephen Hemminger [this message]
2009-02-26 19:01 ` Eric W. Biederman
2009-02-26 20:24 ` Stephen Hemminger
2009-02-27 0:59 ` Herbert Xu
2009-02-27 1:25 ` Stephen Hemminger
2009-02-27 18:26 ` Ben Greear
2009-02-27 18:38 ` Stephen Hemminger
2009-03-02 11:07 ` Patrick McHardy
2009-03-02 11:21 ` Patrick McHardy
2009-03-02 22:11 ` Ben Greear
2009-03-02 22:20 ` Patrick McHardy
2009-03-02 22:47 ` David Miller
2009-03-02 23:03 ` Patrick McHardy
2009-03-03 8:48 ` David Miller
2009-03-08 3:36 ` Eric W. Biederman
2009-02-26 16:55 ` Stephen Hemminger
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=20090226084924.16cb3e08@nehalam \
--to=shemminger@vyatta.com \
--cc=davem@davemloft.net \
--cc=ebiederm@xmission.com \
--cc=herbert@gondor.apana.org.au \
--cc=kaber@trash.net \
--cc=netdev@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.