| Message ID | 20210512131511.1309914-5-arne@rfc2549.org |
|---|---|
| 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 YEkQKCrVm2CudQAAIUCqbw (envelope-from <openvpn-devel-bounces@lists.sourceforge.net>) for <patchwork@openvpn.net>; Wed, 12 May 2021 09:16:26 -0400 Received: from proxy7.mail.iad3b.rsapps.net ([172.31.255.6]) by director11.mail.ord1d.rsapps.net with LMTP id QNvBJyrVm2BEBQAAvGGmqA (envelope-from <openvpn-devel-bounces@lists.sourceforge.net>) for <patchwork@openvpn.net>; Wed, 12 May 2021 09:16:26 -0400 Received: from smtp31.gate.iad3b ([172.31.255.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy7.mail.iad3b.rsapps.net with LMTPS id UNUrIirVm2DHfAAAQkQ5tQ (envelope-from <openvpn-devel-bounces@lists.sourceforge.net>) for <patchwork@openvpn.net>; Wed, 12 May 2021 09:16:26 -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: smtp31.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=rfc2549.org X-Suspicious-Flag: YES X-Classification-ID: 40867d1a-b324-11eb-b8ec-52540005277f-1-1 Received: from [216.105.38.7] ([216.105.38.7:57028] helo=lists.sourceforge.net) by smtp31.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 86/8C-25173-925DB906; Wed, 12 May 2021 09:16:25 -0400 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 <openvpn-devel-bounces@lists.sourceforge.net>) id 1lgoi5-0006Xk-Jl; Wed, 12 May 2021 13:15:33 +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 <arne@kamera.blinkt.de>) id 1lgoi2-0006Wa-UZ for openvpn-devel@lists.sourceforge.net; Wed, 12 May 2021 13:15:30 +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:References: In-Reply-To:Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=//DcjDCYYW9nnE4QNQGWRfe/3dzols4U+8+HhB/eTZI=; b=lT/RhuLYkiQfYrgZcdT3YPmEO/ EmD9G2+7bvXGOne1EBv8vR8Xuaj20FsiGkl8rLEP/qMgG0zcGpKGHVCQ7GQQn//bobq8AfXAvvzcX 25zmsFtWbZAGx0RL0SM1W34w4efV2FUe8H+kd60DJJ8EOlPCSMf6YIcIImlhacoyPFjw=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id: Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=//DcjDCYYW9nnE4QNQGWRfe/3dzols4U+8+HhB/eTZI=; b=PgmxelJxy8MOQr04Vkmwq8FNV7 t+5ufVkUuCLyHygheVgUT8nkg+KAyeCjDJ2D7VuVg6Rx8Uqd7BWrbfPeF0yiMxyIPJs/oeKAe4rJG 5yqiXxlTT46gWJ2ezA4/Sle9j3pUsMgM7MqwJovXmu5e0LNhikLP2JQ0LOKAAdjpLZz8=; Received: from mail.blinkt.de ([192.26.174.232]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.3) id 1lgoht-0008VE-Uj for openvpn-devel@lists.sourceforge.net; Wed, 12 May 2021 13:15:30 +0000 Received: from kamera.blinkt.de ([2001:638:502:390:20c:29ff:fec8:535c]) by mail.blinkt.de with smtp (Exim 4.94.2 (FreeBSD)) (envelope-from <arne@kamera.blinkt.de>) id 1lgohj-000BzB-BC for openvpn-devel@lists.sourceforge.net; Wed, 12 May 2021 15:15:11 +0200 Received: (nullmailer pid 1309974 invoked by uid 10006); Wed, 12 May 2021 13:15:11 -0000 From: Arne Schwabe <arne@rfc2549.org> To: openvpn-devel@lists.sourceforge.net Date: Wed, 12 May 2021 15:15:06 +0200 Message-Id: <20210512131511.1309914-5-arne@rfc2549.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210512131511.1309914-1-arne@rfc2549.org> References: <20210512131511.1309914-1-arne@rfc2549.org> MIME-Version: 1.0 X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. 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: rfc2549.org] 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: 1lgoht-0008VE-Uj Subject: [Openvpn-devel] [PATCH 4/9] Add missing free_key_ctx for auth_token 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> 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 |
Miscellaneous cleanup patches/small fixes
|
|
Commit Message
Arne Schwabe
May 12, 2021, 3:15 a.m. UTC
This is is a small memory leak as this key is only leaked once
per server start.
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
---
src/openvpn/init.c | 1 +
1 file changed, 1 insertion(+)
Comments
Hi, On 12/05/2021 15:15, Arne Schwabe wrote: > This is is a small memory leak as this key is only leaked once > per server start. > > Signed-off-by: Arne Schwabe <arne@rfc2549.org> The leak can indeed be seen with valgrind when running the server with --auth-gen-token: ==23481== HEAP SUMMARY: ==23481== in use at exit: 536 bytes in 7 blocks ==23481== total heap usage: 7,460 allocs, 7,453 frees, 1,364,174 bytes allocated ==23481== ==23481== 536 (32 direct, 504 indirect) bytes in 1 blocks are definitely lost in loss record 7 of 7 ==23481== at 0x48397EF: malloc (vg_replace_malloc.c:307) ==23481== by 0x4AEB269: CRYPTO_zalloc (in /usr/lib64/libcrypto.so.1.1) ==23481== by 0x4AE4D67: HMAC_CTX_new (in /usr/lib64/libcrypto.so.1.1) ==23481== by 0x11F3A8: hmac_ctx_new (crypto_openssl.c:996) ==23481== by 0x119B84: init_key_ctx (crypto.c:847) ==23481== by 0x1135F6: auth_token_init_secret (auth_token.c:168) ==23481== by 0x12B117: do_init_auth_token_key (init.c:2685) ==23481== by 0x12B117: do_init_crypto_tls_c1 (init.c:2764) ==23481== by 0x12B117: do_init_crypto_tls (init.c:2802) ==23481== by 0x12FF07: do_init_crypto (init.c:3065) ==23481== by 0x12FF07: init_instance (init.c:4179) ==23481== by 0x130990: init_instance_handle_signals (init.c:3991) ==23481== by 0x140109: tunnel_server_udp (mudp.c:278) ==23481== by 0x14BD28: openvpn_main (openvpn.c:287) ==23481== by 0x4C69E39: (below main) (in /lib64/libc-2.32.so) ==23481== ==23481== LEAK SUMMARY: ==23481== definitely lost: 32 bytes in 1 blocks ==23481== indirectly lost: 504 bytes in 6 blocks ==23481== possibly lost: 0 bytes in 0 blocks ==23481== still reachable: 0 bytes in 0 blocks ==23481== suppressed: 0 bytes in 0 blocks And after applying the patch the leak is gone: ==27117== HEAP SUMMARY: ==27117== in use at exit: 0 bytes in 0 blocks ==27117== total heap usage: 7,447 allocs, 7,447 frees, 1,295,605 bytes allocated ==27117== ==27117== All heap blocks were freed -- no leaks are possible Acked-by: Antonio Quartulli <antonio@oppenvpn.net> Should this go to 2.5 too? Regards,
I won't claim to understand the lifetime of the various copies of
c1.ks.auth_token_key made by code in init.c (to "to.auth_token_key"
or "other contexts") - but it seems that these all are copying
c1.ks.ssl_ctx as well - and if that can be safely free()'ed, the
other one should be fine, too. I also checked that free_key_ctx()
is safe to be used should we have no auth_token_key at all.
Your patch has been applied to the master and release/2.5 branch.
release/2.4 does not have the offending code (no key-based tokens).
I have only compile-tested 2.5 and master ("it should be fine"),
but if not, the server-side test rig will find it later today...
commit fe39156a386bf0dbe79abe43717c84843830e3c0 (master)
commit 6471fd2ab1d07ad24c2c92e7fbda6bd645dd84c8 (release/2.5)
Author: Arne Schwabe
Date: Wed May 12 15:15:06 2021 +0200
Add missing free_key_ctx for auth_token
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <20210512131511.1309914-5-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg22345.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
--
kind regards,
Gert Doering
diff --git a/src/openvpn/init.c b/src/openvpn/init.c index 1d77a9d42..49c742928 100644 --- a/src/openvpn/init.c +++ b/src/openvpn/init.c @@ -2520,6 +2520,7 @@ key_schedule_free(struct key_schedule *ks, bool free_ssl_ctx) if (tls_ctx_initialised(&ks->ssl_ctx) && free_ssl_ctx) { tls_ctx_free(&ks->ssl_ctx); + free_key_ctx(&ks->auth_token_key); } CLEAR(*ks); }