Attention is currently required from: Arne Schwabe.

Hello Arne Schwabe,

I'd like you to do a code review.
Please visit

    https://gerrit.openvpn.net/c/openvpn/+/2032?usp=email

to review the following change.


Change subject: multi: release the session-id hash reference on shutdown
......................................................................

multi: release the session-id hash reference on shutdown

multi_hash_sid_add() takes a reference on the multi_instance, but
multi_close_instance() only drops it via multi_hash_sid_remove() when
not shutting down. On shutdown hash_free() then frees the table without
releasing the reference, so every instance still connected when the
server stops is leaked (reported by LeakSanitizer, which also turns the
exit code into 1).

Remove the instance from the session-id hash regardless of shutdown.
Unlike the other tables handled in that block, this one holds a
reference.

Fixes: 66f8cdb9 ("Add lookup of multi session by session id")
Change-Id: I62d95dad21891351a16cd6be43063406a024acee
Signed-off-by: Antonio Quartulli <[email protected]>
---
M src/openvpn/multi.c
1 file changed, 7 insertions(+), 6 deletions(-)



  git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/32/2032/1

diff --git a/src/openvpn/multi.c b/src/openvpn/multi.c
index e302a81..813b79c 100644
--- a/src/openvpn/multi.c
+++ b/src/openvpn/multi.c
@@ -584,6 +584,13 @@
         m->earliest_wakeup = NULL;
     }

+    /* The sid hash holds a reference on the instance: drop it on shutdown
+     * too, otherwise the instance is never freed */
+    if (session_id_defined(&mi->sid_hashed_value))
+    {
+        multi_hash_sid_remove(m, &mi->sid_hashed_value);
+    }
+
     if (!shutdown)
     {
         if (mi->did_real_hash)
@@ -605,12 +612,6 @@
         }
 #endif

-
-        if (session_id_defined(&mi->sid_hashed_value))
-        {
-            multi_hash_sid_remove(m, &mi->sid_hashed_value);
-        }
-
         if (mi->context.c2.tls_multi->rx_peer_id != MAX_PEER_ID)
         {
             m->instances[mi->context.c2.tls_multi->rx_peer_id] = NULL;

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

Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I62d95dad21891351a16cd6be43063406a024acee
Gerrit-Change-Number: 2032
Gerrit-PatchSet: 1
Gerrit-Owner: Antonio Quartulli <[email protected]>
Gerrit-Reviewer: Arne Schwabe <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: Arne Schwabe <[email protected]>
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

Reply via email to