From: "its_Giaan (Code Review)" Date: Tue, 4 Nov 2025 15:55:49 +0000 References: Reply-To: gianmarco@...2726..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: <423c5df78824a5a355790f932f24193a2f3abff9-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="uhC3iqTk/1U="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: mudp: fix handling of multiple UDP event flags List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: plaisthos , flichtenheld Cc: openvpn-devel --uhC3iqTk/1U= 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/+/1347?usp=3Demail to review the following change. Change subject: mudp: fix handling of multiple UDP event flags ...................................................................... mudp: fix handling of multiple UDP event flags The handler previously used an 'else-if' chain to process only the first matching UDP event 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 or 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: I51e0ffd54fef817894f35f51c7c57c8167cfbd6c Signed-off-by: Gianmarco De Gregori --- M src/openvpn/mudp.c 1 file changed, 9 insertions(+), 1 deletion(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/47/1347/1 diff --git a/src/openvpn/mudp.c b/src/openvpn/mudp.c index 31134be..6edefac 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]; @@ -374,6 +375,7 @@ { ASSERT(management); management_io(management); + processed_flags |=3D (MANAGEMENT_READ | MANAGEMENT_WRITE); } #endif @@ -381,11 +383,13 @@ if (status & SOCKET_WRITE) { multi_process_outgoing_link(m, mpp_flags); + processed_flags |=3D SOCKET_WRITE; } /* TUN device ready to accept write */ else if (status & TUN_WRITE) { multi_process_outgoing_tun(m, mpp_flags); + processed_flags |=3D TUN_WRITE; } /* Incoming data on UDP port */ else if (status & SOCKET_READ) @@ -395,6 +399,7 @@ { multi_process_incoming_link(m, NULL, mpp_flags, sock); } + processed_flags |=3D SOCKET_READ; } /* Incoming data on TUN device */ else if (status & TUN_READ) @@ -404,12 +409,14 @@ { multi_process_incoming_tun(m, mpp_flags); } + processed_flags |=3D TUN_READ; } #ifdef ENABLE_ASYNC_PUSH /* INOTIFY callback */ else if (status & FILE_CLOSED) { multi_process_file_closed(m, mpp_flags); + processed_flags |=3D FILE_CLOSED; } #endif #if defined(ENABLE_DCO) @@ -423,10 +430,11 @@ ret =3D multi_process_incoming_dco(m); } } + processed_flags |=3D DCO_READ; } #endif - 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/+/1347?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: I51e0ffd54fef817894f35f51c7c57c8167cfbd6c Gerrit-Change-Number: 1347 Gerrit-PatchSet: 1 Gerrit-Owner: its_Giaan Gerrit-Reviewer: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos Gerrit-Attention: flichtenheld --uhC3iqTk/1U= 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 event fl=
ags

The handler previously used an 'else-if' chain to proces= s
only the first matching UDP event flag, and then overwrote
'm-&= gt;multi_io->udp_flags' with a fixed value (e.g. 'ES_ERROR')= .
This caused remaining event bits to be ignored if multiple
flags (s= uch as SOCKET_READ or 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 <= contact@...2949...>
Found-By: ZeroPath (https://zeropath.com)

= Change-Id: I51e0ffd54fef817894f35f51c7c57c8167cfbd6c
Signed-off-by: Gian= marco De Gregori <gianmarco@...2726...>
---
M src/openvpn/mudp.= c
1 file changed, 9 insertions(+), 1 deletion(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/47/1347/1<=
/pre>
+    unsigned int processed_flags =3D 0=
;

#ifdef MULTI_DEBUG_EVENT_LOOP char buf[16];
@@ -374,6 +375,7 @@
{
ASSERT(management);
= management_io(management);
+ processed_flags |=3D (MANAGEMENT_READ | MANAGEMENT_WRI= TE);
}
#endif

@@ -381,11 +383,13 @@
if (status & SOCK= ET_WRITE)
{
multi_process_out= going_link(m, mpp_flags);
+ processed_flags |=3D SOCKET_WRITE;
}
/* TUN device ready to accept write */
= else if (status & TUN_WRITE)
{
= multi_process_outgoing_tun(m, mpp_flags);
+ processed_flags |=3D TUN_WRITE;
}
/* Incoming data on UDP port */
else if (status & SOCKET_READ)
@@ -39= 5,6 +399,7 @@
{
multi= _process_incoming_link(m, NULL, mpp_flags, sock);
= }
+ processed_= flags |=3D SOCKET_READ;
}
/* Inco= ming data on TUN device */
else if (status & TUN_R= EAD)
@@ -404,12 +409,14 @@
{
multi_process_incoming_tun(m, mpp_flags); }
+ = processed_flags |=3D TUN_READ;
}
#ifdef ENABLE_ASYNC_PUSH

/* INOTIFY callback */
else if (status & FILE_CLOSED)
{<= /span>
multi_process_file_closed(m, mpp_flags);+ processed_flags |=3D = FILE_CLOSED;
}
#endif
#if defined(ENABLE_DCO)

@@ -423,10 +430,11 @@
<= span> ret =3D multi_process_incoming_dco(m);

}

}
+ processed_flags |=3D DCO_READ;
}

#endif

- m->multi_io->udp_flags =3D ES_ERR= OR;
+ m->multi_= io->udp_flags &=3D ~processed_flags;
}

/*

To view, visi= t change= 1347. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I51e0ffd54fef817894f35f51c7c= 57c8167cfbd6c
Gerrit-Change-Number: 1347
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...>
= --uhC3iqTk/1U=--