From patchwork Mon Mar 8 03:21:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arne Schwabe X-Patchwork-Id: 1611 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director13.mail.ord1d.rsapps.net ([172.30.191.6]) by backend30.mail.ord1d.rsapps.net with LMTP id SJHsOR4zRmDIBAAAIUCqbw (envelope-from ) for ; Mon, 08 Mar 2021 09:22:22 -0500 Received: from proxy3.mail.ord1d.rsapps.net ([172.30.191.6]) by director13.mail.ord1d.rsapps.net with LMTP id iCPFOR4zRmDQVAAA91zNiA (envelope-from ) for ; Mon, 08 Mar 2021 09:22:22 -0500 Received: from smtp5.gate.ord1d ([172.30.191.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy3.mail.ord1d.rsapps.net with LMTPS id IFhJOR4zRmCKAQAA7WKfLA (envelope-from ) for ; Mon, 08 Mar 2021 09:22:22 -0500 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: smtp5.gate.ord1d.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=rfc2549.org X-Suspicious-Flag: YES X-Classification-ID: b206a214-8019-11eb-bfc9-525400d73c44-1-1 Received: from [216.105.38.7] ([216.105.38.7:45540] helo=lists.sourceforge.net) by smtp5.gate.ord1d.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id 6C/1C-11705-D1336406; Mon, 08 Mar 2021 09:22:22 -0500 Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.90_1) (envelope-from ) id 1lJGlH-0005bU-Oi; Mon, 08 Mar 2021 14:21:31 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lJGlF-0005b4-Op for openvpn-devel@lists.sourceforge.net; Mon, 08 Mar 2021 14:21:29 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc: MIME-Version:Content-Type:Content-Transfer-Encoding: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=L5cgdPRmLamm6SOBbs3i1HFFZrsJrllXXimuRt5zFTQ=; b=fD3yVDJ5e004jZLIdtFIldxda7 5lUmdxanb7xS5kOMUs7cgrSSBtoltRwEawkp8qDJEAx3tzOimY6ctUmMh37ycBXT5sjuY3t/Txvjz 3IyGUjDmELPqp4AZAevrVF5MP9gUnytPW0UT8zOcZHPCFR1xb9Q7ULzhZrlZg+sl4BYs=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc:MIME-Version: Content-Type:Content-Transfer-Encoding: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=L5cgdPRmLamm6SOBbs3i1HFFZrsJrllXXimuRt5zFTQ=; b=IfT2U4H+FjXIf1xydcmvS+SA+2 8Sct3H0MxJOK1TupAH2TViy8yb6jUR/BY+wio1b7CTu2XRexHxYog6WuGlBfcl4FNAflawJZE0pz3 ztt3QSsl30GfhXyGeA3ibQO0GD+aSb47aaXi6M2L7FR8S7WhXah0M5N+7ruhn+Yq1GX8=; Received: from mail.blinkt.de ([192.26.174.232]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.2) id 1lJGl6-001CQw-D8 for openvpn-devel@lists.sourceforge.net; Mon, 08 Mar 2021 14:21:29 +0000 Received: from kamera.blinkt.de ([2001:638:502:390:20c:29ff:fec8:535c]) by mail.blinkt.de with smtp (Exim 4.94 (FreeBSD)) (envelope-from ) id 1lJGkz-000BFf-5c for openvpn-devel@lists.sourceforge.net; Mon, 08 Mar 2021 15:21:13 +0100 Received: (nullmailer pid 24256 invoked by uid 10006); Mon, 08 Mar 2021 14:21:13 -0000 From: Arne Schwabe To: openvpn-devel@lists.sourceforge.net Date: Mon, 8 Mar 2021 15:21:13 +0100 Message-Id: <20210308142113.24208-1-arne@rfc2549.org> X-Mailer: git-send-email 2.17.1 X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. 0.2 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level mail domains are different 0.0 SPF_NONE SPF: sender does not publish an SPF Record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record X-Headers-End: 1lJGl6-001CQw-D8 Subject: [Openvpn-devel] [PATCH] Avoid a crash in mbed TLS 2.25 with --verb < 8 X-BeenThere: openvpn-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox mbed TLS 2.25 has a nasty bug that the print function for Montgomery style EC curves (Curve25519 and Curve448) does segfault. See also the issue reported here: https://github.com/ARMmbed/mbedtls/issues/4208 We request always debug level 3 from mbed TLS but filter out any debug output of level 3 unless verb 8 or higher is set. This commeit sets the debug level to 2 to avoid this problem by makeing mbed TLS not generatin the problematic debug output. For the affected version to still use --verb 8 with mbed TLS 2.25 is to restrict the EC groups to ones that do not crash the print function like with '--tls-groups secp521r1:secp384r1:secp256r1'. This patch has no patch on user-visible behaviour on unaffected mbed TLS versions. Signed-off-by: Arne Schwabe --- src/openvpn/options.c | 6 ++++++ src/openvpn/ssl_common.h | 1 + src/openvpn/ssl_mbedtls.c | 11 ++++++++++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/openvpn/options.c b/src/openvpn/options.c index 0eb049d8..6d908e15 100644 --- a/src/openvpn/options.c +++ b/src/openvpn/options.c @@ -5883,6 +5883,12 @@ add_option(struct options *options, { VERIFY_PERMISSION(OPT_P_MESSAGES); options->verbosity = positive_atoi(p[1]); + if (options->verbosity > 7) + { + /* We pass this flag to the SSL library to avoid a bug + * in mbed TLS 2.5.0 with high log level */ + options->ssl_flags |= SSLF_TLS_DEBUG_ENABLED; + } #if !defined(ENABLE_DEBUG) && !defined(ENABLE_SMALL) /* Warn when a debug verbosity is supplied when built without debug support */ if (options->verbosity >= 7) diff --git a/src/openvpn/ssl_common.h b/src/openvpn/ssl_common.h index bbb8135d..f821c654 100644 --- a/src/openvpn/ssl_common.h +++ b/src/openvpn/ssl_common.h @@ -350,6 +350,7 @@ struct tls_options #define SSLF_TLS_VERSION_MIN_MASK 0xF /* (uses bit positions 6 to 9) */ #define SSLF_TLS_VERSION_MAX_SHIFT 10 #define SSLF_TLS_VERSION_MAX_MASK 0xF /* (uses bit positions 10 to 13) */ +#define SSLF_TLS_DEBUG_ENABLED (1<<14) unsigned int ssl_flags; #ifdef ENABLE_MANAGEMENT diff --git a/src/openvpn/ssl_mbedtls.c b/src/openvpn/ssl_mbedtls.c index b30b6b9d..a7b6c2c6 100644 --- a/src/openvpn/ssl_mbedtls.c +++ b/src/openvpn/ssl_mbedtls.c @@ -1058,7 +1058,16 @@ key_state_ssl_init(struct key_state_ssl *ks_ssl, mbedtls_ssl_config_defaults(ks_ssl->ssl_config, ssl_ctx->endpoint, MBEDTLS_SSL_TRANSPORT_STREAM, MBEDTLS_SSL_PRESET_DEFAULT); #ifdef MBEDTLS_DEBUG_C - mbedtls_debug_set_threshold(3); + /* This works around a crash in mbed TLS 2.25 if Curve25591 is selected + * for DH (https://github.com/ARMmbed/mbedtls/issues/4208)*/ + if (session->opt->ssl_flags & SSLF_TLS_DEBUG_ENABLED) + { + mbedtls_debug_set_threshold(3); + } + else + { + mbedtls_debug_set_threshold(2); + } #endif mbedtls_ssl_conf_dbg(ks_ssl->ssl_config, my_debug, NULL); mbedtls_ssl_conf_rng(ks_ssl->ssl_config, mbedtls_ctr_drbg_random,