From patchwork Wed Jan 17 02:16:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steffan Karger X-Patchwork-Id: 195 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director6.mail.ord1d.rsapps.net ([172.30.191.6]) by backend31.mail.ord1d.rsapps.net (Dovecot) with LMTP id +xMXI+RMX1pHRwAAgoeIoA for ; Wed, 17 Jan 2018 08:17:24 -0500 Received: from proxy6.mail.ord1d.rsapps.net ([172.30.191.6]) by director6.mail.ord1d.rsapps.net (Dovecot) with LMTP id q1cAI+RMX1onHQAAhgvE6Q ; Wed, 17 Jan 2018 08:17:24 -0500 Received: from smtp14.gate.ord1d ([172.30.191.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy6.mail.ord1d.rsapps.net (Dovecot) with LMTP id cCNtB+RMX1ptPAAAQyIf0w ; Wed, 17 Jan 2018 08:17:24 -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.34.181.88] Authentication-Results: smtp14.gate.ord1d.rsapps.net; iprev=pass policy.iprev="216.34.181.88"; 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=fox-it.com X-Classification-ID: c1c376fa-fb88-11e7-8891-525400504bae-1-1 Received: from [216.34.181.88] ([216.34.181.88:44164] helo=lists.sourceforge.net) by smtp14.gate.ord1d.rsapps.net (envelope-from ) (ecelerity 4.2.1.56364 r(Core:4.2.1.14)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id 3A/4F-07747-4EC4F5A5; Wed, 17 Jan 2018 08:17:24 -0500 Received: from localhost ([127.0.0.1] helo=sfs-ml-1.v29.ch3.sourceforge.com) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.89) (envelope-from ) id 1ebnaD-0004Y1-OD; Wed, 17 Jan 2018 13:16:49 +0000 Received: from sfi-mx-2.v28.ch3.sourceforge.com ([172.29.28.192] helo=mx.sourceforge.net) by sfs-ml-1.v29.ch3.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89) (envelope-from ) id 1ebnaC-0004Xg-3j for openvpn-devel@lists.sourceforge.net; Wed, 17 Jan 2018 13:16:48 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Type:MIME-Version:Message-ID:Date:Subject: CC:To:From:Sender:Reply-To: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=MZ4BHBBqqbIU9ltBvDnOHMsKO+1cnG8P+jqe0nuOnpM=; b=D//x1NP7sh3IMrzX5KzMcw6Y8s CgtlMsN5iMkZwvQZONBAdIWz4/koGS3G3U8YME71uwvYpmO3pDQ1x/V99pcbVxh4oizNhMN6EwGp0 ZcfK4/DTRrhTshq+0iQeCFq1g1jxvkZFvrE6FnlpSm3dyfohEbwREWnjr6Gdqx0S3RpY=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Type:MIME-Version:Message-ID:Date:Subject:CC:To:From:Sender: Reply-To: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=MZ4BHBBqqbIU9ltBvDnOHMsKO+1cnG8P+jqe0nuOnpM=; b=G wisiX7XEP39KXRxYQSFm60JsmBpgYdc32/VIEjyX92deDAShkUSTLkMqPANNB3Dxpv7yNA1rsVDos u5Lqu3hSzP/NCW+YSV0bFmg5FfwsUbpnK8xZdQC+HHbgua0iSv1nx4B0mBMaAhHeDSzfL/y8tY/JY 7RHuLBwjTZ8EwO4s=; Received: from ns2.fox-it.com ([178.250.144.131]) by sfi-mx-2.v28.ch3.sourceforge.com with esmtps (TLSv1:ECDHE-RSA-AES256-SHA:256) (Exim 4.89) id 1ebnaB-0003ae-7A for openvpn-devel@lists.sourceforge.net; Wed, 17 Jan 2018 13:16:48 +0000 Received: from FOXDFT52.FOX.local (unknown [10.0.0.129]) by ns2.fox-it.com (Postfix) with ESMTPS id 1157D1AFA26 for ; Wed, 17 Jan 2018 14:16:41 +0100 (CET) Received: from steffan-fox.fox.local (10.0.3.167) by FOXDFT52.FOX.local (10.0.0.129) with Microsoft SMTP Server (TLS) id 15.0.1293.2; Wed, 17 Jan 2018 14:16:40 +0100 From: Steffan Karger To: Date: Wed, 17 Jan 2018 14:16:24 +0100 Message-ID: <1516194984-1540-1-git-send-email-steffan.karger@fox-it.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-ClientProxiedBy: FOXDFT52.FOX.local (10.0.0.129) To FOXDFT52.FOX.local (10.0.0.129) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -0.0 SPF_PASS SPF: sender matches SPF record -0.0 AWL AWL: Adjusted score from AWL reputation of From: address X-Headers-End: 1ebnaB-0003ae-7A Subject: [Openvpn-devel] [PATCH] Plug memory leak if push is interrupted 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: , Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox If a push is interrupted due to a timeout, c->c2.pulled_options_state is never freed. Fix that by always cleaning up any remaining pulled options state when we close a connection. This changes the mbedtls implementation of md_ctx_cleanup to actually clean up the context, which was not needed earlier. Signed-off-by: Steffan Karger --- src/openvpn/crypto_mbedtls.c | 1 + src/openvpn/init.c | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/src/openvpn/crypto_mbedtls.c b/src/openvpn/crypto_mbedtls.c index 8fa03da..8fc252f 100644 --- a/src/openvpn/crypto_mbedtls.c +++ b/src/openvpn/crypto_mbedtls.c @@ -804,6 +804,7 @@ md_ctx_init(mbedtls_md_context_t *ctx, const mbedtls_md_info_t *kt) void md_ctx_cleanup(mbedtls_md_context_t *ctx) { + mbedtls_md_free(ctx); } int diff --git a/src/openvpn/init.c b/src/openvpn/init.c index 30beadb..abf8da2 100644 --- a/src/openvpn/init.c +++ b/src/openvpn/init.c @@ -3384,6 +3384,12 @@ do_close_tls(struct context *c) } c->c2.options_string_local = c->c2.options_string_remote = NULL; #endif + + if (c->c2.pulled_options_state) + { + md_ctx_cleanup(c->c2.pulled_options_state); + md_ctx_free(c->c2.pulled_options_state); + } } /*