From patchwork Tue Nov 17 18:21:14 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gert Doering X-Patchwork-Id: 5732 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:6022:9292:b0:11a:f58a:e788 with SMTP id dc18csp2923857lab; Tue, 17 Nov 2026 10:21:39 -0800 (PST) X-Forwarded-Encrypted: i=2; AL+hErEmQ72HSK8WMvZ1vQdwab7fl/0xod06fOL5QWUm8HPWX7QO7pJX//GXVNB60pELPxh4Dw9Hpc+rFiA=@openvpn.net X-Received: by 2002:a05:701b:2511:b0:1b2:6cba:7f48 with SMTP id a92af1059eb24-1b543c2e6d5mr337403c88.31.1794939699513; Tue, 17 Nov 2026 10:21:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1794939699; cv=none; d=google.com; s=arc-20260327; b=nD/+0aKz+UXHB1NHGtdMmBcx1Y/K/EMEdiquq7O7RzjQgTh9QM5mEaU1KGOe1zPv9O lT/oJHsj6dBrYVV28T9Sn7aMvOVH/OJ31XeM60mNQG3z6blkIFNVcfWw9ql23PLrnwvh hUe0iAijCZEIZqivGVYhEcec1Ftr1LMw39m3QiSDxY7ly2n0gtR80nVVWlAuAPvpbCg2 uAXXWlDzbQ0JChonCvmw5mO1Uf+Iexgmbnkj7192aFlI9ky9B0/e0DTxzu/TXIjQYnjd gJqzj0vGNQAd0IMA8sn6cKtExHE65X3qK41GXCCaYcetS7iRjGgIHhNzEBBXGrZolZTt fdAQ== 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=xqsI528vgip5+ahn+oLLfNRD2CfVFfAfNLHpHoUFzY4=; fh=4NbAC/LsuMLI0S0hprUlLSLCiHwg6SCAifhH718Jh0Q=; b=fXTj+8Bqinn54U7MSXDplphExnk6vX5+K/6g+YhJJUKLb/I1o4kAVwT1NFfI69RSnS dOlQ3rcZ3upb+HgjQKSi8YG6elpd8FEtLP79EfZwWNGn2bIunaXd3j1RjIQWcbrscx1p iSuTrxDTYsBjGutmW0ib410z+cHDRd7guPBz1fWbQId1EXB0nEMf9qGYi01A/P19Si4Y 8fACkEoMXEbyRCEa+C+ZxbiKAF837NQqivayLkhvgEw9AZ5cmzu7Hv06lysvfBJU3Ika AMpCvADS648+fl8IuG2ISNtQ21eOPqZ6PaQ2izrfgyWZPBqEfah0DfDxXJagDP0LtGN9 sgOA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b=ilt6AfvU; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=aamxhmHt; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=I4PvM10i; 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 a92af1059eb24-1b503218a4asi46236873c88.52.2026.11.17.10.21.39 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 Nov 2026 10:21:39 -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=ilt6AfvU; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=aamxhmHt; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=I4PvM10i; 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=xqsI528vgip5+ahn+oLLfNRD2CfVFfAfNLHpHoUFzY4=; b=ilt6AfvUJO0BPw SkjqNKFWHqSVvWXj+fUNGM6yJ9sy0vrqhGXjW5MJWoc36QJ31ZmW0uf39mmHG01bPS2/6/aWmImHL 0rIltLkDt4GGeBPqleeSWwnQ8JRUi0dMszOKUzleTTfcc1Qa7EbRw9/h21GQATCa4vRzQOj80PYBn oyc=; Received: from [127.0.0.1] (helo=sfs-ml-4.v29.lw.sourceforge.com) by sfs-ml-4.v29.lw.sourceforge.com with esmtp (Exim 4.100.1) (envelope-from ) id 1xTNoI-0000000041F-0tiU; Tue, 17 Nov 2026 18:21:38 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.100.1) (envelope-from ) id 1xTNo7-00000000413-3kx9 for openvpn-devel@lists.sourceforge.net; Tue, 17 Nov 2026 18:21:27 +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=OmygsGhPkzs8sIFN1wPwKeftPxCcvMJE+0e9D6yjxhA=; b=aamxhmHt2jAmDQCJBd6dk9nu1Y HRrbE7I/FxCENB3+ZvQ/A/cPP9xyPyMYrtAMWHVClFUvvQ3XtcttsXx1r8Wc/ttp8JvszvhriO3M7 k10c8mtM1fHLdtshBhBIKDvSiAGt5l7LsRXGhgxNFC7XWsXs0NIWbIo20TcIkLe7aKMY=; 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=OmygsGhPkzs8sIFN1wPwKeftPxCcvMJE+0e9D6yjxhA=; b=I4PvM10ied2DT6EhIJJ0g3HoIK bVMn6GtytbF/EPCMCiRtrCfSAEIb5yA01eUaI6N4lEAKa4l6cUNuxQLcyGvg5w6Xoxe1g0IWlRRuG XKm4tJEW0clNNxgREtr4TDH3QVuwBsRvaAE8uqYelrViYAH702vzMIPObTbtwww0Fa1g=; 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 1xTNo6-000000001C2-0i5x for openvpn-devel@lists.sourceforge.net; Tue, 17 Nov 2026 18:21:27 +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 6AHILJK7017660 for ; Tue, 17 Nov 2026 19:21:19 +0100 Received: (from gert@localhost) by blue.greenie.muc.de (8.18.2/8.18.1/Submit) id 6AHILJ9T017659 for openvpn-devel@lists.sourceforge.net; Tue, 17 Nov 2026 19:21:19 +0100 From: Gert Doering To: openvpn-devel@lists.sourceforge.net Date: Tue, 17 Nov 2026 19:21:14 +0100 Message-ID: <20261117182119.17648-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-2.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: Heiko Hund Only the first pipe instance was created with the flag FILE_FLAG_FIRST_PIPE_INSTANCE, which relied on the service never closing all of its instances. Create a disconnected instance on first use instead, which holds the name for the lifetime of the service, no matter how many instances clients use. 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: 1xTNo6-000000001C2-0i5x Subject: [Openvpn-devel] [PATCH v1] openvpnserv: hold the service pipe name with a private instance 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: 1882130690523358063 X-GMAIL-MSGID: 1882130690523358063 From: Heiko Hund Only the first pipe instance was created with the flag FILE_FLAG_FIRST_PIPE_INSTANCE, which relied on the service never closing all of its instances. Create a disconnected instance on first use instead, which holds the name for the lifetime of the service, no matter how many instances clients use. Change-Id: Id3a58112fffc8679978ddf5adb44e7be9083e17a Signed-off-by: Heiko Hund Acked-by: Razvan Cojocaru Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/2112 --- 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/+/2112 This mail reflects revision 1 of this Change. Acked-by according to Gerrit (reflected above): Razvan Cojocaru diff --git a/src/openvpnserv/interactive.c b/src/openvpnserv/interactive.c index 4a8d0b5..5e4b555 100644 --- a/src/openvpnserv/interactive.c +++ b/src/openvpnserv/interactive.c @@ -3806,6 +3806,16 @@ } +/** + * Create an instance of the service pipe clients connect to + * + * The first call also creates a private instance with FILE_FLAG_FIRST_PIPE_INSTANCE, + * which fails if the pipe name already exists. It is kept disconnected, so clients + * cannot connect to it, and holds the pipe name for the lifetime of the service. + * This way the pipe name is blocked from other processes using it. + * + * @return HANDLE of the pipe instance, or INVALID_HANDLE_VALUE on error + */ static HANDLE CreateClientPipeInstance(VOID) { @@ -3833,21 +3843,33 @@ sa.bInheritHandle = FALSE; DWORD flags = PIPE_ACCESS_DUPLEX | WRITE_DAC | FILE_FLAG_OVERLAPPED; - - static BOOL first = TRUE; - if (first) - { - flags |= FILE_FLAG_FIRST_PIPE_INSTANCE; - first = FALSE; - } + DWORD mode = PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_REJECT_REMOTE_CLIENTS; WCHAR pipe_name[256]; /* The entire pipe name string can be up to 256 characters long according to MSDN. */ swprintf(pipe_name, _countof(pipe_name), L"\\\\.\\pipe\\" _L(PACKAGE) L"%ls\\service", service_instance); - HANDLE pipe = CreateNamedPipe( - pipe_name, flags, PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_REJECT_REMOTE_CLIENTS, - PIPE_UNLIMITED_INSTANCES, 1024, 1024, 0, &sa); + + static HANDLE blocker = INVALID_HANDLE_VALUE; + if (blocker == INVALID_HANDLE_VALUE) + { + blocker = CreateNamedPipe(pipe_name, flags | FILE_FLAG_FIRST_PIPE_INSTANCE, mode, + PIPE_UNLIMITED_INSTANCES, 1024, 1024, 0, &sa); + if (blocker != INVALID_HANDLE_VALUE && !DisconnectNamedPipe(blocker)) + { + DWORD error = GetLastError(); + CloseHandleEx(&blocker); + SetLastError(error); + } + } + + /* Without the first instance, fail and try again with the next call */ + HANDLE pipe = INVALID_HANDLE_VALUE; + if (blocker != INVALID_HANDLE_VALUE) + { + pipe = CreateNamedPipe(pipe_name, flags, mode, PIPE_UNLIMITED_INSTANCES, 1024, 1024, 0, + &sa); + } LocalFree(sd);