From: "cron2 (Code Review)" Date: Fri, 10 Oct 2025 14:43:08 +0000 In-Reply-To: References: Reply-To: gert@...1296..., arne-openvpn@...1227..., marco@...2726..., openvpn-devel@lists.sourceforge.net, frank@...2641..., antonio@...2726... Message-ID: <62864071530e460571a86c104f436b1ef436cf78-EmailReplacePatchSet-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="nOqOpjfcSGA="; 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: mrbff , plaisthos , flichtenheld Cc: openvpn-devel --nOqOpjfcSGA= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable cron2 has uploaded a new patch set (#3) to the change originally created by= mrbff. ( http://gerrit.openvpn.net/c/openvpn/+/1255?usp=3Demail ) The following approvals got outdated and were removed: Code-Review+1 by ordex, Code-Review+2 by cron2 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. Also fixed a gc_arena memory leak in one of the error paths and asserted mi->context.c2.tls_multi . Change-Id: I7c28da72be11c7efbed3068fbfc65f2959227bec Signed-off-by: Marco Baffo Acked-by: Gert Doering Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1255 Message-Id: <20251009182855.18712-1-gert@...1296...> URL: https://sourceforge.net/p/openvpn/mailman/message/59244566/ Signed-off-by: Gert Doering --- M src/openvpn/push_util.c M tests/unit_tests/openvpn/test_push_update_msg.c 2 files changed, 36 insertions(+), 8 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/55/1255/3 diff --git a/src/openvpn/push_util.c b/src/openvpn/push_util.c index b475d2e..25c6ebe 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__) @@ -177,20 +178,32 @@ buf_string_compare_advance(&tmp_msg, push_update_cmd); if (process_incoming_push_update(c, pull_permission_mask(c), optio= n_types_found, &tmp_msg, true) =3D=3D PUSH_MSG_ERROR) { - msg(M_WARN, "Failed to process push update message sent to cli= ent ID: %u", - c->c2.tls_multi ? c->c2.tls_multi->peer_id : UINT32_MAX); + msg(M_WARN, "Failed to process push update message sent to cli= ent ID: %u", c->c2.tls_multi->peer_id); continue; } c->options.push_option_types_found |=3D *option_types_found; if (!options_postprocess_pull(&c->options, c->c2.es)) { - msg(M_WARN, "Failed to post-process push update message sent t= o client ID: %u", - c->c2.tls_multi ? c->c2.tls_multi->peer_id : UINT32_MAX); + msg(M_WARN, "Failed to post-process push update message sent t= o client ID: %u", c->c2.tls_multi->peer_id); } } return true; } +/* Return true if the client supports push-update */ +static bool +support_push_update(struct multi_instance *mi) +{ + ASSERT(mi->context.c2.tls_multi); + 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)) + { + 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) { @@ -231,9 +244,17 @@ if (!mi) { + gc_free(&gc); return -ENOENT; } + if (!support_push_update(mi)) + { + msg(M_CLIENT, "PUSH_UPDATE: not sending message to unsupported= peer with ID: %u", mi->context.c2.tls_multi->peer_id); + 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 @@ -262,7 +283,7 @@ { struct multi_instance *curr_mi =3D he->value; - if (curr_mi->halt) + if (curr_mi->halt || !support_push_update(curr_mi)) { continue; } @@ -273,8 +294,7 @@ const char *old_ipv6 =3D curr_mi->context.options.ifconfig_ipv6_lo= cal; if (!send_single_push_update(&curr_mi->context, msgs, &option_type= s_found)) { - msg(M_CLIENT, "ERROR: Peer ID: %u has not been updated", - curr_mi->context.c2.tls_multi ? curr_mi->context.c2.tls_mu= lti->peer_id : UINT32_MAX); + msg(M_CLIENT, "ERROR: Peer ID: %u has not been updated", curr_= mi->context.c2.tls_multi->peer_id); continue; } if (option_types_found & OPT_P_UP) 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: newpatchset Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: I7c28da72be11c7efbed3068fbfc65f2959227bec Gerrit-Change-Number: 1255 Gerrit-PatchSet: 3 Gerrit-Owner: mrbff Gerrit-Reviewer: cron2 Gerrit-Reviewer: flichtenheld Gerrit-Reviewer: ordex Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel --nOqOpjfcSGA= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

cron2 upl= oaded patch set #3 to the change originally created by mrbff.

<= p>View C= hange

The following approvals got outdated and were removed: Code-Review+1 by ordex, Code-Review+2 by cron2

PUSH_UPDATE=
 server: check IV_PROTO before sending the message to the client

Bef= ore sending the PUSH_UPDATE message to the client, we must verify that
t= he client has actually sent IV_PROTO_PUSH_UPDATE to the server, declaring t= hat
it supports push-updates.

Also fixed a gc_arena memory leak i= n one of the error paths and asserted
mi->context.c2.tls_multi .
<= br>Change-Id: I7c28da72be11c7efbed3068fbfc65f2959227bec
Signed-off-by: M= arco Baffo <marco@...2726...>
Acked-by: Gert Doering <gert@...1386...= 296...>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1255
Me= ssage-Id: <20251009182855.18712-1-gert@...1296...>
URL: https://so= urceforge.net/p/openvpn/mailman/message/59244566/
Signed-off-by: Gert Do= ering <gert@...1296...>
---
M src/openvpn/push_util.c
M test= s/unit_tests/openvpn/test_push_update_msg.c
2 files changed, 36 insertio= ns(+), 8 deletions(-)

git pull ssh://gerrit.open=
vpn.net:29418/openvpn refs/changes/55/1255/3
diff --git a/src/openv=
pn/push_util.c b/src/openvpn/push_util.c
index b475d2e..25c= 6ebe 100644
--- a/src/openvpn/push_util.c
+= ++ b/src/openvpn/push_util.c
@@ -7,6 +7,7 @@

#ifdef ENABLE_MANAGEMENT
#include &qu= ot;multi.h"
+#in= clude "ssl_util.h"
#endif

#if defined(__GNUC__) || defined(__clang__)
@@= -177,20 +178,32 @@
buf_string_compare_advance(&am= p;tmp_msg, push_update_cmd);
if (process_incoming_= push_update(c, pull_permission_mask(c), option_types_found, &tmp_msg, t= rue) =3D=3D PUSH_MSG_ERROR)
{
- msg(M_WARN, "Failed to pr= ocess push update message sent to client ID: %u",
- c->c2.tls_multi ? c->= ;c2.tls_multi->peer_id : UINT32_MAX);
+ msg(M_WARN, "Failed to process push u= pdate message sent to client ID: %u", c->c2.tls_multi->peer_id);=
continue;
} c->options.push_option_types_found |=3D *option_types_f= ound;
if (!options_postprocess_pull(&c->opt= ions, c->c2.es))
{
- msg(M_WARN, "Failed to post-proce= ss push update message sent to client ID: %u",
- c->c2.tls_multi ? c->= c2.tls_multi->peer_id : UINT32_MAX);
+ msg(M_WARN, "Failed to post-process pu= sh update message sent to client ID: %u", c->c2.tls_multi->peer_= id);
}
}
= return true;
}

+/* Return true if the client supports push-u= pdate */
+static bool=
+support_push_update= (struct multi_instance *mi)
+{
+ ASSERT= (mi->context.c2.tls_multi);
+ const unsigned int iv_proto_peer =3D extract_iv_proto(mi->= ;context.c2.tls_multi->peer_info);
+ if (!(iv_proto_peer & IV_PROTO_PUSH_UPDATE))
+ {
+ return false;
+ }
+
+ return true;
+
int

send_push_update(struct multi_context *m, const voi= d *target, const char *msg, const push_update_type type, const int push_bun= dle_size)
{
@@ -231,9 +244,17 @@
if (!mi)
{
+ gc_free(&= gc);
return -ENOENT;
= }

+= if (!support_push_update(mi))
+ {
+ msg(M_CLIENT, "PUSH_UPDATE: not sending message to= unsupported peer with ID: %u", mi->context.c2.tls_multi->peer_i= d);
+ gc_f= ree(&gc);
+ = return 0;
+ = }
+
const char *old_ip =3D mi->context.options.ifconfig_local;
const char *old_ipv6 =3D mi->context.options.ifc= onfig_ipv6_local;
if (!mi->halt
@@ -262,7 +283,7 @@

{
struct= multi_instance *curr_mi =3D he->value;

- if (curr_mi->halt)=
+ if (curr_mi->ha= lt || !support_push_update(curr_mi))
{
<= span> continue;
}
@@ -= 273,8 +294,7 @@
const char *old_ipv6 =3D curr_mi-&= gt;context.options.ifconfig_ipv6_local;
if (!send_= single_push_update(&curr_mi->context, msgs, &option_types_found)= )
{
- msg(M_CLIENT, "ERROR: Peer ID: %u has not been upda= ted",
- = curr_mi->context.c2.tls_multi ? curr_mi->context.c2.tls_multi-&g= t;peer_id : UINT32_MAX);
+ msg(M_CLIENT, "ERROR: Peer ID: %u has not been update= d", curr_mi->context.c2.tls_multi->peer_id);
= continue;
}
if = (option_types_found & OPT_P_UP)
diff --git a/tests/unit= _tests/openvpn/test_push_update_msg.c b/tests/unit_tests/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;
<= span> }
-#endif /* ifnd= ef ENABLE_MANAGEMENT */
+
+unsigned int
+extract_iv_proto(const= char *peer_info)
+{<= /span>
+ return IV_PROTO_= PUSH_UPDATE;
+}
+#endif /* ifdef ENABLE_MA= NAGEMENT */

/* tests */
=
@@ -464,6 +470,7 @@
struct multi_con= text *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_instan= ce));

+ mi->con= text.c2.tls_multi =3D calloc(1, sizeof(struct tls_multi));
= *(m->instances) =3D mi;
m->top.options.disa= ble_dco =3D true;
*state =3D m;
@@ -47= 4,6 +481,7 @@
teardown2(void **state)
{
struct multi_context *m =3D *state;
+ free((*(m->instances))->conte= xt.c2.tls_multi);
free(*(m->instances));
= free(m->instances);
free(m);
<= span>

To view, visit change 1255. To unsubscribe, or for hel= p writing mail filters, visit settings.

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I7c28da72be11c7efbed3068fbfc= 65f2959227bec
Gerrit-Change-Number: 1255
Gerrit-PatchSet: 3
Gerrit-Owner: mrbff <marco@...2726...> <= /div>
Gerrit-Reviewer: cron2 <gert@...1296...>=
Gerrit-Reviewer: flichtenheld <frank@...2716...= 1...>
Gerrit-Reviewer: ordex <antonio@...2726...&= gt;
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
= --nOqOpjfcSGA=--