mbedtls: fix segfault by calling mbedtls_cipher_free() in cipher_ctx_free()
PATCH 1/1 mbedtls: fix segfault by calling mbedtls_cipher_free() in cipher_ctx_free()
Commit ("openssl: Fix compilation without deprecated OpenSSL 1.1 APIs") has removed the cipher_ctx_cleanup() API, as it is not anymore required to be a distinct call. However, while doing so it also touched the mbedtls backend in a wrong way causing a systematic segfault upon connection.
Basically mbedtls_cipher_free(ctx) was moved from the defunct cipher_ctx_cleanup() to md_ctx_free(), while it was supposed to go into cipher_ctx_free(). This was clearly wrong as also the type of the ctx variable was not correct anymore.
Fix this mistake by actually moving mbedtls_cipher_free(ctx) to cipher_ctx_free().
--- src/openvpn/crypto_mbedtls.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
src/openvpn/crypto_mbedtls.c +1 -1
@@ -591,6 +591,7 @@ cipher_ctx_new(void)void cipher_ctx_free (mbedtls_cipher_context_t *ctx) { +mbedtls_cipher_free (ctx);free (ctx); }
@@ -855,7 +856,6 @@ md_ctx_new(void)void md_ctx_free (mbedtls_md_context_t *ctx) { -mbedtls_cipher_free (ctx);free (ctx); }
Signature · 1 line
2.22.1
Hi,
Quoted 5 lines · Antonio Quartulli
Commit ("openssl: Fix compilation without deprecated OpenSSL 1.1 APIs") has removed the
cipher_ctx_cleanup()API, as it is not anymore required to be a distinct call. However, while doing so it also touched the mbedtls backend in a wrong way causing a systematic segfault upon connection.
Quoted 7 lines
Basically
mbedtls_cipher_free(ctx)was moved from the defunctcipher_ctx_cleanup()tomd_ctx_free(), while it was supposed to go intocipher_ctx_free(). This was clearly wrong as also the type of the ctx variable was not correct anymore.Fix this mistake by actually moving
mbedtls_cipher_free(ctx)tocipher_ctx_free().
This looks reasonable, the explanation makes sense and it pacifies buildbot (gave this a test run on all the bots, and we're back to "t_client test 1 fails on ubuntu+fedora29", and no more crashes).
So I'm good with it, though I'd welcome a confirmation from Arne or Steffan.
gert
Signature · 6 lines
"If was one thing all people took for granted, was conviction that if you
feed honest figures into a computer, honest figures come out. Never doubted
it myself till I met a computer with a sense of humor."
Robert A. Heinlein, The Moon is a Harsh Mistress
Gert Doering - Munich, Germany [email protected]...Arne Schwabe
Acked-byAm 17.08.2019 um 08:48 schrieb Gert Doering:
Quoted 13 lines
Hi,
Quoted 10 lines · Antonio Quartulli
Commit ("openssl: Fix compilation without deprecated OpenSSL 1.1 APIs") has removed the
cipher_ctx_cleanup()API, as it is not anymore required to be a distinct call. However, while doing so it also touched the mbedtls backend in a wrong way causing a systematic segfault upon connection.Basically
mbedtls_cipher_free(ctx)was moved from the defunctcipher_ctx_cleanup()tomd_ctx_free(), while it was supposed to go intocipher_ctx_free(). This was clearly wrong as also the type of the ctx variable was not correct anymore.
Quoted 8 lines
Quoted 2 lines
Fix this mistake by actually moving
mbedtls_cipher_free(ctx)tocipher_ctx_free().This looks reasonable, the explanation makes sense and it pacifies buildbot (gave this a test run on all the bots, and we're back to "
t_clienttest 1 fails on ubuntu+fedora29", and no more crashes).So I'm good with it, though I'd welcome a confirmation from Arne or Steffan.
Yeah, sorry that looks like a very stupid mistake from my side :(
Your patch has been applied to the master branch.
As already written, the explanation makes sense, and it fully fixes the problems observed on the buildslaves -> so, another ACK from me.
Thanks for the quick investigation & fix.
commit 2a74fc3f66bb9f73fc957719d187256922ca003f
Author: Antonio Quartulli Date: Fri Aug 16 22:49:45 2019 +0200
mbedtls: fix segfault by calling mbedtls_cipher_free() in cipher_ctx_free()
Signed-off-by: Antonio Quartulli <[email protected]...>
Acked-by: Gert Doering <[email protected]...>
Acked-by: Arne Schwabe <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg18781.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering