From: "its_Giaan (Code Review)" Date: Mon, 7 Jul 2025 12:57:02 +0000 References: Reply-To: gianmarco@...2726..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: <55bfa3dd6dfbbc01a29c8bb424751c64224056d8-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="2VJ9MFUKzQQ="; 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: plaisthos , flichtenheld Cc: openvpn-devel --2VJ9MFUKzQQ= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Attention is currently required from: flichtenheld, plaisthos. Hello plaisthos, flichtenheld, I'd like you to do a code review. Please visit http://gerrit.openvpn.net/c/openvpn/+/1078?usp=3Demail to review the following change. 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: #773 Change-Id: Iecbbcf32c0059f2b16a05333b3794599060d7d6a Signed-off-by: Gianmarco De Gregori --- M src/openvpn/mudp.c 1 file changed, 17 insertions(+), 9 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/78/1078/1 diff --git a/src/openvpn/mudp.c b/src/openvpn/mudp.c index 93e65e0..c47ed16 100644 --- a/src/openvpn/mudp.c +++ b/src/openvpn/mudp.c @@ -216,16 +216,24 @@ 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) + /* Ensure that clients from previous sessions do not attem= pt to + * hijack instances of newly connected clients in multi-pr= otocol scenarios */ + 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]; + + if (mi) + { + *floated =3D !link_socket_actual_match(&mi->contex= t.c2.from, &m->top.c2.from); + + if (*floated) + { + /* reset prefix, since here we are not sure pe= er is the one it claims to be */ + ungenerate_prefix(mi); + msg(D_MULTI_MEDIUM, "Float requested for peer = %" PRIu32 " 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: 1 Gerrit-Owner: its_Giaan Gerrit-Reviewer: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos Gerrit-Attention: flichtenheld Gerrit-MessageType: newchange --2VJ9MFUKzQQ= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is currently required from: flichtenheld, plaisthos.

its_Giaan would like plaisthos and flichtenheld to review this change.

V= iew Change

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 iss= ue occurred when a client reused a previously
assigned peer-id that was = now associated with a
different client using a different transport proto= col.

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 wh= ich is filled by the
recvfrom(), causing an assert to be triggered.
<= br>A protocol check has been added to prevent packets
from different pro= tocols from hijacking active
connections.

Github: #773

Cha= nge-Id: Iecbbcf32c0059f2b16a05333b3794599060d7d6a
Signed-off-by: Gianmar= co De Gregori <gianmarco@...2726...>
---
M src/openvpn/mudp.c1 file changed, 17 insertions(+), 9 deletions(-)

git pull ssh:=
//gerrit.openvpn.net:29418/openvpn refs/changes/78/1078/1
diff --=
git a/src/openvpn/mudp.c b/src/openvpn/mudp.c
index 93e65e0= ..c47ed16 100644
--- a/src/openvpn/mudp.c
+= ++ b/src/openvpn/mudp.c
@@ -216,16 +216,24 @@

if (!peer_id_disabled && (peer_id= < m->max_clients) && (m->instances[peer_id]))
<= span> {
- = mi =3D m->instances[peer_id];
-
- *floated =3D !link_socket_actual_match(&mi->cont= ext.c2.from, &m->top.c2.from);
-
- = if (*floated)
+ /* Ensure that clients from previous sessions do not a= ttempt to
+ = * hijack instances of newly connected clients in multi-protocol scen= arios */
+ = if (m->instances[peer_id]->context.c2.link_sockets[0]->info.p= roto =3D=3D sock->info.proto)
{<= br>- /* reset = prefix, since here we are not sure peer is the one it claims to be */
- ungener= ate_prefix(mi);
- = msg(D_MULTI_MEDIUM, "Float requested for peer %" PR= Iu32 " to %s", peer_id,
- mroute_addr_print(&real, &gc));=
+ = mi =3D m->instances[peer_id];
+
+ = if (mi)
+ *floated =3D !link_socket_actual_match(&mi= ->context.c2.from, &m->top.c2.from);
+
+ if (*floated)
+ {
+ /* reset pref= ix, since here we are not sure peer is the one it claims to be */+ u= ngenerate_prefix(mi);
+ msg(D_MULTI_MEDIUM, "Float requested for= peer %" PRIu32 " to %s", peer_id,
+ mroute_addr_p= rint(&real, &gc));
+ }
+ }
}
}
}

To view, visit change 1078. To unsubscribe, or for help writing m= ail filters, visit settings<= /a>.

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Iecbbcf32c0059f2b16a05333b37= 94599060d7d6a
Gerrit-Change-Number: 1078
Gerrit-PatchSet: 1
Gerrit-Owner: its_Giaan <gianmarco@...2786...= ..>
Gerrit-Reviewer: flichtenheld <frank@...2716...= 1...>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-Attention: plaisthos <arne-openvpn@...220...= ..1227...>
Gerrit-Attention: flichtenheld <frank@...2375...= 41...>
Gerrit-MessageType: newchange
--2VJ9MFUKzQQ=--