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=email

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 <[email protected]>
Found-By: ZeroPath (https://zeropath.com)

Change-Id: I51e0ffd54fef817894f35f51c7c57c8167cfbd6c
Signed-off-by: Gianmarco De Gregori <[email protected]>
---
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 = m->top.c2.fast_io
                                        ? (MPP_CONDITIONAL_PRE_SELECT | 
MPP_CLOSE_ON_SIGNAL)
                                        : (MPP_PRE_SELECT | 
MPP_CLOSE_ON_SIGNAL);
+    unsigned int processed_flags = 0;

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

@@ -381,11 +383,13 @@
     if (status & SOCKET_WRITE)
     {
         multi_process_outgoing_link(m, mpp_flags);
+        processed_flags |= SOCKET_WRITE;
     }
     /* TUN device ready to accept write */
     else if (status & TUN_WRITE)
     {
         multi_process_outgoing_tun(m, mpp_flags);
+        processed_flags |= 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 |= 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 |= TUN_READ;
     }
 #ifdef ENABLE_ASYNC_PUSH
     /* INOTIFY callback */
     else if (status & FILE_CLOSED)
     {
         multi_process_file_closed(m, mpp_flags);
+        processed_flags |= FILE_CLOSED;
     }
 #endif
 #if defined(ENABLE_DCO)
@@ -423,10 +430,11 @@
                 ret = multi_process_incoming_dco(m);
             }
         }
+        processed_flags |= DCO_READ;
     }
 #endif

-    m->multi_io->udp_flags = ES_ERROR;
+    m->multi_io->udp_flags &= ~processed_flags;
 }

 /*

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1347?usp=email
To unsubscribe, or for help writing mail filters, visit 
http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I51e0ffd54fef817894f35f51c7c57c8167cfbd6c
Gerrit-Change-Number: 1347
Gerrit-PatchSet: 1
Gerrit-Owner: its_Giaan <[email protected]>
Gerrit-Reviewer: flichtenheld <[email protected]>
Gerrit-Reviewer: plaisthos <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]>
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

Reply via email to