From: David Miller <davem@davemloft.net>
To: eric.dumazet@gmail.com
Cc: nschichan@freebox.fr, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, edumazet@google.com,
xiyou.wangcong@gmail.com
Subject: Re: [PATCH v3.10-rc7] net: fix kernel deadlock with interface rename and netdev name retrieval.
Date: Wed, 26 Jun 2013 13:44:05 -0700 (PDT) [thread overview]
Message-ID: <20130626.134405.464630881670006463.davem@davemloft.net> (raw)
In-Reply-To: <1372264414.3301.198.camel@edumazet-glaptop>
From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Wed, 26 Jun 2013 09:33:34 -0700
> On Wed, 2013-06-26 at 17:23 +0200, Nicolas Schichan wrote:
>> When the kernel (compiled with CONFIG_PREEMPT=n) is performing the
>> rename of a network interface, it can end up waiting for a workqueue
>> to complete. If userland is able to invoke a SIOCGIFNAME ioctl or a
>> SO_BINDTODEVICE getsockopt in between, the kernel will deadlock due to
>> the fact that read_secklock_begin() will spin forever waiting for the
>> writer process (the one doing the interface rename) to update the
>> devnet_rename_seq sequence.
>>
>> This patch fixes the problem by adding a helper (netdev_get_name())
>> and using it in the code handling the SIOCGIFNAME ioctl and
>> SO_BINDTODEVICE setsockopt.
>>
>> The netdev_get_name() helper uses raw_seqcount_begin() to avoid
>> spinning forever, waiting for devnet_rename_seq->sequence to become
>> even. cond_resched() is used in the contended case, before retrying
>> the access to give the writer process a chance to finish.
>>
>> The use of raw_seqcount_begin() will incur some unneeded work in the
>> reader process in the contended case, but this is better than
>> deadlocking the system.
>>
>> Signed-off-by: Nicolas Schichan <nschichan@freebox.fr>
>> ---
>
> This goes back to commit c91f6df2db49
> ("sockopt: Change getsockopt() of SO_BINDTODEVICE to return an interface
> name") in linux-3.8
>
> Acked-by: Eric Dumazet <edumazet@google.com>
Applied and queued up for -stable, thanks everyone.
prev parent reply other threads:[~2013-06-26 20:44 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-26 15:23 [PATCH v3.10-rc7] net: fix kernel deadlock with interface rename and netdev name retrieval Nicolas Schichan
2013-06-26 16:33 ` Eric Dumazet
2013-06-26 20:44 ` David Miller [this message]
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=20130626.134405.464630881670006463.davem@davemloft.net \
--to=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=eric.dumazet@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=nschichan@freebox.fr \
--cc=xiyou.wangcong@gmail.com \
/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;
as well as URLs for NNTP newsgroup(s).