From: Antonio Quartulli <antonio@openvpn.net>
To: moonafterrain@outlook.com, Sabrina Dubroca <sd@queasysnail.net>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
Yuhao Jiang <danisjiang@gmail.com>,
stable@vger.kernel.org
Subject: Re: [PATCH net 2/2] ovpn: don't re-hash a removed peer on float
Date: Thu, 6 Aug 2026 11:51:07 +0200 [thread overview]
Message-ID: <96c13143-ada5-4a38-bf31-eb36e5828b43@openvpn.net> (raw)
In-Reply-To: <20260805-ovpn-fixes-v1-2-763f8c237fb9@outlook.com>
Hi Junrui,
On 05/08/2026 15:29, Junrui Luo via B4 Relay wrote:
> From: Junrui Luo <moonafterrain@outlook.com>
>
> ovpn_peer_endpoints_update() releases peer->lock before sending the
> float notification, then re-acquires ovpn->lock and peer->lock to move
> the peer to its new bucket in the by_transp_addr table. The only
> re-check in that second critical section is for a NULL bind, which
> cannot detect removal: bind is cleared by ovpn_peer_release() only
> after the refcount drops to zero, and the RX path holds a reference
> across the whole float.
>
> Both paths take ovpn->lock, but that only serialises them - it does
> not order them:
>
> CPU0 (RX softirq) CPU1
> ovpn_peer_endpoints_update()
> spin_unlock_bh(&peer->lock)
> ovpn_nl_peer_float_notify()
> ovpn_nl_peer_del_doit()
> ovpn_peer_remove() <- unlinks peer
> unlock_ovpn() <- drops last ref
> spin_lock_bh(&ovpn->lock)
> hlist_nulls_add_head_rcu() <- removed peer re-linked
>
> ovpn_peer_release_rcu() then frees the peer without unlinking it again,
> leaving a dangling node in by_transp_addr that every later datagram
> walks in ovpn_peer_get_by_transp_addr():
>
> BUG: KASAN: slab-use-after-free in ovpn_peer_endpoints_update+0xa5a/0x1010
> Write of size 8 at addr ffff888008576858 by task trigger/78
>
> Call Trace:
> ovpn_peer_endpoints_update+0xa5a/0x1010
> ovpn_decrypt_post+0x212/0x1040
> ovpn_recv+0x2b6/0x540
> ovpn_udp_encap_recv+0x21c/0x420
> udp_queue_rcv_one_skb+0x1060/0x11a0
> process_backlog+0x451/0x600
>
> Freed by task 0:
> kfree+0x11a/0x390
> rcu_core+0x7aa/0x1570
>
> Last potentially related work creation:
> call_rcu+0x82/0x720
> ovpn_peer_release_kref+0x5c/0xd0
> ovpn_nl_peer_del_doit+0x355/0x550
>
> Fix it by extending the existing early return to also bail out when the
> peer is no longer hashed by ID. hash_entry_id is unhashed with
> hlist_del_init_rcu() by ovpn_peer_remove() under ovpn->lock, which the
> float path holds across both the check and the rehash, so a peer that
> passes the test cannot be removed before it is re-linked.
>
> Fixes: f0281c1d3732 ("ovpn: add support for updating local or remote UDP endpoint")
> Reported-by: Yuhao Jiang <danisjiang@gmail.com>
> Assisted-by: Claude:claude-opus-5
> Cc: stable@vger.kernel.org
> Signed-off-by: Junrui Luo <moonafterrain@outlook.com>
A fix for this issue was recently merged to net:
commit 33ec10567fe14456063daf549fdf1a4f53448e4c
Author: Antonio Quartulli <antonio@openvpn.net>
Date: Tue Jul 28 13:48:47 2026 +0200
ovpn: skip rehash for peers already removed from by_id
Probably you came up with this fix on an older codebase.
I suggest two things:
1) always check the openvpn-devel mailing list and our patchwork
instance for already submitted patches that are waiting review (or that
are queued for sending to net/net-next)
2) make sure to always pull the latest tree patches are based on (net or
net-next) before sending them over.
In this period of hectic AI works things are moving exceptionally fast
(well, not always :))
Thanks a lot anyway for looking after our code!
Best Regards,
--
Antonio Quartulli
OpenVPN Inc.
next prev parent reply other threads:[~2026-08-06 9:51 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-05 13:29 [PATCH net 0/2] ovpn: fix peer float use-after-free and key slot NULL deref Junrui Luo via B4 Relay
2026-08-05 13:29 ` [PATCH net 1/2] ovpn: don't deref NULL key slot in ovpn_crypto_kill_key() Junrui Luo via B4 Relay
2026-08-06 9:43 ` Antonio Quartulli
2026-08-05 13:29 ` [PATCH net 2/2] ovpn: don't re-hash a removed peer on float Junrui Luo via B4 Relay
2026-08-06 9:51 ` Antonio Quartulli [this message]
2026-08-08 6:17 ` Junrui Luo
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=96c13143-ada5-4a38-bf31-eb36e5828b43@openvpn.net \
--to=antonio@openvpn.net \
--cc=andrew+netdev@lunn.ch \
--cc=danisjiang@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=moonafterrain@outlook.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sd@queasysnail.net \
--cc=stable@vger.kernel.org \
/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