[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1511881981.16595.13.camel@gmail.com>
Date: Tue, 28 Nov 2017 07:13:01 -0800
From: Eric Dumazet <eric.dumazet@...il.com>
To: Francesco Ruggeri <fruggeri@...sta.com>
Cc: David Miller <davem@...emloft.net>,
netdev <netdev@...r.kernel.org>,
Francesco Ruggeri <fruggeri@...stanetworks.com>,
Willem de Bruijn <willemb@...gle.com>
Subject: Re: [PATCH net] net/packet: fix a race in packet_bind() and
packet_notifier()
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@...il.com
> > wrote:
> > From: Eric Dumazet <edumazet@...gle.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.
Powered by blists - more mailing lists