[Openvpn-devel] mbedtls: fix segfault by calling mbedtls_cipher_free() in cipher_ctx_free()
| Message ID | 20190816204945.7937-1-a@unstable.cc |
|---|---|
| State | Accepted |
| Headers |
Return-Path: <openvpn-devel-bounces@lists.sourceforge.net> Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director11.mail.ord1d.rsapps.net ([172.31.255.6]) by backend30.mail.ord1d.rsapps.net with LMTP id EMNiFZ4XV13jKwAAIUCqbw for <patchwork@openvpn.net>; Fri, 16 Aug 2019 16:52:46 -0400 Received: from proxy17.mail.iad3b.rsapps.net ([172.31.255.6]) by director11.mail.ord1d.rsapps.net with LMTP id 4HSsEp4XV12TaQAAvGGmqA ; Fri, 16 Aug 2019 16:52:46 -0400 Received: from smtp32.gate.iad3b ([172.31.255.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy17.mail.iad3b.rsapps.net with LMTP id oFTlDJ4XV11KHwAA5ccGVQ ; Fri, 16 Aug 2019 16:52:46 -0400 X-Spam-Threshold: 95 X-Spam-Score: 0 X-Spam-Flag: NO X-Virus-Scanned: OK X-Orig-To: openvpnslackdevel@openvpn.net X-Originating-Ip: [216.105.38.7] Authentication-Results: smtp32.gate.iad3b.rsapps.net; iprev=pass policy.iprev="216.105.38.7"; spf=pass smtp.mailfrom="openvpn-devel-bounces@lists.sourceforge.net" smtp.helo="lists.sourceforge.net"; dkim=fail (signature verification failed) header.d=sourceforge.net; dkim=fail (signature verification failed) header.d=sf.net; dmarc=none (p=nil; dis=none) header.from=unstable.cc X-Suspicious-Flag: YES X-Classification-ID: cc2bfaf4-c067-11e9-a9a3-5254006a2e70-1-1 Received: from [216.105.38.7] ([216.105.38.7:47078] helo=lists.sourceforge.net) by smtp32.gate.iad3b.rsapps.net (envelope-from <openvpn-devel-bounces@lists.sourceforge.net>) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id 5C/55-08644-D97175D5; Fri, 16 Aug 2019 16:52:45 -0400 Received: from [127.0.0.1] (helo=sfs-ml-4.v29.lw.sourceforge.com) by sfs-ml-4.v29.lw.sourceforge.com with esmtp (Exim 4.90_1) (envelope-from <openvpn-devel-bounces@lists.sourceforge.net>) id 1hyjCa-00065O-Cf; Fri, 16 Aug 2019 20:52:00 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from <a@unstable.cc>) id 1hyjCZ-00065H-1y for openvpn-devel@lists.sourceforge.net; Fri, 16 Aug 2019 20:51:59 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=QNFkZps9TuqrSn3y87IN73uPVezJji2s9X11luu3zMk=; b=bYXHExgE6w0G/RtsOT5WG1HdXC F9OXrKY3mZTzM3tVLrdYjYIPzr5lkLDqaSSgjx4wLKtdFMGm2tHHwQws6U40yarC2/aRKcHenCHW8 ZYn7ohQS6krrFO8O88hRf4w9qFQeyHlK3om6oz7WsqTgN7kxcQzrIz9v2WU+SA0hHWYw=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:Message-Id:Date:Subject:Cc:To:From :Sender:Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post: List-Owner:List-Archive; bh=QNFkZps9TuqrSn3y87IN73uPVezJji2s9X11luu3zMk=; b=X PgE0ZOVO78Vke/fCd9qUUQRPaCUuArcjyCja5LE9pWwz3gvRjVM98myWMZvF/V3P54dryokBHJnAB MNBxsvHRE1u1exYinZA6CBbt2ySWUrOIk1ut9HVR1CyqkwYdFPkjuvU9rJxlImjAaldgDcaG+bMun 5OY1yJ09ENqnsptY=; Received: from s2.neomailbox.net ([5.148.176.60]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLSv1.2:DHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) id 1hyjCU-008mUd-8v for openvpn-devel@lists.sourceforge.net; Fri, 16 Aug 2019 20:51:58 +0000 From: Antonio Quartulli <a@unstable.cc> To: openvpn-devel@lists.sourceforge.net Date: Fri, 16 Aug 2019 22:49:45 +0200 Message-Id: <20190816204945.7937-1-a@unstable.cc> MIME-Version: 1.0 X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [5.148.176.60 listed in list.dnswl.org] 0.0 URIBL_BLOCKED ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [URIs: unstable.cc] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 AWL AWL: Adjusted score from AWL reputation of From: address X-Headers-End: 1hyjCU-008mUd-8v Subject: [Openvpn-devel] [PATCH] mbedtls: fix segfault by calling mbedtls_cipher_free() in cipher_ctx_free() X-BeenThere: openvpn-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: <openvpn-devel.lists.sourceforge.net> List-Unsubscribe: <https://lists.sourceforge.net/lists/options/openvpn-devel>, <mailto:openvpn-devel-request@lists.sourceforge.net?subject=unsubscribe> List-Archive: <http://sourceforge.net/mailarchive/forum.php?forum_name=openvpn-devel> List-Post: <mailto:openvpn-devel@lists.sourceforge.net> List-Help: <mailto:openvpn-devel-request@lists.sourceforge.net?subject=help> List-Subscribe: <https://lists.sourceforge.net/lists/listinfo/openvpn-devel>, <mailto:openvpn-devel-request@lists.sourceforge.net?subject=subscribe> Cc: Antonio Quartulli <a@unstable.cc> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox |
| Series |
[Openvpn-devel] mbedtls: fix segfault by calling mbedtls_cipher_free() in cipher_ctx_free()
|
|
Commit Message
Antonio Quartulli
Aug. 16, 2019, 10:49 a.m. UTC
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().
Signed-off-by: Antonio Quartulli <a@unstable.cc>
---
src/openvpn/crypto_mbedtls.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
Hi, On Fri, Aug 16, 2019 at 10:49:45PM +0200, Antonio Quartulli wrote: > 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(). 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
Am 17.08.2019 um 08:48 schrieb Gert Doering: > Hi, > > On Fri, Aug 16, 2019 at 10:49:45PM +0200, Antonio Quartulli wrote: >> 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(). > 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. Yeah, sorry that looks like a very stupid mistake from my side :( Acked-By: Arne Schwabe <arne@rfc2549.org>
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 <a@unstable.cc>
Acked-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20190816204945.7937-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg18781.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
--
kind regards,
Gert Doering
diff --git a/src/openvpn/crypto_mbedtls.c b/src/openvpn/crypto_mbedtls.c index f924323d..648a988e 100644 --- a/src/openvpn/crypto_mbedtls.c +++ b/src/openvpn/crypto_mbedtls.c @@ -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); }