From: "cron2 (Code Review)" Date: Fri, 18 Jul 2025 19:07:25 +0000 In-Reply-To: References: Reply-To: gert@...1296..., arne-openvpn@...1227..., gianmarco@...2726..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: <8ef61666058cb1204cdb6e75bd4ee40b62013f8c-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="VDJTc+ZPRZQ="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: Multi-socket: Fix assert triggered by stale peer-id reuse List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: its_Giaan Cc: plaisthos , flichtenheld , openvpn-devel --VDJTc+ZPRZQ= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/10= 78?usp=3Demail ) Change subject: Multi-socket: Fix assert triggered by stale peer-id reuse ...................................................................... Multi-socket: Fix assert triggered by stale peer-id reuse Fixed a bug where clients using different transport protocols (UDP, TCP) could interfere with each other after a server restart. The issue occurred when a client reused a previously assigned peer-id that was now associated with a different client using a different transport protocol. For example, a UDP client could send packets with a peer-id now assigned to a TCP client, which lacks a valid context->c2.from which is filled by the recvfrom(), causing an assert to be triggered. A protocol check has been added to prevent packets from different protocols from hijacking active connections. Github: OpenVPN/openvpn#773 Change-Id: Iecbbcf32c0059f2b16a05333b3794599060d7d6a Signed-off-by: Gianmarco De Gregori Acked-by: Gert Doering Message-Id: <20250718185559.4515-1-gert@...1296...> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg32= 220.html Signed-off-by: Gert Doering --- M src/openvpn/mudp.c 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/openvpn/mudp.c b/src/openvpn/mudp.c index 93e65e0..ee8446a 100644 --- a/src/openvpn/mudp.c +++ b/src/openvpn/mudp.c @@ -216,16 +216,20 @@ if (!peer_id_disabled && (peer_id < m->max_clients) && (m->ins= tances[peer_id])) { - mi =3D m->instances[peer_id]; - - *floated =3D !link_socket_actual_match(&mi->context.c2.fro= m, &m->top.c2.from); - - if (*floated) + /* Floating on TCP will never be possible, so ensure we on= ly process + * UDP clients */ + if (m->instances[peer_id]->context.c2.link_sockets[0]->inf= o.proto =3D=3D sock->info.proto) { - /* reset prefix, since here we are not sure peer is th= e one it claims to be */ - ungenerate_prefix(mi); - msg(D_MULTI_MEDIUM, "Float requested for peer %" PRIu3= 2 " to %s", peer_id, - mroute_addr_print(&real, &gc)); + mi =3D m->instances[peer_id]; + *floated =3D !link_socket_actual_match(&mi->context.c2= .from, &m->top.c2.from); + + if (*floated) + { + /* reset prefix, since here we are not sure peer i= s the one it claims to be */ + ungenerate_prefix(mi); + msg(D_MULTI_MEDIUM, "Float requested for peer %" P= RIu32 " to %s", peer_id, + mroute_addr_print(&real, &gc)); + } } } } -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1078?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: Iecbbcf32c0059f2b16a05333b3794599060d7d6a Gerrit-Change-Number: 1078 Gerrit-PatchSet: 4 Gerrit-Owner: its_Giaan Gerrit-Reviewer: cron2 Gerrit-Reviewer: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-MessageType: merged --VDJTc+ZPRZQ= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

cron2 submitted this change.

View Change

Multi-socket: Fix assert triggered by stale p=
eer-id reuse

Fixed a bug where clients using different transport
= protocols (UDP, TCP) could interfere with each other
after a server rest= art.
The issue occurred when a client reused a previously
assigned pe= er-id that was now associated with a
different client using a different = transport protocol.

For example, a UDP client could send packets wit= h a
peer-id now assigned to a TCP client, which lacks
a valid context= ->c2.from which is filled by the
recvfrom(), causing an assert to be = triggered.

A protocol check has been added to prevent packets
fro= m different protocols from hijacking active
connections.

Github: = OpenVPN/openvpn#773

Change-Id: Iecbbcf32c0059f2b16a05333b3794599060d= 7d6a
Signed-off-by: Gianmarco De Gregori <gianmarco@...2726...>Acked-by: Gert Doering <gert@...1296...>
Message-Id: <20250718= 185559.4515-1-gert@...1296...>
URL: https://www.mail-archive.com/open= vpn-devel@lists.sourceforge.net/msg32220.html
Signed-off-by: Gert Doerin= g <gert@...1296...>
---
M src/openvpn/mudp.c
1 file changed,= 13 insertions(+), 9 deletions(-)

diff --git a/src/openvpn/mudp.c b/src/openvpn/mudp.c
ind= ex 93e65e0..ee8446a 100644
--- a/src/openvpn/mudp.c<= br>+++ b/src/openvpn/mudp.c
@@ -216,16 +216,20 @@


if (!peer_id_disabled &&= ; (peer_id < m->max_clients) && (m->instances[peer_id]))
{
- mi =3D m->instances[peer_id];
-
- *floated =3D !link_socket_actual_match(&m= i->context.c2.from, &m->top.c2.from);
-
- if (*floated)
+ /* Floating on TCP will never be possible, s= o ensure we only process
+ * UDP clients */
+ if (m->instances[peer_id]->context= .c2.link_sockets[0]->info.proto =3D=3D sock->info.proto)
{

= - /* reset prefix, since here we are not sure peer is th= e one it claims to be */
- msg(D_MULTI_MEDIUM, "Float= requested for peer %" PRIu32 " to %s", peer_id,
<= span style=3D"color: hsl(0, 100%, 40%);">- mroute_ad= dr_print(&real, &gc));
+ mi =3D m->instances[peer_id];
<= span style=3D"color: hsl(120, 100%, 40%);">+ *floated = =3D !link_socket_actual_match(&mi->context.c2.from, &m->top.c= 2.from);
+
= + if (*float= ed)
+ = {
+ = /* reset prefix, since here we are not sure peer is the one it cl= aims to be */
+ = ungenerate_prefix(mi);
+ msg(D_MULTI_MEDIUM, "Floa= t requested for peer %" PRIu32 " to %s", peer_id,
= + mr= oute_addr_print(&real, &gc));
+ }
}<= /span>
}
}
<= /span>

To view, visit change 1078. To unsubscribe, or for help writ= ing mail filters, visit sett= ings.

<= link itemprop=3D"url" href=3D"http://gerrit.openvpn.net/c/openvpn/+/1078?us= p=3Demail"/>
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Iecbbcf32c0059f2b16a05333b37= 94599060d7d6a
Gerrit-Change-Number: 1078
Gerrit-PatchSet: 4
Gerrit-Owner: its_Giaan <gianmarco@...2786...= ..>
Gerrit-Reviewer: cron2 <gert@...1296...>=
Gerrit-Reviewer: flichtenheld <frank@...2716...= 1...>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-MessageType: merged
--VDJTc+ZPRZQ=--