From patchwork Thu Nov 26 14:45:09 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ralf Lici X-Patchwork-Id: 5797 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:6022:91c9:10b0:11b:d6c:f273 with SMTP id tl9-n1csp7290290lad; Thu, 26 Nov 2026 06:45:40 -0800 (PST) X-Forwarded-Encrypted: i=2; AL+hErHa74wfvKYRZJ3NjxN/GTsaaequwBLw5Te1DEV/VUKkCnch3SaLi7Ygu01sCv0+T/oFiPTVEZLvobk=@openvpn.net X-Received: by 2002:a05:6a21:6b85:b0:40a:4b8e:b7f7 with SMTP id adf61e73a8af0-40a4b8ec379mr1559022637.45.1795704339631; Thu, 26 Nov 2026 06:45:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1795704339; cv=none; d=google.com; s=arc-20260327; b=WWZNjjULUNKpOjZ6EBh9AY3Js67O3Lgbr/EXytsDM/9wvrp0cnUrZm8DbqD5uBF1jB KUCNs8rIRy4wxUq7gSeWmCXBACwa6oJumlFRY2l60pHjtETsuogQwkCTW+q0JVgRb4QA GPA7M+/gfsWFDWq71DF97pJ1UgX1k8bRobDYCJ/Ac7ElC+98+MDLpZHivHId51HH6rs6 0cQqplljxEyHTw1XWc1gi05+asROIIrRLk7wp7MryIhU6QkoKSeAL2DQb7Vk6husVADs xaJMesoo5TJtX+YB7QhsUoARFd/sfQ4RBQfEB8ib8Yx6DprqPI/kjS6TtcyuYqM0P8qc oddA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=errors-to:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :dkim-signature:dkim-signature:dkim-signature:dkim-signature; bh=br2RjapdmEXmxhQCw3VkiZ+zkBDmULz9fphJkXCReug=; fh=4NbAC/LsuMLI0S0hprUlLSLCiHwg6SCAifhH718Jh0Q=; b=F9JC5B8j4IocAeBWLLL+SvBPWIZMpNBM1S7Gi5rFIhIeHhC5RGEwdFMuFBzn1xG2wq kJZhP80XT6wrFtNZgyI4Ql6NK0+qGkXRUKCoprh15iN1I75MVgI5rwdjCDNqPUngwUXb X9at2w4QgcyPdBu99Akkg1gmOQ9rPkG8LK8cNInN4qkC9or2doTSmJ1DvlhA/bw0zgov GI6hnF/iWbpCxst36ugADIcWj9mAoXAzD9vGaZDGagT1i4MtkER3emnKujhS2b/Y3x9O fwNavr1H1lPCNoDZBUVur1R0EvCFus5Ci1swCAH485j66nIIAwk7IG3NYbIVktqNELHo e3eA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b=hoeSxCc4; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=W+OZguz5; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=TBADoS1x; dkim=neutral (body hash did not verify) header.i=@mandelbit.com header.s=MBO0001 header.b=NDgZMXNW; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7]) by mx.google.com with ESMTPS id 41be03b00d2f7-cde6d0125c7si31294384a12.109.2026.11.26.06.45.39 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 26 Nov 2026 06:45:39 -0800 (PST) Received-SPF: pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) client-ip=216.105.38.7; Authentication-Results: mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b=hoeSxCc4; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=W+OZguz5; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=TBADoS1x; dkim=neutral (body hash did not verify) header.i=@mandelbit.com header.s=MBO0001 header.b=NDgZMXNW; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.sourceforge.net; s=beta; h=Content-Transfer-Encoding:Content-Type: List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: Subject:MIME-Version:References:In-Reply-To:Message-ID:Date:To:From:Sender: Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Unsubscribe-Post: List-Owner; bh=br2RjapdmEXmxhQCw3VkiZ+zkBDmULz9fphJkXCReug=; b=hoeSxCc4iixcK8 5PxK6QEZ1mVwLow7nnCDX0OCs/LXI114hzAN288aLW8mbEviMxdvh9ZcSeS3AU5Gi/+d+3aa4hrEH Pu9m90kb2ZShWfTLfqLXJuGaHrCjHgbmvr1vnfHNqZHOwAp/9omb43SAPmFulEk1+DYMnOMAaWSZX SnE=; Received: from [127.0.0.1] (helo=sfs-ml-2.v29.lw.sourceforge.com) by sfs-ml-2.v29.lw.sourceforge.com with esmtp (Exim 4.100.1) (envelope-from ) id 1xWajC-000000004tW-1d3C; Thu, 26 Nov 2026 14:45:38 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.100.1) (envelope-from ) id 1xWajA-000000004tE-09Ez for openvpn-devel@lists.sourceforge.net; Thu, 26 Nov 2026 14:45:36 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Unsubscribe-Post:List-Subscribe:List-Post:List-Owner:List-Archive; bh=0GiUkp4sKBvffAbm8LzEKrsFioHGHb8CGIcLMPYDKc0=; b=W+OZguz56R1gyTIUF7XkNjv5i3 YvCHjo0FK/fMl1Od6gntyYFlb1X+jrLy2rvxAzOvuyEoJb7WoNqg5CxIAZeGxZZdhiiboxOWThExh Ke5YlSQb8gDj69QVS9W6PLNIiFyQLTHzAvLY3Ob9cDnu0NMELufdI9nl8/iimZDa6OfI=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID: Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Unsubscribe-Post: List-Subscribe:List-Post:List-Owner:List-Archive; bh=0GiUkp4sKBvffAbm8LzEKrsFioHGHb8CGIcLMPYDKc0=; b=TBADoS1xLR0zHr1Z2FtORUge2o FALjbAJB0JLjAJPZe+nlfqgh18meOBu4/KyRDGeFj2wzATayaIrED9JUe72iQcmPb+dTWroERnPMH u/5A9YLOZEg9gglibTAVsyJUn5j1/tD13xmgmvAbOcV2c7CCYRDUiTT786vXIgc83hvE=; Received: from mout-b-105.mailbox.org ([195.10.208.50]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.100.1) id 1xWaj8-000000001wm-1TAX for openvpn-devel@lists.sourceforge.net; Thu, 26 Nov 2026 14:45:35 +0000 Received: from smtp1.mailbox.org (smtp1.mailbox.org [IPv6:2001:67c:2050:b231:465::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519MLKEM768 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-b-105.mailbox.org (Postfix) with ESMTPS id 4jZzqR0FRmz9sKM for ; Thu, 26 Nov 2026 15:45:23 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandelbit.com; s=MBO0001; t=1795704323; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0GiUkp4sKBvffAbm8LzEKrsFioHGHb8CGIcLMPYDKc0=; b=NDgZMXNWeG8/lnysR0JzR1Dgn/T3pQPKCdm92GHI8i9bTIDKN4M+8Ss8snnxz2q+sKcBTI xbMq0QchH6IjKh36pa7Zr8knN6SldEfOJGoHYHJRO5JHoJy+xvPIJLXLUnE/fTdxv4nwL4 ZYG4PhgHZ7hP0KE2w8uWDRFtMnoEoV+53+KapctXsooUZ/N/eWLJQymmDizDPI5I8kX3b1 KXlSwE8XSICtr/0NR3tgI3qNbQf0DjC08W4i/g596noeYfteAtKvEdQx9G7ELh2MNOeRUw WI4R4kHUS+HbPZ32LKP8U0pCbh94A8DrffZfwQ1OsPX7uEnsk4p+Jy2vnfmAjw== Authentication-Results: outgoing_mbo_mout; dkim=none; spf=pass (outgoing_mbo_mout: domain of ralf@mandelbit.com designates 2001:67c:2050:b231:465::1 as permitted sender) smtp.mailfrom=ralf@mandelbit.com From: Ralf Lici To: openvpn-devel@lists.sourceforge.net Date: Thu, 26 Nov 2026 15:45:09 +0100 Message-ID: X-Mailer: git-send-email 2.56.0 In-Reply-To: References: MIME-Version: 1.0 X-Rspamd-Queue-Id: 4jZzqR0FRmz9sKM X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "sfi-spamd-2.hosts.colo.sdot.me", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: When the peer endpoint changes, the new bind is published with RCU before the dst cache is reset. TX does not take peer->lock before the cache lookup, so a concurrent transmitter can pick up the new b [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-Headers-End: 1xWaj8-000000001wm-1TAX Subject: [Openvpn-devel] [PATCH ovpn net 1/3] ovpn: reset dst cache before publishing a new bind X-BeenThere: openvpn-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox X-GMAIL-THRID: 1882932473788647309 X-GMAIL-MSGID: 1882932473788647309 When the peer endpoint changes, the new bind is published with RCU before the dst cache is reset. TX does not take peer->lock before the cache lookup, so a concurrent transmitter can pick up the new bind and still get a hit on the entry cached for the old one. The packet then goes out over the old route and cached source address but towards the new remote. On a cross-family float, dst_cache_get_ip4 or dst_cache_get_ip6 would also return a dst of the wrong family, which is then passed to the other family's xmit helper. Reset the cache before publishing the new bind, both when the endpoint is updated from RX and when it is changed via netlink. Both run under peer->lock, which a TX must hold to store a new dst, and the store requires the bind to still be the current one. Therefore, once the new bind is visible no stale entry can be repopulated. A failed bind update at worst costs one extra cache miss. Fixes: aea934a221ec ("ovpn: replace bind when learning local endpoint") Fixes: 1d36a36f6d53 ("ovpn: implement peer add/get/dump/delete via netlink") Link: https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260921102215.3599702-1-antonio%40openvpn.net?part=5 Signed-off-by: Ralf Lici --- drivers/net/ovpn/netlink.c | 7 ++++++- drivers/net/ovpn/peer.c | 10 +++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/drivers/net/ovpn/netlink.c b/drivers/net/ovpn/netlink.c index 5432bc2eb8e8..6231d87304e1 100644 --- a/drivers/net/ovpn/netlink.c +++ b/drivers/net/ovpn/netlink.c @@ -333,6 +333,12 @@ static int ovpn_nl_peer_modify(struct ovpn_peer *peer, struct genl_info *info, */ local_ip = ovpn_nl_attr_local_ip(attrs); + /* reset the cache before publishing the new bind, so that + * concurrent TX cannot pair it with a route cached for the + * old one + */ + dst_cache_reset(&peer->dst_cache); + /* set peer sockaddr */ ret = ovpn_peer_reset_sockaddr(peer, &ss, local_ip); if (ret < 0) { @@ -341,7 +347,6 @@ static int ovpn_nl_peer_modify(struct ovpn_peer *peer, struct genl_info *info, ret); goto err_unlock; } - dst_cache_reset(&peer->dst_cache); } /* In a multipeer-to-multipeer setup we may have asymmetric peer IDs, diff --git a/drivers/net/ovpn/peer.c b/drivers/net/ovpn/peer.c index 2067825bb5b6..07f3fd9cbed6 100644 --- a/drivers/net/ovpn/peer.c +++ b/drivers/net/ovpn/peer.c @@ -294,16 +294,16 @@ void ovpn_peer_endpoints_update(struct ovpn_peer *peer, struct sk_buff *skb) goto unlock; } + /* reset the cache before publishing the new bind, so that concurrent TX + * cannot pair it with a route cached for the old one + */ + dst_cache_reset(&peer->dst_cache); + if (unlikely(ovpn_peer_reset_sockaddr(peer, (struct sockaddr_storage *)&ss, local_ip) < 0)) goto unlock; - /* reset the cache only after a successful bind update to avoid useless - * cache misses on concurrent TX - */ - dst_cache_reset(&peer->dst_cache); - /* if only the local address changed, bail out now */ if (!floated) goto unlock;