From: "its_Giaan (Code Review)" Date: Tue, 11 Nov 2025 11:55:23 +0000 References: Reply-To: gianmarco@...2726..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: <0a4cad9665cdc89fd989021146eb9e734ad8e215-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="4PfCejbm2Bc="; charset=UTF-8 Subject: [Openvpn-devel] [XS] Change in openvpn[master]: mudp: fix handling of multiple UDP socket flags List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: plaisthos , flichtenheld Cc: openvpn-devel --4PfCejbm2Bc= 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/+/1365?usp=3Demail to review the following change. Change subject: mudp: fix handling of multiple UDP socket flags ...................................................................... mudp: fix handling of multiple UDP socket flags The handler previously used an 'else-if' chain to process only the first matching flag, and then overwrote 'm->multi_io->udp_flags' with a fixed value (e.g. 'ES_ERROR'). This caused remaining event bits to be ignored if multiple flags (such as SOCKET_READ and SOCKET_WRITE) were set simultaneously. This patch changes the logic to test each flag independently and clear only the bits that were actually handled. Reported-by: Joshua Rogers Found-by: ZeroPath (https://zeropath.com) Change-Id: I509ea79990305f39e3385136fc0d9e5fbfa68e6c Signed-off-by: Gianmarco De Gregori --- M src/openvpn/mudp.c 1 file changed, 4 insertions(+), 1 deletion(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/65/1365/1 diff --git a/src/openvpn/mudp.c b/src/openvpn/mudp.c index 71c742f..1f3594a 100644 --- a/src/openvpn/mudp.c +++ b/src/openvpn/mudp.c @@ -342,6 +342,7 @@ const unsigned int mpp_flags =3D m->top.c2.fast_io ? (MPP_CONDITIONAL_PRE_SELECT | MPP= _CLOSE_ON_SIGNAL) : (MPP_PRE_SELECT | MPP_CLOSE_ON_SI= GNAL); + unsigned int processed_flags =3D 0; #ifdef MULTI_DEBUG_EVENT_LOOP char buf[16]; @@ -361,6 +362,7 @@ if (status & SOCKET_WRITE) { multi_process_outgoing_link(m, mpp_flags); + processed_flags |=3D SOCKET_WRITE; } /* Incoming data on UDP port */ else if (status & SOCKET_READ) @@ -370,9 +372,10 @@ { multi_process_incoming_link(m, NULL, mpp_flags, sock); } + processed_flags |=3D SOCKET_READ; } - m->multi_io->udp_flags =3D ES_ERROR; + m->multi_io->udp_flags &=3D ~processed_flags; } /* -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1365?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings?usp=3Demail Gerrit-MessageType: newchange Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: I509ea79990305f39e3385136fc0d9e5fbfa68e6c Gerrit-Change-Number: 1365 Gerrit-PatchSet: 1 Gerrit-Owner: its_Giaan Gerrit-Reviewer: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos Gerrit-Attention: flichtenheld --4PfCejbm2Bc= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is cur= rently required from: flichtenheld, plaisthos.

its_Giaan would like plaisthos and flichtenheld to review this change.

V= iew Change

mudp: fix handling of multiple UDP socket f=
lags

The handler previously used an 'else-if' chain to proce= ss
only the first matching flag, and then overwrote
'm->multi_= io->udp_flags' with a fixed value (e.g. 'ES_ERROR').
This= caused remaining event bits to be ignored if multiple
flags (such as SO= CKET_READ and SOCKET_WRITE) were set
simultaneously.

This patch c= hanges the logic to test each flag independently
and clear only the bits= that were actually handled.

Reported-by: Joshua Rogers <contact@= ...2949...>
Found-by: ZeroPath (https://zeropath.com)

Change-I= d: I509ea79990305f39e3385136fc0d9e5fbfa68e6c
Signed-off-by: Gianmarco De= Gregori <gianmarco@...2726...>
---
M src/openvpn/mudp.c
1 f= ile changed, 4 insertions(+), 1 deletion(-)

git =
pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/65/1365/1
= diff --git a/src/openvpn/mudp.c b/src/openvpn/mudp.c
index = 71c742f..1f3594a 100644
--- a/src/openvpn/mudp.c
= +++ b/src/openvpn/mudp.c
@@ -342,6 +342,7 @@ const unsigned int mpp_flags =3D m->top.c2.fast_io ? (MPP_CONDITIONAL_PRE_SELE= CT | MPP_CLOSE_ON_SIGNAL)
= : (MPP_PRE_SELECT | MPP_CLOSE_ON_SIGNAL);
+ unsigned int processed_flags =3D 0;=

#ifdef MULTI_DEBUG_EVENT_LOOP
= char buf[16];
@@ -361,6 +362,7 @@
= if (status & SOCKET_WRITE)
{
= multi_process_outgoing_link(m, mpp_flags);
+ processed_flags |=3D SOCKET_WRITE;
}
/* Incoming data on UDP port */
else if (status & SOCKET_READ)
@@ -37= 0,9 +372,10 @@
{
mult= i_process_incoming_link(m, NULL, mpp_flags, sock);
= }
+ processed= _flags |=3D SOCKET_READ;
}
- m->multi_io->udp_flag= s =3D ES_ERROR;
+ = m->multi_io->udp_flags &=3D ~processed_flags;
}<= /span>

/*

T= o view, visit change 1365. To unsubscribe, or for help writing mail filters, vi= sit settings= .

Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I509ea79990305f39e3385136fc0= d9e5fbfa68e6c
Gerrit-Change-Number: 1365
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...>
= --4PfCejbm2Bc=--