From patchwork Mon Oct 26 11:03:24 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Lichtenheld X-Patchwork-Id: 5503 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7000:ea99:b0:8dc:5c83:a4ec with SMTP id ov25csp2563707mab; Mon, 26 Oct 2026 04:03:55 -0700 (PDT) X-Forwarded-Encrypted: i=2; AKwUvBxIUM0pJHih/i1x/mPJVFjOdGsAv05l0NNz3cF8L6WH4ApTdtwB91Wn16AUtOBSdRGS13Sc3uV5T8Y=@openvpn.net X-Received: by 2002:a05:6820:1629:b0:708:b419:4881 with SMTP id 006d021491bc7-70ba0e37350mr3155704eaf.44.1793012635317; Mon, 26 Oct 2026 04:03:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1793012635; cv=none; d=google.com; s=arc-20260327; b=kbzRHyRPuUT1qBTF00Vmzh721tjK59wg04fw2HQ4pxhBAr5kRwWOYTWJ9RkiXhPa6Z q23WntMIlNrwqkFFS5ZLEuDsHWdZt+KbVujThW3s5nPNGQPJYib05Q8TX5Ter8qMvCCE Q55yC6GaCbjMBD5WIH1juV1c3nWZVNQmbR5w+McsqR8Ut/0jeC1HlmeCBjlC3wF9oLsr ZhcFri2nkNW1dH3McW4U5PPP8iiKtivy7ctZ68Mb1m8VnoIKkHH9524ps1nc2i41mrwF fxcQE+aPIYUKUisV9va2tkwexkXKim6Wk+m91LhIdvVsWc1NnRC7LwOzWxLTUNmXdgUj t/qQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=errors-to:content-transfer-encoding:cc:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :dkim-signature:dkim-signature:dkim-signature:dkim-signature; bh=eg7bQJA99BiMSkDAAkyAjAr4mp/pTEtqGYxduaNJBtk=; fh=t1poTxOwxrfPRAdordRDObzcjwONfS2rkQhMn7jOoNM=; b=bf0A0pbR9KPdLJvSCxAPqUMjEF7dqZLKNC0jpPR0vtnwH37NNNgaBFM6oXvtzzv8+B tSMjg6jlKxDXky5RBpYW2SWMA4aIz4GiDMzhFglMD57rfbTTTjm1HKe7sbhQUfMuUoAM 5wExFIRgNnZtMWWYDy0glji9K+JqZVUzp1nRHBlHwRbdH+fiOHWjd3bFIPmqJkTLESoP 7PHDSHavTKCYwD5tBIemjxleua0qR4JRCbECIco5VJllRDODFGFqF57i44v8cIDOJjfn r6R8IxFsswIcVQDnUeKMx20/lvndRqjY5t/RDKx7EFVWFciD8acKiGxV6szHsZbxSdqv lMJg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b=lQv6ADX1; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=Y2M5D1Un; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=hoKzD8LV; dkim=neutral (body hash did not verify) header.i=@lichtenheld.com header.s=MBO0001 header.b=lCfXMkSs; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7]) by mx.google.com with ESMTPS id 46e09a7af769-850fcaba03csi10877623a34.113.2026.10.26.04.03.53 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 26 Oct 2026 04:03:55 -0700 (PDT) Received-SPF: pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) client-ip=216.105.38.7; Authentication-Results: mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b=lQv6ADX1; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=Y2M5D1Un; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=hoKzD8LV; dkim=neutral (body hash did not verify) header.i=@lichtenheld.com header.s=MBO0001 header.b=lCfXMkSs; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.sourceforge.net; s=beta; h=Content-Transfer-Encoding:Content-Type:Cc: List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: Subject:MIME-Version:References:In-Reply-To:Message-ID:Date:To:From:Sender: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:List-Unsubscribe-Post:List-Owner; bh=eg7bQJA99BiMSkDAAkyAjAr4mp/pTEtqGYxduaNJBtk=; b=lQv6ADX1c9ZzA5arrHajq6/6ru zV2zzHAObH/9kz2PvEMXljTn5IpDCVWrQjaugNa50Ev9UEIM3V3ptcTy3QTZ8L+AoUj+B/gTn0ZdD m62exmqcQ3sgEEhxdQZtQLe1No4ouGv6+TICiGJHEmACz9rfomhMPQRMqz7Vs2d0RX64=; Received: from [127.0.0.1] (helo=sfs-ml-2.v29.lw.sourceforge.com) by sfs-ml-2.v29.lw.sourceforge.com with esmtp (Exim 4.100.1) (envelope-from ) id 1xLIUZ-000000004kF-3ZHU; Mon, 26 Oct 2026 11:03:51 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.100.1) (envelope-from ) id 1xLIUI-000000004im-3Hws for openvpn-devel@lists.sourceforge.net; Mon, 26 Oct 2026 11:03:34 +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: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:List-Id:List-Help:List-Unsubscribe: List-Unsubscribe-Post:List-Subscribe:List-Post:List-Owner:List-Archive; bh=GCuG0OOrwnSq57I5WzrFBJjTtfKnU1zGl1Wgk/WmW0M=; b=Y2M5D1UnHnVQWE8+TQyPrz8Znw eJcFvEMwgE5j0Cwqfdt0HD8dEHryGETRTpIfjaGkWdcR5J+nemt4Ai+axyq6XAlbZNpNIA7pdfu3W nVVWtoy6hf25ZmM0UAsmoGGEMnHwOG2EsNJSEjDOOtBMYmICJnGV7jfaybXlvveOsEY8=; 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: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:List-Id:List-Help:List-Unsubscribe:List-Unsubscribe-Post: List-Subscribe:List-Post:List-Owner:List-Archive; bh=GCuG0OOrwnSq57I5WzrFBJjTtfKnU1zGl1Wgk/WmW0M=; b=hoKzD8LV1N5YmrAuWf4CXHp9/c H9lJNFdTGvOZ2yMhv6RdbZ8uCW7vB4STfhBwxDFDdt/tv2kIDabguBGPfIU5u9cz+mKMNTLxf7ykd TK4CFi/GV7j4R/LIMGOkWcdsAxO1eVviWBsTwpt7KpY6b3ft83gPdxAGP7GZEbgqomLU=; Received: from mout-p-101.mailbox.org ([80.241.56.151]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.100.1) id 1xLIUH-000000006gP-1HDy for openvpn-devel@lists.sourceforge.net; Mon, 26 Oct 2026 11:03:34 +0000 Received: from smtp1.mailbox.org (smtp1.mailbox.org [IPv6:2001:67c:2050:b231:465::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519MLKEM768 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-101.mailbox.org (Postfix) with ESMTPS id 4jCrMd1ppcz8tdk; Mon, 26 Oct 2026 12:03:25 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lichtenheld.com; s=MBO0001; t=1793012605; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GCuG0OOrwnSq57I5WzrFBJjTtfKnU1zGl1Wgk/WmW0M=; b=lCfXMkSseGCIV3g5Ek/tWSp4G2FCMK1DNrGETNhOJXtDyR+6mhJSEA4rOcLxxbtfrY8S5P XoXkgGNxAYu8VIqjpJfaotRI3+vNCFq1ebdB23sxRvukNjZO9iFzNwjCXrcA/Ma/olZyuI PdCags9W2NXwDmEGDdiv2ILV3GS9ukjLZ/ijQsX8+IJeo5silatUuStKK/Y7zH8IUSlbrI nz+0+d57EbiJBbRzR5Kt4tRRlAjLy71H7zit3ecrB5yowj20I+L1OqX3iO6bzoPlDkKn9j Cjf/QHhCBqB5qoj0K3XmJ2aun2hY7Nwh9tQ6Xo8tWxgsyWTIKVpxGRpPrHDx4g== Authentication-Results: outgoing_mbo_mout; dkim=none; spf=pass (outgoing_mbo_mout: domain of frank@lichtenheld.com designates 2001:67c:2050:b231:465::1 as permitted sender) smtp.mailfrom=frank@lichtenheld.com From: Frank Lichtenheld To: openvpn-devel@lists.sourceforge.net Date: Mon, 26 Oct 2026 12:03:24 +0100 Message-ID: <20261026110324.55339-1-frank@lichtenheld.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-Rspamd-Queue-Id: 4jCrMd1ppcz8tdk X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "sfi-spamd-1.hosts.colo.sdot.me", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Antonio Quartulli multi_hash_sid_add() takes a reference on the multi_instance, but multi_close_instance() only drops it via multi_hash_sid_remove() when not shutting down. On shutdown hash_free() then frees the table [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-Headers-End: 1xLIUH-000000006gP-1HDy Subject: [Openvpn-devel] [PATCH v1] multi: release the session-id hash reference on shutdown 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: , Cc: Antonio Quartulli , Arne Schwabe Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox X-GMAIL-THRID: 1880110016917124577 X-GMAIL-MSGID: 1880110016917124577 From: Antonio Quartulli multi_hash_sid_add() takes a reference on the multi_instance, but multi_close_instance() only drops it via multi_hash_sid_remove() when not shutting down. On shutdown hash_free() then frees the table without releasing the reference, so every instance still connected when the server stops is leaked (reported by LeakSanitizer, which also turns the exit code into 1). Remove the instance from the session-id hash regardless of shutdown. Unlike the other tables handled in that block, this one holds a reference. Fixes: 66f8cdb9 ("Add lookup of multi session by session id") Change-Id: I62d95dad21891351a16cd6be43063406a024acee Signed-off-by: Antonio Quartulli Acked-by: Arne Schwabe Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/2032 --- This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master. Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/2032 This mail reflects revision 1 of this Change. Acked-by according to Gerrit (reflected above): Arne Schwabe diff --git a/src/openvpn/multi.c b/src/openvpn/multi.c index e302a81..813b79c 100644 --- a/src/openvpn/multi.c +++ b/src/openvpn/multi.c @@ -584,6 +584,13 @@ m->earliest_wakeup = NULL; } + /* The sid hash holds a reference on the instance: drop it on shutdown + * too, otherwise the instance is never freed */ + if (session_id_defined(&mi->sid_hashed_value)) + { + multi_hash_sid_remove(m, &mi->sid_hashed_value); + } + if (!shutdown) { if (mi->did_real_hash) @@ -605,12 +612,6 @@ } #endif - - if (session_id_defined(&mi->sid_hashed_value)) - { - multi_hash_sid_remove(m, &mi->sid_hashed_value); - } - if (mi->context.c2.tls_multi->rx_peer_id != MAX_PEER_ID) { m->instances[mi->context.c2.tls_multi->rx_peer_id] = NULL;