From: "mrbff (Code Review)" Date: Wed, 8 Oct 2025 11:31:05 +0000 References: Reply-To: marco@...2726..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: <4254e808dbc963f9e299b4fcf55676b42b70cc7f-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="ylcHf6i2ogs="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: PUSH_UPDATE server: check IV_PROTO before sending the message to the ... List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: plaisthos , flichtenheld Cc: openvpn-devel --ylcHf6i2ogs= 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/+/1255?usp=3Demail to review the following change. Change subject: PUSH_UPDATE server: check IV_PROTO before sending the messa= ge to the client ...................................................................... PUSH_UPDATE server: check IV_PROTO before sending the message to the client Before sending the PUSH_UPDATE message to the client, we must verify that the client has actually sent IV_PROTO_PUSH_UPDATE to the server, declaring = that it supports push-updates. Change-Id: I7c28da72be11c7efbed3068fbfc65f2959227bec Signed-off-by: Marco Baffo --- M src/openvpn/push_util.c M tests/unit_tests/openvpn/test_push_update_msg.c 2 files changed, 38 insertions(+), 2 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/55/1255/1 diff --git a/src/openvpn/push_util.c b/src/openvpn/push_util.c index f306104..5c8a9da 100644 --- a/src/openvpn/push_util.c +++ b/src/openvpn/push_util.c @@ -7,6 +7,7 @@ #ifdef ENABLE_MANAGEMENT #include "multi.h" +#include "ssl_util.h" #endif #if defined(__GNUC__) || defined(__clang__) @@ -188,6 +189,26 @@ return true; } +/* Return true if the client supports push-update */ +static bool +support_push_update(struct multi_instance *mi) +{ + if (!mi) + { + return false; + } + + const unsigned int iv_proto_peer =3D extract_iv_proto(mi->context.c2.t= ls_multi->peer_info); + if (!(iv_proto_peer & IV_PROTO_PUSH_UPDATE)) + { + msg(M_CLIENT, "ERROR: Peer ID: %u does not support push-update", + mi->context.c2.tls_multi ? mi->context.c2.tls_multi->peer_id := UINT32_MAX); + return false; + } + + return true; +} + int send_push_update(struct multi_context *m, const void *target, const char *= msg, const push_update_type type, const int push_bundle_size) { @@ -228,9 +249,16 @@ if (!mi) { + gc_free(&gc); return -ENOENT; } + if (!support_push_update(mi)) + { + gc_free(&gc); + return 0; + } + const char *old_ip =3D mi->context.options.ifconfig_local; const char *old_ipv6 =3D mi->context.options.ifconfig_ipv6_local; if (!mi->halt @@ -259,7 +287,7 @@ { struct multi_instance *curr_mi =3D he->value; - if (curr_mi->halt) + if (curr_mi->halt || !support_push_update(curr_mi)) { continue; } diff --git a/tests/unit_tests/openvpn/test_push_update_msg.c b/tests/unit_t= ests/openvpn/test_push_update_msg.c index 6e49f14..60596ed 100644 --- a/tests/unit_tests/openvpn/test_push_update_msg.c +++ b/tests/unit_tests/openvpn/test_push_update_msg.c @@ -144,7 +144,13 @@ { return true; } -#endif /* ifndef ENABLE_MANAGEMENT */ + +unsigned int +extract_iv_proto(const char *peer_info) +{ + return IV_PROTO_PUSH_UPDATE; +} +#endif /* ifdef ENABLE_MANAGEMENT */ /* tests */ @@ -464,6 +470,7 @@ struct multi_context *m =3D calloc(1, sizeof(struct multi_context)); m->instances =3D calloc(1, sizeof(struct multi_instance *)); struct multi_instance *mi =3D calloc(1, sizeof(struct multi_instance)); + mi->context.c2.tls_multi =3D calloc(1, sizeof(struct tls_multi)); *(m->instances) =3D mi; m->top.options.disable_dco =3D true; *state =3D m; @@ -474,6 +481,7 @@ teardown2(void **state) { struct multi_context *m =3D *state; + free((*(m->instances))->context.c2.tls_multi); free(*(m->instances)); free(m->instances); free(m); -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1255?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: I7c28da72be11c7efbed3068fbfc65f2959227bec Gerrit-Change-Number: 1255 Gerrit-PatchSet: 1 Gerrit-Owner: mrbff Gerrit-Reviewer: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos Gerrit-Attention: flichtenheld --ylcHf6i2ogs= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

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

mrbff would like plaisthos and flichtenheld to review t= his change.

V= iew Change

PUSH_UPDATE server: check IV_PROTO before s=
ending the message to the client

Before sending the PUSH_UPDATE mess= age to the client, we must verify that
the client has actually sent IV_P= ROTO_PUSH_UPDATE to the server, declaring that
it supports push-updates.=

Change-Id: I7c28da72be11c7efbed3068fbfc65f2959227bec
Signed-off-= by: Marco Baffo <marco@...2726...>
---
M src/openvpn/push_util.= c
M tests/unit_tests/openvpn/test_push_update_msg.c
2 files changed, = 38 insertions(+), 2 deletions(-)

git pull ssh:=
//gerrit.openvpn.net:29418/openvpn refs/changes/55/1255/1
diff --=
git a/src/openvpn/push_util.c b/src/openvpn/push_util.c
ind= ex f306104..5c8a9da 100644
--- a/src/openvpn/push_util.c
+++ b/src/openvpn/push_util.c
@@ -7,6 +7,7 @@=

#ifdef ENABLE_MANAGEMENT
#include "multi.h"

+#include "ssl_util.h"
#endif<= br>
#if defined(__GNUC__) || defined(__clang__)
@@ -188,6 +189,26 @@
return true;<= br> }

+/* Return true if the client supports push-update */
+static bool

+support_push_update(struct multi_instanc= e *mi)
+{
<= span style=3D"color: hsl(120, 100%, 40%);">+ if (!mi)
+ {
+ return false;
+ }
+
+ cons= t unsigned int iv_proto_peer =3D extract_iv_proto(mi->context.c2.tls_mul= ti->peer_info);
+ = if (!(iv_proto_peer & IV_PROTO_PUSH_UPDATE))
+ {
+ msg(M_CLIENT, "ERROR: Peer ID: %u does not= support push-update",
+ mi->context.c2.tls_multi ? mi->context.c2.tls_mul= ti->peer_id : UINT32_MAX);
+ return false;
+ }
+
+ return true;
+}
+
int
se= nd_push_update(struct multi_context *m, const void *target, const char *msg= , const push_update_type type, const int push_bundle_size)
= {
@@ -228,9 +249,16 @@

= if (!mi)
{
+ gc_free(&gc);
= return -ENOENT;
}
=
+ if (!support_push_= update(mi))
+ = {
+ gc_fre= e(&gc);
+ = return 0;
+ = }
+
const char *old_ip =3D mi->context.options.ifconfig_local;
const char *old_ipv6 =3D mi->context.options.ifcon= fig_ipv6_local;
if (!mi->halt
@= @ -259,7 +287,7 @@
{
struct m= ulti_instance *curr_mi =3D he->value;

- if (curr_mi->halt)+ if (curr_mi->halt= || !support_push_update(curr_mi))
{
continue;

}
diff -= -git a/tests/unit_tests/openvpn/test_push_update_msg.c b/tests/unit_tests/o= penvpn/test_push_update_msg.c
index 6e49f14..60596ed 100644=
--- a/tests/unit_tests/openvpn/test_push_update_msg.c
+++ b/tests/unit_tests/openvpn/test_push_update_msg.c@@ -144,7 +144,13 @@
{
return = true;
}
+
+unsigned int
+extra= ct_iv_proto(const char *peer_info)
+{
+ = return IV_PROTO_PUSH_UPDATE;
+}
+#endif /= * ifdef ENABLE_MANAGEMENT */

/* tests */=

@@ -464,6 +470,7 @@
= struct multi_context *m =3D calloc(1, sizeof(struct multi_context));
m->instances =3D calloc(1, sizeof(struct multi_instance = *));
struct multi_instance *mi =3D calloc(1, sizeof(st= ruct multi_instance));
+ free((*(m->inst= ances))->context.c2.tls_multi);
free(*(m->instan= ces));
free(m->instances);
fre= e(m);

To view, visit change 1255. To unsubs= cribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I7c28da72be11c7efbed3068fbfc= 65f2959227bec
Gerrit-Change-Number: 1255
Gerrit-PatchSet: 1
Gerrit-Owner: mrbff <marco@...2726...> <= /div>
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...>
= --ylcHf6i2ogs=--