Change in openvpn[master]: PUSH_UPDATE server: check IV_PROTO before sending the message to the ...
A message that is not in the archive (sent off-list or not yet received): gerrit.1759923063000.I7c28da72be11c7efbed3068fbfc65f2959227bec@...2715...
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=email
to review the following change.
Change subject: PUSH_UPDATE server: check IV_PROTO before sending the message 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.
---
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
src/openvpn/push_util.c +29 -1
@@ -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 =extract_iv_proto (mi->context.c2.tls_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 = mi->context.options.ifconfig_local;const char *old_ipv6 = mi->context.options.ifconfig_ipv6_local; if (!mi->halt
@@ -259,7 +287,7 @@ {struct multi_instance *curr_mi = he->value; -if (curr_mi->halt) +if (curr_mi->halt || !support_push_update (curr_mi)) {continue ; }
tests/unit_tests/openvpn/test_push_update_msg.c +9 -1
@@ -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 =calloc (1 ,sizeof (struct multi_context )); m->instances =calloc (1 ,sizeof (struct multi_instance *));struct multi_instance *mi =calloc (1 ,sizeof (struct multi_instance )); + mi->context.c2.tls_multi =calloc (1 ,sizeof (struct tls_multi )); *(m->instances) = mi; m->top.options.disable_dco = true; *state = m;
@@ -474,6 +481,7 @@ teardown2(void **state) {struct multi_context *m = *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=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: I7c28da72be11c7efbed3068fbfc65f2959227bec
Gerrit-Change-Number: 1255
Gerrit-PatchSet: 1
Gerrit-Owner: mrbff <[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]...>
Attention is currently required from: flichtenheld, mrbff, plaisthos.
ordex has posted comments on this change by mrbff. ( http://gerrit.openvpn.net/c/openvpn/+/1255?usp=email )
Change subject: PUSH_UPDATE server: check IV_PROTO before sending the message to the client
......................................................................
Patch Set 1: Code-Review-2
(3 comments)
File src/openvpn/push_util.c:
http://gerrit.openvpn.net/c/openvpn/+/1255/comment/af9bdc8d_7673d872?usp=email :
PS1, Line 204: msg(M_CLIENT, "ERROR: Peer ID: %u does not support push-update",
I'd remove the "ERROR:" label - this is just an information that we have unsupported clients connected and they won't receive the message.
maybe something: "PUSH_UPDATE: not sending message to unsupported peer with ID %u"?
http://gerrit.openvpn.net/c/openvpn/+/1255/comment/352256e9_45e6f7bc?usp=email :
PS1, Line 205: mi->context.c2.tls_multi ? mi->context.c2.tls_multi->peer_id : UINT32_MAX);
you just dereferenced "tls_multi" a few lines above, therefore it must be non-NULL at this point. If you believe it can be NULL, this check should happen earlier on. But can it really happen? I am not sure.
http://gerrit.openvpn.net/c/openvpn/+/1255/comment/ac206d3c_e8cbc84e?usp=email :
PS1, Line 252: gc_free(&gc);
am I wrong or this is totally unrelated?
It still seems a valid fix, but please submit it in its own patch.
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1255?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I7c28da72be11c7efbed3068fbfc65f2959227bec
Gerrit-Change-Number: 1255
Gerrit-PatchSet: 1
Gerrit-Owner: mrbff <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: ordex <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: mrbff <[email protected]...>
Gerrit-Comment-Date: Wed, 08 Oct 2025 12:03:01 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Attention is currently required from: flichtenheld, mrbff, plaisthos.
cron2 has posted comments on this change by mrbff. ( http://gerrit.openvpn.net/c/openvpn/+/1255?usp=email )
Change subject: PUSH_UPDATE server: check IV_PROTO before sending the message to the client
......................................................................
Patch Set 1:
(2 comments)
File src/openvpn/push_util.c:
http://gerrit.openvpn.net/c/openvpn/+/1255/comment/c4b5cab5_f39d3a8a?usp=email :
PS1, Line 199: }
this cannot be NULL - but if you doubt your own callers, make it in an ASSERT(mi).
http://gerrit.openvpn.net/c/openvpn/+/1255/comment/df6efcad_2cdada10?usp=email :
PS1, Line 204: msg(M_CLIENT, "ERROR: Peer ID: %u does not support push-update",
Quoted 1 line
I'd remove the "ERROR:" label - this is just an information that we have unsupported clients connect […]
For the "I want *this* one client" case, an ERROR is valid, for the "send to all" it's a bit excessive ("there are 400 clients connected, only 2 of them are new enough to receive this, so 398 error messages"). So maybe moving the msg() call to UPD_BY_CID case in send_push_update()?
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1255?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I7c28da72be11c7efbed3068fbfc65f2959227bec
Gerrit-Change-Number: 1255
Gerrit-PatchSet: 1
Gerrit-Owner: mrbff <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: ordex <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: cron2 <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: mrbff <[email protected]...>
Gerrit-Comment-Date: Wed, 08 Oct 2025 12:10:48 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: ordex <[email protected]...>
Attention is currently required from: cron2, flichtenheld, ordex, plaisthos.
mrbff has posted comments on this change by mrbff. ( http://gerrit.openvpn.net/c/openvpn/+/1255?usp=email )
Change subject: PUSH_UPDATE server: check IV_PROTO before sending the message to the client
......................................................................
Patch Set 1:
(4 comments)
File src/openvpn/push_util.c:
http://gerrit.openvpn.net/c/openvpn/+/1255/comment/df855855_fc7dc98e?usp=email :
PS1, Line 199: }
Quoted 1 line
this cannot be NULL - but if you doubt your own callers, make it in an
ASSERT(mi).
Acknowledged
http://gerrit.openvpn.net/c/openvpn/+/1255/comment/d70a48ea_ca9f747a?usp=email :
PS1, Line 204: msg(M_CLIENT, "ERROR: Peer ID: %u does not support push-update",
Quoted 1 line
For the "I want *this* one client" case, an ERROR is valid, for the "send to all" it's a bit excessi […]
Acknowledged
http://gerrit.openvpn.net/c/openvpn/+/1255/comment/275c68b2_08325ea1?usp=email :
PS1, Line 205: mi->context.c2.tls_multi ? mi->context.c2.tls_multi->peer_id : UINT32_MAX);
Quoted 1 line
you just dereferenced "
tls_multi" a few lines above, therefore it must be non-NULL at this point. […]
Acknowledged
http://gerrit.openvpn.net/c/openvpn/+/1255/comment/b80626a7_60d0008d?usp=email :
PS1, Line 252: gc_free(&gc);
Quoted 1 line
am I wrong or this is totally unrelated? […]
yeah, it is unrelated, but a patch only for this?
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1255?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I7c28da72be11c7efbed3068fbfc65f2959227bec
Gerrit-Change-Number: 1255
Gerrit-PatchSet: 1
Gerrit-Owner: mrbff <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: ordex <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: cron2 <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: ordex <[email protected]...>
Gerrit-Comment-Date: Wed, 08 Oct 2025 12:19:06 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: cron2 <[email protected]...>
Comment-In-Reply-To: ordex <[email protected]...>
Attention is currently required from: flichtenheld, mrbff, ordex, plaisthos.
cron2 has posted comments on this change by mrbff. ( http://gerrit.openvpn.net/c/openvpn/+/1255?usp=email )
Change subject: PUSH_UPDATE server: check IV_PROTO before sending the message to the client
......................................................................
Patch Set 1:
(1 comment)
File src/openvpn/push_util.c:
http://gerrit.openvpn.net/c/openvpn/+/1255/comment/1b73c2df_7d09cc66?usp=email :
PS1, Line 252: gc_free(&gc);
Quoted 1 line
yeah, it is unrelated, but a patch only for this?
I'l leave it in, and mention it in the commit message
"while at it, fix a gc_arena mem leak in one of the error paths"
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1255?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I7c28da72be11c7efbed3068fbfc65f2959227bec
Gerrit-Change-Number: 1255
Gerrit-PatchSet: 1
Gerrit-Owner: mrbff <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: ordex <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: cron2 <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: ordex <[email protected]...>
Gerrit-Attention: mrbff <[email protected]...>
Gerrit-Comment-Date: Wed, 08 Oct 2025 12:21:35 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: ordex <[email protected]...>
Comment-In-Reply-To: mrbff <[email protected]...>
Attention is currently required from: flichtenheld, mrbff, ordex, plaisthos.
Hello flichtenheld, ordex, plaisthos,
I'd like you to reexamine a change. Please visit
http://gerrit.openvpn.net/c/openvpn/+/1255?usp=email
to look at the new patch set (#2).
Change subject: PUSH_UPDATE server: check IV_PROTO before sending the message 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 .
---
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/2
src/openvpn/push_util.c +27 -7
@@ -7,6 +7,7 @@#ifdef ENABLE_MANAGEMENT #include "multi.h" +#include "ssl_util.h" #endif #if defined(__GNUC__) || defined(__clang__)
@@ -174,20 +175,32 @@buf_string_compare_advance (&msgs[i], push_update_cmd);if (process_incoming_push_update (c,pull_permission_mask (c), option_types_found, &msgs[i], true) ==PUSH_MSG_ERROR ) { -msg (M_WARN ,"Failed to process 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 update message sent to client ID: %u" , c->c2.tls_multi->peer_id);continue ; } c->options.push_option_types_found |= *option_types_found;if (!options_postprocess_pull (&c->options, c->c2.es)) { -msg (M_WARN ,"Failed to post-process 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 push update message sent to 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 =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 void *target,const char *msg,const push_update_type type,const int push_bundle_size) {
@@ -228,9 +241,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 = mi->context.options.ifconfig_local;const char *old_ipv6 = mi->context.options.ifconfig_ipv6_local; if (!mi->halt
@@ -259,7 +280,7 @@ {struct multi_instance *curr_mi = he->value; -if (curr_mi->halt) +if (curr_mi->halt || !support_push_update (curr_mi)) {continue ; }
@@ -270,8 +291,7 @@const char *old_ipv6 = curr_mi->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 updated" , - curr_mi->context.c2.tls_multi ? curr_mi->context.c2.tls_multi->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 )
tests/unit_tests/openvpn/test_push_update_msg.c +9 -1
@@ -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 =calloc (1 ,sizeof (struct multi_context )); m->instances =calloc (1 ,sizeof (struct multi_instance *));struct multi_instance *mi =calloc (1 ,sizeof (struct multi_instance )); + mi->context.c2.tls_multi =calloc (1 ,sizeof (struct tls_multi )); *(m->instances) = mi; m->top.options.disable_dco = true; *state = m;
@@ -474,6 +481,7 @@ teardown2(void **state) {struct multi_context *m = *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=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I7c28da72be11c7efbed3068fbfc65f2959227bec
Gerrit-Change-Number: 1255
Gerrit-PatchSet: 2
Gerrit-Owner: mrbff <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: ordex <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: cron2 <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: ordex <[email protected]...>
Gerrit-Attention: mrbff <[email protected]...>
Attention is currently required from: cron2, flichtenheld, ordex, plaisthos.
mrbff has posted comments on this change by mrbff. ( http://gerrit.openvpn.net/c/openvpn/+/1255?usp=email )
Change subject: PUSH_UPDATE server: check IV_PROTO before sending the message to the client
......................................................................
Patch Set 1:
(2 comments)
File src/openvpn/push_util.c:
http://gerrit.openvpn.net/c/openvpn/+/1255/comment/8cf8fa77_19df11d9?usp=email :
PS1, Line 204: msg(M_CLIENT, "ERROR: Peer ID: %u does not support push-update",
Quoted 1 line
Acknowledged
Now i log the message "PUSH_UPDATE: not sending message to unsupported peer with ID %u" just in upt-cid. After that a "ERROR: no client updated" message will be logged so should be clear it's an error anyway.
http://gerrit.openvpn.net/c/openvpn/+/1255/comment/cbf60c60_b11a51e8?usp=email :
PS1, Line 252: gc_free(&gc);
Quoted 1 line
I'l leave it in, and mention it in the commit message […]
Done
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1255?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I7c28da72be11c7efbed3068fbfc65f2959227bec
Gerrit-Change-Number: 1255
Gerrit-PatchSet: 1
Gerrit-Owner: mrbff <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: ordex <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: cron2 <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: ordex <[email protected]...>
Gerrit-Comment-Date: Wed, 08 Oct 2025 13:32:24 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: cron2 <[email protected]...>
Comment-In-Reply-To: ordex <[email protected]...>
Comment-In-Reply-To: mrbff <[email protected]...>
Attention is currently required from: cron2, flichtenheld, mrbff, plaisthos.
ordex has posted comments on this change by mrbff. ( http://gerrit.openvpn.net/c/openvpn/+/1255?usp=email )
Change subject: PUSH_UPDATE server: check IV_PROTO before sending the message to the client
......................................................................
Patch Set 2: Code-Review-2
(1 comment)
File src/openvpn/push_util.c:
http://gerrit.openvpn.net/c/openvpn/+/1255/comment/9f86880a_824507c6?usp=email :
PS2, Line 294: msg(M_CLIENT, "ERROR: Peer ID: %u has not been updated", curr_mi->context.c2.tls_multi->peer_id);
I thought we wanted to print a message only in the BY_ID command, no? Here it's the broadcast branch.
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1255?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I7c28da72be11c7efbed3068fbfc65f2959227bec
Gerrit-Change-Number: 1255
Gerrit-PatchSet: 2
Gerrit-Owner: mrbff <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: ordex <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: cron2 <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: mrbff <[email protected]...>
Gerrit-Comment-Date: Thu, 09 Oct 2025 11:21:47 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Attention is currently required from: cron2, flichtenheld, ordex, plaisthos.
mrbff has posted comments on this change by mrbff. ( http://gerrit.openvpn.net/c/openvpn/+/1255?usp=email )
Change subject: PUSH_UPDATE server: check IV_PROTO before sending the message to the client
......................................................................
Patch Set 2:
(1 comment)
File src/openvpn/push_util.c:
http://gerrit.openvpn.net/c/openvpn/+/1255/comment/b02c6dcb_0391bff1?usp=email :
PS2, Line 294: msg(M_CLIENT, "ERROR: Peer ID: %u has not been updated", curr_mi->context.c2.tls_multi->peer_id);
Quoted 1 line
I thought we wanted to print a message only in the
BY_IDcommand, no? Here it's the broadcast branch […]
this is unrelated to the new patch, the error message was already, here, but it is not triggered by the presence or not of the IV_PROTO_PUSH_UPDATE. It's just in case there is another generic problem, it should not happen normally. I just removed the inline statement since I assert that tls_multi is not NULL (in support_push_update()).
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1255?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I7c28da72be11c7efbed3068fbfc65f2959227bec
Gerrit-Change-Number: 1255
Gerrit-PatchSet: 2
Gerrit-Owner: mrbff <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: ordex <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: cron2 <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: ordex <[email protected]...>
Gerrit-Comment-Date: Thu, 09 Oct 2025 11:45:08 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: ordex <[email protected]...>
Attention is currently required from: cron2, flichtenheld, plaisthos.
ordex has posted comments on this change by mrbff. ( http://gerrit.openvpn.net/c/openvpn/+/1255?usp=email )
Change subject: PUSH_UPDATE server: check IV_PROTO before sending the message to the client
......................................................................
Patch Set 2: -Code-Review
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1255?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I7c28da72be11c7efbed3068fbfc65f2959227bec
Gerrit-Change-Number: 1255
Gerrit-PatchSet: 2
Gerrit-Owner: mrbff <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: ordex <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: cron2 <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Thu, 09 Oct 2025 11:50:25 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Attention is currently required from: cron2, flichtenheld, mrbff, plaisthos.
ordex has posted comments on this change by mrbff. ( http://gerrit.openvpn.net/c/openvpn/+/1255?usp=email )
Change subject: PUSH_UPDATE server: check IV_PROTO before sending the message to the client
......................................................................
Patch Set 2: Code-Review+1
(1 comment)
Patchset:
PS2:
ok, this looks good to me
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1255?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I7c28da72be11c7efbed3068fbfc65f2959227bec
Gerrit-Change-Number: 1255
Gerrit-PatchSet: 2
Gerrit-Owner: mrbff <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: ordex <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: cron2 <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: mrbff <[email protected]...>
Gerrit-Comment-Date: Thu, 09 Oct 2025 11:52:59 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Attention is currently required from: flichtenheld, mrbff, plaisthos.
cron2 has posted comments on this change by mrbff. ( http://gerrit.openvpn.net/c/openvpn/+/1255?usp=email )
Change subject: PUSH_UPDATE server: check IV_PROTO before sending the message to the client
......................................................................
Patch Set 2: Code-Review+2
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1255?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I7c28da72be11c7efbed3068fbfc65f2959227bec
Gerrit-Change-Number: 1255
Gerrit-PatchSet: 2
Gerrit-Owner: mrbff <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: ordex <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: mrbff <[email protected]...>
Gerrit-Comment-Date: Thu, 09 Oct 2025 18:28:40 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
PATCH v2 1/1 PUSH_UPDATE server: check IV_PROTO before sending the message to the client
In reply to a message not in the archiveFrom: Marco Baffo <[email protected]...>
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 .
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1255
---
This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1255
This mail reflects revision 2 of this Change.
Acked-by according to Gerrit (reflected above):
Gert Doering <[email protected]...>
src/openvpn/push_util.c +27 -7
@@ -7,6 +7,7 @@#ifdef ENABLE_MANAGEMENT #include "multi.h" +#include "ssl_util.h" #endif #if defined(__GNUC__) || defined(__clang__)
@@ -174,20 +175,32 @@buf_string_compare_advance (&msgs[i], push_update_cmd);if (process_incoming_push_update (c,pull_permission_mask (c), option_types_found, &msgs[i], true) ==PUSH_MSG_ERROR ) { -msg (M_WARN ,"Failed to process 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 update message sent to client ID: %u" , c->c2.tls_multi->peer_id);continue ; } c->options.push_option_types_found |= *option_types_found;if (!options_postprocess_pull (&c->options, c->c2.es)) { -msg (M_WARN ,"Failed to post-process 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 push update message sent to 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 =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 void *target,const char *msg,const push_update_type type,const int push_bundle_size) {
@@ -228,9 +241,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 = mi->context.options.ifconfig_local;const char *old_ipv6 = mi->context.options.ifconfig_ipv6_local; if (!mi->halt
@@ -259,7 +280,7 @@ {struct multi_instance *curr_mi = he->value; -if (curr_mi->halt) +if (curr_mi->halt || !support_push_update (curr_mi)) {continue ; }
@@ -270,8 +291,7 @@const char *old_ipv6 = curr_mi->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 updated" , - curr_mi->context.c2.tls_multi ? curr_mi->context.c2.tls_multi->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 )
tests/unit_tests/openvpn/test_push_update_msg.c +9 -1
@@ -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 =calloc (1 ,sizeof (struct multi_context )); m->instances =calloc (1 ,sizeof (struct multi_instance *));struct multi_instance *mi =calloc (1 ,sizeof (struct multi_instance )); + mi->context.c2.tls_multi =calloc (1 ,sizeof (struct tls_multi )); *(m->instances) = mi; m->top.options.disable_dco = true; *state = m;
@@ -474,6 +481,7 @@ teardown2(void **state) {struct multi_context *m = *state; +free ((*(m->instances))->context.c2.tls_multi);free (*(m->instances));free (m->instances);free (m);
[Openvpn-devel] [PATCH applied] Re: PUSH_UPDATE server: check IV_PROTO before sending the message to the client
Tested on a system with 3 clients, 2 of them capable, 1 incapable of receiving PUSH_UPDATE messages. Both "push-update-broad" and "push-update-cid" now (with 1264) do what it says - "send to all who can receive" or "send, if possible, error message otherwise".
Your patch has been applied to the master branch.
commit 855094893e8cd808ddc74d2e6d392cf04bd06a65
Author: Marco Baffo Date: Thu Oct 9 20:28:49 2025 +0200
PUSH_UPDATE server: check IV_PROTO before sending the message to the client
Signed-off-by: Marco Baffo <[email protected]...>
Acked-by: Gert Doering <[email protected]...>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1255
Message-Id: <[email protected]...>
URL: https://sourceforge.net/p/openvpn/mailman/message/59244566/
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
Attention is currently required from: flichtenheld, mrbff, plaisthos.
cron2 has posted comments on this change by mrbff. ( http://gerrit.openvpn.net/c/openvpn/+/1255?usp=email )
Change subject: PUSH_UPDATE server: check IV_PROTO before sending the message to the client
......................................................................
Patch Set 2: Code-Review-1
(1 comment)
Patchset:
PS2:
This does not work for me.
I have 3 clients connected, 2 with "master, sends IV" and 1 on 2.6 (freebsd-14-amd64 is "2.6")
``` CLIENT_LIST freebsd-14-amd64 udp6:194.97.140.5:64748 10.204.2.46 fd00:abcd:204:2::100a 6448 5636 2025-10-10 09:57:55 1760083075 MyTokenUser 57 2 AES-256-GCM CLIENT_LIST cron2-freebsd-tc-amd64-25 udp6:194.97.140.21:25690 10.204.2.38 fd00:abcd:204:2::1008 5383 5284 2025-10-10 09:58:43 1760083123 MyTokenUser 59 3 AES-256-GCM CLIENT_LIST cron2-macos-arm64-m2 udp6:193.149.48.144:51724 10.204.2.50 fd00:abcd:204:2::100b 8497 7237 2025-10-10 09:52:05 1760082725 MyTokenUser 55 0 AES-256-GCM ```
Then I do a push-update-broad "-dns" (something harmless). The log file shows
``` Oct 10 09:59:17 gentoo tun-udp-p2mp[24491]: SENT CONTROL [freebsd-14-amd64]: 'PUSH_UPDATE,-dns' (status=1) Oct 10 09:59:17 gentoo tun-udp-p2mp[24491]: SENT CONTROL [cron2-macos-arm64-m2]: '' (status=1) Oct 10 09:59:17 gentoo tun-udp-p2mp[24491]: Failed to process push update message sent to client ID: 0 ```
why only 2 clients? why is the message empty on the second one?
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1255?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I7c28da72be11c7efbed3068fbfc65f2959227bec
Gerrit-Change-Number: 1255
Gerrit-PatchSet: 2
Gerrit-Owner: mrbff <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: ordex <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: mrbff <[email protected]...>
Gerrit-Comment-Date: Fri, 10 Oct 2025 08:03:31 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Attention is currently required from: cron2, flichtenheld, plaisthos.
mrbff has posted comments on this change by mrbff. ( http://gerrit.openvpn.net/c/openvpn/+/1255?usp=email )
Change subject: PUSH_UPDATE server: check IV_PROTO before sending the message to the client
......................................................................
Patch Set 2:
(1 comment)
Patchset:
PS2:
Quoted 1 line
This does not work for me. […]
It's a bug unrelated to this patch, I sent another patch to fix it https://gerrit.openvpn.net/c/openvpn/+/1264
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1255?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I7c28da72be11c7efbed3068fbfc65f2959227bec
Gerrit-Change-Number: 1255
Gerrit-PatchSet: 2
Gerrit-Owner: mrbff <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: ordex <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Fri, 10 Oct 2025 10:23:18 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: cron2 <[email protected]...>
Attention is currently required from: flichtenheld, mrbff, plaisthos.
cron2 has posted comments on this change by mrbff. ( http://gerrit.openvpn.net/c/openvpn/+/1255?usp=email )
Change subject: PUSH_UPDATE server: check IV_PROTO before sending the message to the client
......................................................................
Patch Set 2: Code-Review+2
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1255?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I7c28da72be11c7efbed3068fbfc65f2959227bec
Gerrit-Change-Number: 1255
Gerrit-PatchSet: 2
Gerrit-Owner: mrbff <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: ordex <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: mrbff <[email protected]...>
Gerrit-Comment-Date: Fri, 10 Oct 2025 14:19:16 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Attention is currently required from: flichtenheld, mrbff, plaisthos.
cron2 has posted comments on this change by mrbff. ( http://gerrit.openvpn.net/c/openvpn/+/1255?usp=email )
Change subject: PUSH_UPDATE server: check IV_PROTO before sending the message to the client
......................................................................
Patch Set 2:
(1 comment)
Patchset:
PS2:
with the bugfix from #1264, this works
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1255?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I7c28da72be11c7efbed3068fbfc65f2959227bec
Gerrit-Change-Number: 1255
Gerrit-PatchSet: 2
Gerrit-Owner: mrbff <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: ordex <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: mrbff <[email protected]...>
Gerrit-Comment-Date: Fri, 10 Oct 2025 14:20:24 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
cron2 has uploaded a new patch set (#3) to the change originally created by mrbff. ( http://gerrit.openvpn.net/c/openvpn/+/1255?usp=email )
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 message 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 .
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1255
Message-Id: <[email protected]...>
URL: https://sourceforge.net/p/openvpn/mailman/message/59244566/
---
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
src/openvpn/push_util.c +27 -7
@@ -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), option_types_found, &tmp_msg, true) ==PUSH_MSG_ERROR ) { -msg (M_WARN ,"Failed to process 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 update message sent to client ID: %u" , c->c2.tls_multi->peer_id);continue ; } c->options.push_option_types_found |= *option_types_found;if (!options_postprocess_pull (&c->options, c->c2.es)) { -msg (M_WARN ,"Failed to post-process 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 push update message sent to 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 =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 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 = mi->context.options.ifconfig_local;const char *old_ipv6 = mi->context.options.ifconfig_ipv6_local; if (!mi->halt
@@ -262,7 +283,7 @@ {struct multi_instance *curr_mi = he->value; -if (curr_mi->halt) +if (curr_mi->halt || !support_push_update (curr_mi)) {continue ; }
@@ -273,8 +294,7 @@const char *old_ipv6 = curr_mi->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 updated" , - curr_mi->context.c2.tls_multi ? curr_mi->context.c2.tls_multi->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 )
tests/unit_tests/openvpn/test_push_update_msg.c +9 -1
@@ -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 =calloc (1 ,sizeof (struct multi_context )); m->instances =calloc (1 ,sizeof (struct multi_instance *));struct multi_instance *mi =calloc (1 ,sizeof (struct multi_instance )); + mi->context.c2.tls_multi =calloc (1 ,sizeof (struct tls_multi )); *(m->instances) = mi; m->top.options.disable_dco = true; *state = m;
@@ -474,6 +481,7 @@ teardown2(void **state) {struct multi_context *m = *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=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I7c28da72be11c7efbed3068fbfc65f2959227bec
Gerrit-Change-Number: 1255
Gerrit-PatchSet: 3
Gerrit-Owner: mrbff <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: ordex <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/1255?usp=email )
Change subject: PUSH_UPDATE server: check IV_PROTO before sending the message 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 .
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1255
Message-Id: <[email protected]...>
URL: https://sourceforge.net/p/openvpn/mailman/message/59244566/
---
M src/openvpn/push_util.c
M tests/unit_tests/openvpn/test_push_update_msg.c
2 files changed, 36 insertions(+), 8 deletions(-)
src/openvpn/push_util.c +27 -7
@@ -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), option_types_found, &tmp_msg, true) ==PUSH_MSG_ERROR ) { -msg (M_WARN ,"Failed to process 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 update message sent to client ID: %u" , c->c2.tls_multi->peer_id);continue ; } c->options.push_option_types_found |= *option_types_found;if (!options_postprocess_pull (&c->options, c->c2.es)) { -msg (M_WARN ,"Failed to post-process 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 push update message sent to 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 =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 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 = mi->context.options.ifconfig_local;const char *old_ipv6 = mi->context.options.ifconfig_ipv6_local; if (!mi->halt
@@ -262,7 +283,7 @@ {struct multi_instance *curr_mi = he->value; -if (curr_mi->halt) +if (curr_mi->halt || !support_push_update (curr_mi)) {continue ; }
@@ -273,8 +294,7 @@const char *old_ipv6 = curr_mi->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 updated" , - curr_mi->context.c2.tls_multi ? curr_mi->context.c2.tls_multi->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 )
tests/unit_tests/openvpn/test_push_update_msg.c +9 -1
@@ -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 =calloc (1 ,sizeof (struct multi_context )); m->instances =calloc (1 ,sizeof (struct multi_instance *));struct multi_instance *mi =calloc (1 ,sizeof (struct multi_instance )); + mi->context.c2.tls_multi =calloc (1 ,sizeof (struct tls_multi )); *(m->instances) = mi; m->top.options.disable_dco = true; *state = m;
@@ -474,6 +481,7 @@ teardown2(void **state) {struct multi_context *m = *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=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I7c28da72be11c7efbed3068fbfc65f2959227bec
Gerrit-Change-Number: 1255
Gerrit-PatchSet: 3
Gerrit-Owner: mrbff <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: ordex <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>