From: Sabrina Dubroca <sd@queasysnail.net>
To: Antonio Quartulli <antonio@openvpn.net>
Cc: Jakub Kicinski <kuba@kernel.org>,
netdev@vger.kernel.org, Hyunwoo Kim <imv4bel@gmail.com>,
Paolo Abeni <pabeni@redhat.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>
Subject: Re: [PATCH net 1/1] ovpn: fix race between deleting interface and adding new peer
Date: Thu, 26 Mar 2026 10:13:07 +0100 [thread overview]
Message-ID: <acT4o2VwsGk8o3jG@krikkit> (raw)
In-Reply-To: <9c891d6c-1064-4f35-8982-3e2dcb3290f5@openvpn.net>
2026-03-25, 14:37:36 +0100, Antonio Quartulli wrote:
> Hi!
>
> On 24/03/2026 23:40, Sabrina Dubroca wrote:
> > 2026-03-24, 14:30:06 -0700, Jakub Kicinski wrote:
> > > LGTM. This or change all the write paths to check if the device is still
> > > alive after taking the lock.
> >
> > I think peer_new is the only relevant path here (other paths use an
> > existing peer and modify/delete the peer itself or its keys while
> > holding a reference), and we don't take a lock except to insert the
> > peer in the ovpn instance (ie netdev)'s hashtable (or peer slot, for
> > single-peer instances). I guess we could add the reg_state >=
> > NETREG_UNREGISTERING check to ovpn_peer_add_{p2p,mp} and reject adding
> > the peer. It seems cleaner than my ovpn_nl_post_doit() diff above.
>
> Yeah, I like the check in ovpn_peer_add_* too.
>
> >
> > > > Or we can call ovpn_peers_free on every NETDEV_UNREGISTER notification
> > > > that netdev_wait_allrefs_any sends us (but then we don't need it in
> > > > ndo_uninit).
> > >
> > > Hm, wouldn't we need a notification _after_ netdev_wait_allrefs_any() ?
> >
> > netdev_wait_allrefs_any() will never complete if we don't clean up all
> > the peers, since they hold a ref on the netdev.
> >
> > But calling ovpn_peers_free on netdev_wait_allrefs_any()'s
> >
> > /* Rebroadcast unregister notification */
> >
> > should clean up peers that got added while we were unregistering.
>
> But with the check in ovpn_peer_add_*, we don't need this extra call to
> ovpn_peers_free(), right?
Yes. This was an alternative idea for the same thing.
--
Sabrina
prev parent reply other threads:[~2026-03-26 9:13 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-20 10:03 [PATCH net 0/1] pull request: fixes for ovpn 2026-03-20 Antonio Quartulli
2026-03-20 10:03 ` [PATCH net 1/1] ovpn: fix race between deleting interface and adding new peer Antonio Quartulli
2026-03-24 1:43 ` Jakub Kicinski
2026-03-24 1:45 ` Jakub Kicinski
2026-03-24 10:09 ` Sabrina Dubroca
2026-03-24 21:30 ` Jakub Kicinski
2026-03-24 22:40 ` Sabrina Dubroca
2026-03-25 13:37 ` Antonio Quartulli
2026-03-26 9:13 ` Sabrina Dubroca [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=acT4o2VwsGk8o3jG@krikkit \
--to=sd@queasysnail.net \
--cc=andrew+netdev@lunn.ch \
--cc=antonio@openvpn.net \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=imv4bel@gmail.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.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