From: "cron2 (Code Review)" Date: Mon, 13 May 2024 15:24:13 +0000 In-Reply-To: References: Reply-To: gert@...1296..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: <820b5ea9f9005e6e5d226a5397591081899638a8-EmailReplacePatchSet-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="TyD3d3AhXYQ="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: Workaround issue in LibreSSL crashing when enumerating digests/ciphers List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: plaisthos , flichtenheld Cc: openvpn-devel --TyD3d3AhXYQ= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable cron2 has uploaded a new patch set (#2) to the change originally created by= plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/586?usp=3Demail ) The following approvals got outdated and were removed: Code-Review+2 by cron2 Change subject: Workaround issue in LibreSSL crashing when enumerating dige= sts/ciphers ...................................................................... Workaround issue in LibreSSL crashing when enumerating digests/ciphers OpenBSD/LibreSSL reimplemented EVP_get_cipherbyname/EVP_get_digestbyname and broke calling EVP_get_cipherbynid/EVP_get_digestbyname with an invalid nid in the process so that it would segfault. Workaround but doing that NULL check in OpenVPN instead of leaving it to the library. Github: see also https://github.com/libressl/openbsd/issues/150 Change-Id: Ia08a9697d0ff41721fb0acf17ccb4cfa23cb3934 Signed-off-by: Arne Schwabe Acked-by: Gert Doering Message-Id: <20240508220540.12554-1-gert@...1296...> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg28= 649.html Signed-off-by: Gert Doering --- M src/openvpn/crypto_openssl.c 1 file changed, 25 insertions(+), 1 deletion(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/86/586/2 diff --git a/src/openvpn/crypto_openssl.c b/src/openvpn/crypto_openssl.c index 61c6518..1649ab7 100644 --- a/src/openvpn/crypto_openssl.c +++ b/src/openvpn/crypto_openssl.c @@ -387,7 +387,19 @@ #else for (int nid =3D 0; nid < 10000; ++nid) { +#if defined(LIBRESSL_VERSION_NUMBER) + /* OpenBSD/LibreSSL reimplemented EVP_get_cipherbyname and broke + * calling EVP_get_cipherbynid with an invalid nid in the process + * so that it would segfault. */ + const EVP_CIPHER *cipher =3D NULL; + const char *name =3D OBJ_nid2sn(nid); + if (name) + { + cipher =3D EVP_get_cipherbyname(name); + } +#else /* if defined(LIBRESSL_VERSION_NUMBER) */ const EVP_CIPHER *cipher =3D EVP_get_cipherbynid(nid); +#endif /* We cast the const away so we can keep the function prototype * compatible with EVP_CIPHER_do_all_provided */ collect_ciphers((EVP_CIPHER *) cipher, &cipher_list); @@ -441,7 +453,19 @@ #else for (int nid =3D 0; nid < 10000; ++nid) { + /* OpenBSD/LibreSSL reimplemented EVP_get_digestbyname and broke + * calling EVP_get_digestbynid with an invalid nid in the process + * so that it would segfault. */ +#ifdef LIBRESSL_VERSION_NUMBER + const EVP_MD *digest =3D NULL; + const char *name =3D OBJ_nid2sn(nid); + if (name) + { + digest =3D EVP_get_digestbyname(name); + } +#else /* ifdef LIBRESSL_VERSION_NUMBER */ const EVP_MD *digest =3D EVP_get_digestbynid(nid); +#endif if (digest) { /* We cast the const away so we can keep the function prototype @@ -449,7 +473,7 @@ print_digest((EVP_MD *)digest, NULL); } } -#endif +#endif /* if OPENSSL_VERSION_NUMBER >=3D 0x30000000L */ printf("\n"); } -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/586?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: Ia08a9697d0ff41721fb0acf17ccb4cfa23cb3934 Gerrit-Change-Number: 586 Gerrit-PatchSet: 2 Gerrit-Owner: plaisthos Gerrit-Reviewer: cron2 Gerrit-Reviewer: flichtenheld Gerrit-CC: openvpn-devel Gerrit-MessageType: newpatchset --TyD3d3AhXYQ= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

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

View Change

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

Workaround issue in LibreSSL crashing when enumerati=
ng digests/ciphers

OpenBSD/LibreSSL reimplemented EVP_get_cipherbyna= me/EVP_get_digestbyname
and broke calling EVP_get_cipherbynid/EVP_get_di= gestbyname with an
invalid nid in the process so that it would segfault.=

Workaround but doing that NULL check in OpenVPN instead of leaving = it
to the library.

Github: see also https://github.com/libressl/o= penbsd/issues/150

Change-Id: Ia08a9697d0ff41721fb0acf17ccb4cfa23cb39= 34
Signed-off-by: Arne Schwabe <arne@...1227...>
Acked-by: Gert= Doering <gert@...1296...>
Message-Id: <20240508220540.12554-1-= gert@...1296...>
URL: https://www.mail-archive.com/openvpn-devel@...1514...= s.sourceforge.net/msg28649.html
Signed-off-by: Gert Doering <gert@...493...= 1296...>
---
M src/openvpn/crypto_openssl.c
1 file changed, 25 = insertions(+), 1 deletion(-)

git pull ssh://gerrit.openvpn.net:29=
418/openvpn refs/changes/86/586/2
diff --git a/src/openvpn/crypto_o=
penssl.c b/src/openvpn/crypto_openssl.c
index 61c6518..1649= ab7 100644
--- a/src/openvpn/crypto_openssl.c
+++ b/src/openvpn/crypto_openssl.c
@@ -387,7 +387,19 @@<= /span>
#else
for (int nid =3D 0; nid < 10= 000; ++nid)
{
+#if defined(LIBRESSL_VERSION_NUMBER)
+ /* OpenBSD/LibreSSL reimplemented= EVP_get_cipherbyname and broke
+ * calling EVP_get_cipherbynid with an invalid nid in t= he process
+ = * so that it would segfault. */
+ const EVP_CIPHER *cipher =3D NULL;
+ const char *name =3D OBJ_nid2sn(= nid);
+ if (na= me)
+ {=
+ cipher =3D EVP= _get_cipherbyname(name);
+ }
+#else= /* if defined(LIBRESSL_VERSION_NUMBER) */
const = EVP_CIPHER *cipher =3D EVP_get_cipherbynid(nid);
+#endif
/* We cast the= const away so we can keep the function prototype
= * compatible with EVP_CIPHER_do_all_provided */
c= ollect_ciphers((EVP_CIPHER *) cipher, &cipher_list);
@@= -441,7 +453,19 @@
#else
for (int nid= =3D 0; nid < 10000; ++nid)
{
+ /* OpenBSD/LibreSSL reimplemented= EVP_get_digestbyname and broke
+ * calling EVP_get_digestbynid with an invalid nid in t= he process
+ = * so that it would segfault. */
+#ifdef LIBRESSL_VERSION_NUMBER
+ const EVP_MD *digest =3D NULL;
+ const char *name =3D OBJ_= nid2sn(nid);

+ = if (name)
+ {=
+ digest = =3D EVP_get_digestbyname(name);
+ }
+#else /* ifdef LIBRESSL_VERSION_NUMBER */
const= EVP_MD *digest =3D EVP_get_digestbynid(nid);
+#endif
if (digest)
{
/* We cast the const awa= y so we can keep the function prototype
@@ -449,7 +473,7 @@=
print_digest((EVP_MD *)digest, NULL);<= br> }
}
-#endif
+#endif /* if OPENSSL_VERSION_NUMBER >=3D 0x30000000L */ printf("\n");
}


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

<= /div>
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ia08a9697d0ff41721fb0acf17cc= b4cfa23cb3934
Gerrit-Change-Number: 586
Gerrit-PatchSet: 2
Gerrit-Owner: plaisthos <arne-openvpn@...1711...= 27...>
Gerrit-Reviewer: cron2 <gert@...1296...>=
Gerrit-Reviewer: flichtenheld <frank@...2716...= 1...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-MessageType: newpatchset
--TyD3d3AhXYQ=--