From patchwork Thu Nov 19 13:08:26 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gert Doering X-Patchwork-Id: 5750 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:6022:b1c3:10b0:11b:d6c:f273 with SMTP id i3-n1csp1557514laq; Thu, 19 Nov 2026 05:08:43 -0800 (PST) X-Forwarded-Encrypted: i=2; AL+hErFdkefMj9D+R6sTMH9hLttV0665df4AK0EZow00PceIzRXqC67xtACCY69Nig18BcMWW5JfEhI+JZE=@openvpn.net X-Received: by 2002:a05:7301:d817:b0:384:fe97:8ccc with SMTP id 5a478bee46e88-384fe9792d8mr452229eec.29.1795093723029; Thu, 19 Nov 2026 05:08:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1795093723; cv=none; d=google.com; s=arc-20260327; b=L+hq1iZg9AupWiLWznPvHCEN+zW3r5MUq3teFWAMnpB6oJTX3QE5RC2WkuuQ6ub7Fy i1GOH//AF0rg78K3nxriFyRvKnv1rtzfYtZe/Wlnr/kGlEVJj3AQ1HcKZ+OY3VOOE+2e aU8qyH3INQ5c7ySpvI0nRxlDCZw6/LpiilNTIEtWQ5sX3CoGVxti7ShfpLIZW0DyW1NL se8ehR68G4JRHckIX/L5Zb9HzK9tK78g3ZGEMHYzhgeAPZO98st0rCgrQvB1F+DZK85Y v/zhMFob9MhgS68i+ueUKQyuq6GCZQ0t2LIgItnRSTNUNzyYAdkTaVVkOYz8v1X7043W o2Cw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=errors-to:content-transfer-encoding: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; bh=n5BJ3KsLf96Q/pPCnTP/YBRF7r0iULf6023Y5UXZ9uM=; fh=4NbAC/LsuMLI0S0hprUlLSLCiHwg6SCAifhH718Jh0Q=; b=JwQIn4IL5yPseX5MINcIRu1GOS48Xvr1GdR+eHrihv2zv+fQIvTHvbLC5ocdHasUtR XwQ17QvsItv5ke7e57tT0TrtovX6WF31kAC3aRIr2GZqx251zUIjJBzDkyEWrsxmfCZF 6Yk8DDOieXKNxy+GYqeD9XIoOMsRssMn6aan779/YGYKqqF+iAzr2y50KHOf3shiHwJy HlRriGE5xbWMuAJ7tZD9/xVicL09t8cB2Tzc+BVs43wvPqpeZOx09zPz8P6/e6hxPNc+ BE6olrel2aFtJ4yoQo2y2pKCJerTjT8zzmJIxuN+u4ux3p4N8+AOXyHQEdfXUZtzH5Tc hAtQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b=lPKXYYQH; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=nObJSFOB; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=l96+gJPt; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=muc.de Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7]) by mx.google.com with ESMTPS id 5a478bee46e88-382a908c413si12407878eec.36.2026.11.19.05.08.42 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Nov 2026 05:08:43 -0800 (PST) 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=lPKXYYQH; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=nObJSFOB; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=l96+gJPt; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=muc.de 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: 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:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Unsubscribe-Post: List-Owner; bh=n5BJ3KsLf96Q/pPCnTP/YBRF7r0iULf6023Y5UXZ9uM=; b=lPKXYYQHrKJpX9 XRqsbl1OEtO2an1fWIfwIiBjyZe3pylI+FMMlOmTQrbjN/CAA6btrOsefutkBk7D7V8uhpHLBBbDe mfa4zF9c6baiEK3MByLjZZPNB3qJRjWK6b74a9TzocVDPe3x/+6fMFhJw8fo8FdvVFDW5HXxEwChC FHs=; 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 1xU1sX-000000008Ea-3CDS; Thu, 19 Nov 2026 13:08:41 +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 1xU1sW-000000008EO-0mYA for openvpn-devel@lists.sourceforge.net; Thu, 19 Nov 2026 13:08:40 +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-Unsubscribe-Post:List-Subscribe:List-Post:List-Owner:List-Archive; bh=EAWEvdj6hbUg3onAhqfICnjRQoLcp6ADZjZmY/64n4c=; b=nObJSFOBDm4dkynMNfCd6ba4Zl KIjblSp8B0h3ddd9LeMaLi4WjipLaKEjTZFCWsMp/inomMpqw4gc4trJRt7D25kTQlMIvAsYhgfkN JHQ5c+/MVXDh8WQG3Q/8vZ8wc0MR01L1AaNV25oZ9JuleTN88wwvBcvCiH/EEuUGwx8g=; 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-Unsubscribe-Post: List-Subscribe:List-Post:List-Owner:List-Archive; bh=EAWEvdj6hbUg3onAhqfICnjRQoLcp6ADZjZmY/64n4c=; b=l96+gJPtCXuAULLQtquLg4KHnx Zb3DnaVF/elL94ZQ7azav0oCkOh7aC9HxZX41LrMkgd8e85qtAq/Nx0ZPu9fSKxQynsfqDMvk/k2J kWweEg/ddOGX6KJtNIZf4T8kNPpRKrhLRM8/eaGdFmd5L0KoF118JpPiEpY96fTcMVf8=; Received: from [193.149.48.129] (helo=blue.greenie.muc.de) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.100.1) id 1xU1sV-0000000018n-1GKZ for openvpn-devel@lists.sourceforge.net; Thu, 19 Nov 2026 13:08:40 +0000 Received: from blue.greenie.muc.de (localhost [127.0.0.1]) by blue.greenie.muc.de (8.18.1/8.18.1) with ESMTP id 6AJD8WDH020815 for ; Thu, 19 Nov 2026 14:08:32 +0100 Received: (from gert@localhost) by blue.greenie.muc.de (8.18.2/8.18.1/Submit) id 6AJD8WhF020814 for openvpn-devel@lists.sourceforge.net; Thu, 19 Nov 2026 14:08:32 +0100 From: Gert Doering To: openvpn-devel@lists.sourceforge.net Date: Thu, 19 Nov 2026 14:08:26 +0100 Message-ID: <20261119130832.20797-1-gert@greenie.muc.de> X-Mailer: git-send-email 2.55.0 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Score: 1.3 (+) 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 On a restart init_instance() registers the management callbacks before the restart pause, while c2.tls_multi is still NULL: close_instance() freed it and do_init_crypto_tls() has not created the new o [...] Content analysis details: (1.3 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 1.3 RDNS_NONE Delivered to internal network by a host with no rDNS X-Headers-End: 1xU1sV-0000000018n-1GKZ Subject: [Openvpn-devel] [PATCH v1] dco: don't access tls_multi in dco_get_peer_stats() during a restart 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 X-GMAIL-THRID: 1882292195502152072 X-GMAIL-MSGID: 1882292195502152072 From: Antonio Quartulli On a restart init_instance() registers the management callbacks before the restart pause, while c2.tls_multi is still NULL: close_instance() freed it and do_init_crypto_tls() has not created the new one yet. A management "status" command during the pause therefore calls dco_get_peer_stats() without a tls_multi. With --persist-tun the DCO interface survives the restart, so the Linux and Windows implementations get past their interface checks and dereference the NULL tls_multi; FreeBSD hits ASSERT(c->c2.tls_multi) even without --persist-tun. Either way openvpn dies. Return an error when there is no tls_multi, as when there is no DCO interface. Reproduced on Linux with a DCO client using --persist-tun: (echo 'signal SIGUSR1'; sleep 0.5; echo status; sleep 3) | nc 127.0.0.1 7505 segfaults in dco_get_peer_stats() during the restart pause. Gerrit change 2201 makes print_status() answer even when dco_get_peer_stats() fails; together with this change, "status" gets a reply during a reconnect instead of hanging or crashing. Related: https://gerrit.openvpn.net/c/openvpn/+/2201 Change-Id: I2088345f10a630241fbddde68336ea7c1f7b449d Signed-off-by: Antonio Quartulli Acked-by: Lev Stipakov Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/2204 --- 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/+/2204 This mail reflects revision 1 of this Change. Acked-by according to Gerrit (reflected above): Lev Stipakov diff --git a/src/openvpn/dco_freebsd.c b/src/openvpn/dco_freebsd.c index 11b8dff..6701d21 100644 --- a/src/openvpn/dco_freebsd.c +++ b/src/openvpn/dco_freebsd.c @@ -916,7 +916,11 @@ int dco_get_peer_stats(struct context *c, const bool raise_sigusr1_on_err) { - ASSERT(c->c2.tls_multi); + /* tls_multi is NULL during a restart */ + if (!c->c2.tls_multi) + { + return -EINVAL; + } msg(D_DCO_DEBUG, "%s: peer-id %d", __func__, c->c2.tls_multi->dco_peer_id); if (c->c2.tls_multi->dco_peer_id < 0) diff --git a/src/openvpn/dco_linux.c b/src/openvpn/dco_linux.c index 3a55b6e..befad61 100644 --- a/src/openvpn/dco_linux.c +++ b/src/openvpn/dco_linux.c @@ -1280,7 +1280,8 @@ int dco_get_peer_stats(struct context *c, const bool raise_sigusr1_on_err) { - if (!c->c1.tuntap || c->c1.tuntap->dco.ifindex == 0) + /* tls_multi is NULL during a restart, while a persisted tun is still around */ + if (!c->c1.tuntap || c->c1.tuntap->dco.ifindex == 0 || !c->c2.tls_multi) { return -1; } diff --git a/src/openvpn/dco_win.c b/src/openvpn/dco_win.c index a854045..eff4d33 100644 --- a/src/openvpn/dco_win.c +++ b/src/openvpn/dco_win.c @@ -898,7 +898,8 @@ { const struct tuntap *tt = c->c1.tuntap; - if (!tuntap_defined(tt)) + /* tls_multi is NULL during a restart, while a persisted tun is still around */ + if (!tuntap_defined(tt) || !c->c2.tls_multi) { return -1; }