From: "cron2 (Code Review)" Date: Wed, 15 Nov 2023 14:45:35 +0000 In-Reply-To: References: Reply-To: gert@...1296..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641..., a@...2181... Message-ID: <974bc82f12fd974ad883980a3d0602cf1a000280-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="OjyLqFcnAwQ="; 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 Cc: flichtenheld , openvpn-devel --OjyLqFcnAwQ= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/42= 6?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. Github: fixes OpenVPN/openvpn#449 Change-Id: I226a73d47a2b1b29f7ec175ce23a806593abc2ac [a@...2181...: add check for !send_reliable and message] Signed-off-by: Arne Schwabe Acked-by: Gert Doering Message-Id: <20231115103331.18050-1-gert@...1296...> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg27= 401.html Signed-off-by: Gert Doering --- M src/openvpn/ssl.c 1 file changed, 16 insertions(+), 0 deletions(-) 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: 3 Gerrit-Owner: plaisthos Gerrit-Reviewer: cron2 Gerrit-Reviewer: flichtenheld Gerrit-Reviewer: ordex Gerrit-CC: openvpn-devel Gerrit-MessageType: merged --OjyLqFcnAwQ= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

cron2 submitted this change.

View Change

Do not check key_state buffers that are in S_U=
NDEF state

When a key_state is in S_UNDEF the send_reliable is not i= nitialised. So
checking it might access invalid memory or null pointers.=

Github: fixes OpenVPN/openvpn#449

Change-Id: I226a73d47a2b1b= 29f7ec175ce23a806593abc2ac
[a@...2181...: add check for !send_reliable a= nd message]
Signed-off-by: Arne Schwabe <arne@...1227...>
Acked= -by: Gert Doering <gert@...1296...>
Message-Id: <20231115103331= .18050-1-gert@...1296...>
URL: https://www.mail-archive.com/openvpn-d= evel@lists.sourceforge.net/msg27401.html
Signed-off-by: Gert Doering <= ;gert@...1296...>
---
M src/openvpn/ssl.c
1 file changed, 16 in= sertions(+), 0 deletions(-)

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 sen= d_reliable to be NULL when state is
+ * not S_UNDEF, but people have reported crashes no= netheless,
+ = * therefore we better catch this event, report and exit.
+ */
+ if (!ks->send_reliable)
<= span style=3D"color: hsl(120, 100%, 40%);">+ {
+ msg(M_FATAL, "ERROR: ses= sion->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)<= br>

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

<= /div>
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I226a73d47a2b1b29f7ec175ce23= a806593abc2ac
Gerrit-Change-Number: 426
Gerrit-PatchSet: 3
Gerrit-Owner: plaisthos <arne-openvpn@...1711...= 27...>
Gerrit-Reviewer: cron2 <gert@...1296...>=
Gerrit-Reviewer: flichtenheld <frank@...2716...= 1...>
Gerrit-Reviewer: ordex <a@...2181...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-MessageType: merged
--OjyLqFcnAwQ=--