From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Dumazet Subject: Re: [PATCH net] net/packet: fix a race in packet_bind() and packet_notifier() Date: Tue, 28 Nov 2017 07:14:55 -0800 Message-ID: <1511882095.16595.14.camel@gmail.com> References: <1511841652.16595.11.camel@gmail.com> <20171128.094855.1432729042351719024.davem@davemloft.net> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit Cc: netdev@vger.kernel.org, fruggeri@aristanetworks.com, willemb@google.com To: David Miller Return-path: Received: from mail-pg0-f44.google.com ([74.125.83.44]:37331 "EHLO mail-pg0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752050AbdK1PO6 (ORCPT ); Tue, 28 Nov 2017 10:14:58 -0500 Received: by mail-pg0-f44.google.com with SMTP id y6so56173pgp.4 for ; Tue, 28 Nov 2017 07:14:58 -0800 (PST) In-Reply-To: <20171128.094855.1432729042351719024.davem@davemloft.net> Sender: netdev-owner@vger.kernel.org List-ID: On Tue, 2017-11-28 at 09:48 -0500, David Miller wrote: > From: Eric Dumazet > Date: Mon, 27 Nov 2017 20:00:52 -0800 > > > @@ -368,9 +368,11 @@ static void __unregister_prot_hook(struct sock > *sk, bool sync) > >       __sock_put(sk); > >   > >       if (sync) { > > +             po->frozen = 1; > >               spin_unlock(&po->bind_lock); > >               synchronize_net(); > >               spin_lock(&po->bind_lock); > > +             po->frozen = 0; > >       } > >  } > >   > > Ugh. > > Maybe you can just set po->num to zero in the bind code path which > causes > this problem.  That will prevent this situation entirely. Yes, I can submit a V2 with this idea implemented, thanks.