Attention is currently required from: plaisthos.

Hello plaisthos,

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

    http://gerrit.openvpn.net/c/openvpn/+/1795?usp=email

to review the following change.


Change subject: dco.c: make key state desync recoverable
......................................................................

dco.c: make key state desync recoverable

If installing a DCO key succeeds, always record the slot in the
corresponding key_state. The installed-key counter only tracks whether
the number of kernel slots grew, but a successful KEY_NEW still means
that this key_state is associated with the selected DCO slot.

Also replace the assertion in dco_update_keys() with an error return
when the selected primary key is not marked as installed in DCO. This
preserves the invariant check but lets the existing caller restart the
connection instead of aborting the process.

Github: https://github.com/OpenVPN/openvpn-private-issues/issues/143
Change-Id: I4d0887839b4a13a92e92250d1b315dec949698f3
Signed-off-by: Ralf Lici <[email protected]>
---
M src/openvpn/dco.c
1 file changed, 11 insertions(+), 3 deletions(-)



  git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/95/1795/1

diff --git a/src/openvpn/dco.c b/src/openvpn/dco.c
index e944547..6f158e3 100644
--- a/src/openvpn/dco.c
+++ b/src/openvpn/dco.c
@@ -73,9 +73,12 @@

     int ret = dco_new_key(multi->dco, multi->dco_peer_id, ks->key_id, slot, 
encrypt_key, encrypt_iv,
                           decrypt_key, decrypt_iv, ciphername, epoch);
-    if ((ret == 0) && (multi->dco_keys_installed < 2))
+    if (ret == 0)
     {
-        multi->dco_keys_installed++;
+        if (multi->dco_keys_installed < 2)
+        {
+            multi->dco_keys_installed++;
+        }
         ks->dco_status =
             (slot == OVPN_KEY_SLOT_PRIMARY) ? DCO_INSTALLED_PRIMARY : 
DCO_INSTALLED_SECONDARY;
     }
@@ -166,7 +169,12 @@
     /* if we have a primary key, it must have been installed already (keys
      * are installed upon generation in the TLS code)
      */
-    ASSERT(primary->dco_status != DCO_NOT_INSTALLED);
+    if (primary->dco_status == DCO_NOT_INSTALLED)
+    {
+        msg(D_DCO, "DCO key state mismatch: selected primary key is not 
installed (peer_id=%d, key_id=%d, dco_keys_installed=%d)",
+            multi->dco_peer_id, primary->key_id, multi->dco_keys_installed);
+        return false;
+    }

     struct key_state *secondary = dco_get_secondary_key(multi, primary);
     /* if the current primary key was installed as secondary in DCO,

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1795?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: I4d0887839b4a13a92e92250d1b315dec949698f3
Gerrit-Change-Number: 1795
Gerrit-PatchSet: 1
Gerrit-Owner: ralf_lici <[email protected]>
Gerrit-Reviewer: plaisthos <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]>
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

Reply via email to