From: "ordex (Code Review)" Date: Wed, 15 Nov 2023 10:23:05 +0000 In-Reply-To: References: Reply-To: a@...2181..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: <58b3e1584bdb329e21ec3b15743dc47fe897e564-EmailReplacePatchSet-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="tv6OyPZXkLk="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: Do not check key_state buffers that are in S_UNDEF state List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: plaisthos , flichtenheld Cc: openvpn-devel --tv6OyPZXkLk= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Attention is currently required from: flichtenheld, plaisthos. ordex has uploaded a new patch set (#2) to the change originally created by= plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/426?usp=3Demail ) Change subject: Do not check key_state buffers that are in S_UNDEF state ...................................................................... Do not check key_state buffers that are in S_UNDEF state When a key_state is in S_UNDEF the send_reliable is not initialised. So checking it might access invalid memory or null pointers. Change-Id: I226a73d47a2b1b29f7ec175ce23a806593abc2ac [a@...2181...: add check for !send_reliable and message] Signed-off-by: Arne Schwabe --- M src/openvpn/ssl.c 1 file changed, 16 insertions(+), 0 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/26/426/2 diff --git a/src/openvpn/ssl.c b/src/openvpn/ssl.c index cee4afe..b4cd8f5 100644 --- a/src/openvpn/ssl.c +++ b/src/openvpn/ssl.c @@ -3189,6 +3189,22 @@ for (int i =3D 0; i < KS_SIZE; i++) { struct key_state *ks =3D &session->key[i]; + if (ks->state =3D=3D S_UNDEF) + { + continue; + } + + /* we don't expect send_reliable to be NULL when state is + * not S_UNDEF, but people have reported crashes nonetheless, + * therefore we better catch this event, report and exit. + */ + if (!ks->send_reliable) + { + msg(M_FATAL, "ERROR: session->key[%d]->send_reliable is NULL " + "while key state is %s. Exiting.", + i, state_name(ks->state)); + } + for (int j =3D 0; j < ks->send_reliable->size; j++) { if (ks->send_reliable->array[i].buf.data =3D=3D dataptr) -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/426?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: I226a73d47a2b1b29f7ec175ce23a806593abc2ac Gerrit-Change-Number: 426 Gerrit-PatchSet: 2 Gerrit-Owner: plaisthos Gerrit-Reviewer: flichtenheld Gerrit-Reviewer: ordex Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos Gerrit-Attention: flichtenheld Gerrit-MessageType: newpatchset --tv6OyPZXkLk= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is currently required from: flichtenheld, plaisthos.

ordex uploaded patch set #2 to the change originally cr= eated by plaisthos.

View Change

Do not check key_state buffers that are in=
 S_UNDEF state

When a key_state is in S_UNDEF the send_reliable is n= ot initialised. So
checking it might access invalid memory or null point= ers.

Change-Id: I226a73d47a2b1b29f7ec175ce23a806593abc2ac
[a@...1665...= 181...: add check for !send_reliable and message]
Signed-off-by: Arne Sc= hwabe <arne@...1227...>
---
M src/openvpn/ssl.c
1 file chang= ed, 16 insertions(+), 0 deletions(-)

git pull ssh://gerrit.openvp=
n.net:29418/openvpn refs/changes/26/426/2
diff --git a/src/openvpn/=
ssl.c b/src/openvpn/ssl.c
index cee4afe..b4cd8f5 100644
--- a/src/openvpn/ssl.c
+++ b/src/openvpn/ssl.= c
@@ -3189,6 +3189,22 @@
for (int i = =3D 0; i < KS_SIZE; i++)
{
= struct key_state *ks =3D &session->key[i];
+ if (ks->state =3D=3D S_UNDEF)
+ {
+ continue;

<= span style=3D"color: hsl(120, 100%, 40%);">+ }

+
+ /* we don't expect send_reliable to be NULL when= state is
+ *= not S_UNDEF, but people have reported crashes nonetheless,
+ * therefore we better catc= h this event, report and exit.
+ */
+ {
+ msg(M_FATAL, "ERROR: session->key[%d]->send_= reliable is NULL "
+ "while key state is %s. Exiting.",
= + i, state_name(= ks->state));
+ = }
+
for (int j =3D 0; j < ks->send_reliable->size; j++)
{
if (ks->send_relia= ble->array[i].buf.data =3D=3D dataptr)

=

To view, visit change 426. To unsubscribe, or for help writing mail filters,= visit settings.

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I226a73d47a2b1b29f7ec175ce23= a806593abc2ac
Gerrit-Change-Number: 426
Gerrit-PatchSet: 2
Gerrit-Owner: plaisthos <arne-openvpn@...1711...= 27...>
Gerrit-Reviewer: flichtenheld <frank@...2716...= 1...>
Gerrit-Reviewer: ordex <a@...2181...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-Attention: plaisthos <arne-openvpn@...220...= ..1227...>
Gerrit-Attention: flichtenheld <frank@...2375...= 41...>
Gerrit-MessageType: newpatchset
--tv6OyPZXkLk=--