public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail•com>
To: Francesco Ruggeri <fruggeri@arista•com>
Cc: David Miller <davem@davemloft•net>,
	netdev <netdev@vger•kernel.org>,
	Francesco Ruggeri <fruggeri@aristanetworks•com>,
	Willem de Bruijn <willemb@google•com>
Subject: Re: [PATCH net] net/packet: fix a race in packet_bind() and packet_notifier()
Date: Tue, 28 Nov 2017 07:13:01 -0800	[thread overview]
Message-ID: <1511881981.16595.13.camel@gmail.com> (raw)
In-Reply-To: <CA+HUmGh4CGPOmDDAkRy165NTf9PDQkBEY2Da41VZFoVZBBBHxQ@mail.gmail.com>

On Tue, 2017-11-28 at 02:23 -0800, Francesco Ruggeri wrote:
> On Mon, Nov 27, 2017 at 8:00 PM, Eric Dumazet <eric.dumazet@gmail•com
> > wrote:
> > From: Eric Dumazet <edumazet@google•com>
> > 
> > 
...
> > +++ b/net/packet/af_packet.c
> > @@ -336,7 +336,7 @@ static void register_prot_hook(struct sock *sk)
> >  {
> >         struct packet_sock *po = pkt_sk(sk);
> > 
> > -       if (!po->running) {
> > +       if (!po->running && !po->frozen) {
> 
> Would it make sense to move the check for po->frozen to
> packet_notifier(NETDEV_UP)?
> As far as I can tell that is the only case today that can cause this
> race condition, and if new cases come up in the future an error code
> may be required rather than silently turning register_prot_hook()
> into
> a noop.
> Otherwise it looks fine to me.
> 

Whatever works for me is fine, I have no strong opinion on this.

Note that frozen is only set in the case we know that
register_prot_hook() is going to be called by us.

  reply	other threads:[~2017-11-28 15:13 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-28  4:00 [PATCH net] net/packet: fix a race in packet_bind() and packet_notifier() Eric Dumazet
2017-11-28 10:23 ` Francesco Ruggeri
2017-11-28 15:13   ` Eric Dumazet [this message]
2017-11-28 14:48 ` David Miller
2017-11-28 15:14   ` Eric Dumazet
2017-11-28 16:03     ` [PATCH v2 " Eric Dumazet
2017-11-28 16:14       ` David Miller

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=1511881981.16595.13.camel@gmail.com \
    --to=eric.dumazet@gmail$(echo .)com \
    --cc=davem@davemloft$(echo .)net \
    --cc=fruggeri@arista$(echo .)com \
    --cc=fruggeri@aristanetworks$(echo .)com \
    --cc=netdev@vger$(echo .)kernel.org \
    --cc=willemb@google$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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