From: "cron2 (Code Review)" Date: Wed, 15 Nov 2023 14:45:30 +0000 In-Reply-To: References: Reply-To: gert@...1296..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641..., a@...2181... Message-ID: <974bc82f12fd974ad883980a3d0602cf1a000280-EmailReplacePatchSet-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="NHN7hUZ8KkQ="; 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 --NHN7hUZ8KkQ= 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= plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/426?usp=3Demail ) The following approvals got outdated and were removed: Code-Review+2 by cron2 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(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/26/426/3 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: newpatchset --NHN7hUZ8KkQ= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

cron2 uploaded patch set #3 to the change originally cr= eated by plaisthos.

View Change

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

Do not check key_state buffers that are in S_UNDEF s=
tate

When a key_state is in S_UNDEF the send_reliable is not initial= ised. So
checking it might access invalid memory or null pointers.
Github: fixes OpenVPN/openvpn#449

Change-Id: I226a73d47a2b1b29f7ec= 175ce23a806593abc2ac
[a@...2181...: add check for !send_reliable and mes= sage]
Signed-off-by: Arne Schwabe <arne@...1227...>
Acked-by: G= ert Doering <gert@...1296...>
Message-Id: <20231115103331.18050= -1-gert@...1296...>
URL: https://www.mail-archive.com/openvpn-devel@...465...= ists.sourceforge.net/msg27401.html
Signed-off-by: Gert Doering <gert@= ...1296...>
---
M src/openvpn/ssl.c
1 file changed, 16 insertio= ns(+), 0 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/ope=
nvpn refs/changes/26/426/3
diff --git a/src/openvpn/ssl.c b/src/ope=
nvpn/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<= br>+ * not S_UNDEF, but= people have reported crashes nonetheless,
+ * therefore we better catch this event, rep= ort and exit.
+ = */
+ if (!k= s->send_reliable)
= + {
+ = msg(M_FATAL, "ERROR: session->key[%d]->send_reliable is NULL = "
+ = "while key state is %s. Exiting.",
+ i, state_name(ks->state));
+ }
<= span style=3D"color: hsl(120, 100%, 40%);">+

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= change 4= 26. 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: 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: newpatchset
--NHN7hUZ8KkQ=--