From patchwork Thu Dec 3 14:26:24 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gert Doering X-Patchwork-Id: 5842 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:6022:311b:b0:11b:d6c:f273 with SMTP id e27csp154032laa; Thu, 3 Dec 2026 06:26:42 -0800 (PST) X-Forwarded-Encrypted: i=2; AL+hErG7OWcmOE4jfJFzrxhhSY6vo9p5/RLd0FP/VcC8nk/H5iwJfGCYZCuSs60Nbi6wBpc5bL0/gr67bYs=@openvpn.net X-Received: by 2002:a05:693c:8813:10b0:385:cbc5:7eeb with SMTP id 5a478bee46e88-385cbc595acmr38249921eec.15.1796308002431; Thu, 03 Dec 2026 06:26:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1796308002; cv=none; d=google.com; s=arc-20260327; b=miLC7/vngHZ7GKVKjd+eArJ097re47yPDsr04I25GcxW5gdJW/Js7hCUCCRXGQmE9N rPtepdnekqwoGRK39mUqzmhGWkhzmaYtzIzWPwd57lIXyP2P+sjytqqjiGdiYAdiLjKp ws2ZjJs18SqKgIaN7I9pGTCE9nACQVY7Y4vZpxme5wO0MMYSo78c3Ha7i4u5Ap2QzoOS 8xCvVsqpeTLCWjL2P+ue3yB2IxTD+G9hgQpSZwM3HLs0QGHrKcYzGBjA1N3xERnLLZD+ O6U2koBSXXQubtXWtpliY6DcCi0nma847XMyeLWTq1N1nxVag67ay3ZbxMxIiyh+63me nCOw== 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=5Z5aaMlwEcazt4PaHs00kuK9Jg/8InryG+/jqkjaoPc=; fh=4NbAC/LsuMLI0S0hprUlLSLCiHwg6SCAifhH718Jh0Q=; b=TaULoG4T8G+zYdhtMJUaNqGd7ZCUmfWhDWXJsLUqMfNe/EtnxcFQMmL97lJfGsGd0c SSAaJQpV9cFHmjiaCHuAnU4xkPGQ0eH5jQ1DNn0ugP+6BN0ZUOUbCnTRr6dQcqkLNn+c WXop2OgYcLNyy/XKKiGyqfe97BQH13gocIVVtfMrD/VpJh52lPIsupk/NEkFp6FFzTVC Jhw7zoop76PvSKPZcaHZB4haC5OZRzmw9gS3Y9VTRea3BDdAHzaMxWvK24iWAegI/b9T svQJSOjtg2iOLKySrixQO8lIKRmZMC8IpH9Val4HLyHYL8slye9bLzA7yqLpYKunATW9 gD0g==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b=Jx40lKvs; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=MsaMClbi; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=fn7iF95g; 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-3869c273d9bsi105654753eec.20.2026.12.03.06.26.41 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 Dec 2026 06:26:42 -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=Jx40lKvs; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=MsaMClbi; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=fn7iF95g; 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=5Z5aaMlwEcazt4PaHs00kuK9Jg/8InryG+/jqkjaoPc=; b=Jx40lKvsUZijkG oJYk9Z1LZEOzvuUahZOq6Xcrxkhg5KfV0lR07LFu5fXGsy/AtMmGBYoI9zWxW+eWS8waVBpF7eroB ZXSxAm7D0O//n36NcJ5MjhCobdCXw9wmKPWLZiAQOzCIXjTSOR/zjYBF061HZR2P2p4FzNcjNYoKw JcM=; 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 1xZ7lf-0000000044L-3dkd; Thu, 03 Dec 2026 14:26:39 +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 1xZ7le-0000000044D-3WD0 for openvpn-devel@lists.sourceforge.net; Thu, 03 Dec 2026 14:26:38 +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=xoVgUPw+wnCkItL8X7TKGvMf+DtSRAxSD4PpAN2lZfA=; b=MsaMClbiCcVzBs+3tldiXQJcca I1KAPFI5TQ4FllM2/ifYO1q1sg2/AY0EwrJ24pVJ2I77LeKiJ4qTXarZDY2oj+Cvmd4suMK5TTVpj nxBIDLvezU2mpCt5FPwxTmTAq4Lt/DzOmtZVhz3k1zmsXB7JWIoXFGwnRJfrmUDr7fDw=; 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=xoVgUPw+wnCkItL8X7TKGvMf+DtSRAxSD4PpAN2lZfA=; b=fn7iF95gv9oFGfiH3w83s0X3bm vX+P/ZBPySngVQVzW+E3VqBoJb+3aKNzl/f1MnS0FibZwMGTs4Ryy3vlvq9IUfLmGk9GxImSTUr4l h7uWb6QE2p7Yqp44tqAz6ldBv0wrSxw6OhKKhTgZ3SGCN4EuGTb5jvmY+7dDr6Lu/Agg=; Received: from [193.149.48.129] (helo=blue.greenie.muc.de) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.100.1) id 1xZ7ld-000000000lE-3BtR for openvpn-devel@lists.sourceforge.net; Thu, 03 Dec 2026 14:26:38 +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 6B3EQU3k001259 for ; Thu, 3 Dec 2026 15:26:30 +0100 Received: (from gert@localhost) by blue.greenie.muc.de (8.18.2/8.18.1/Submit) id 6B3EQUrs001258 for openvpn-devel@lists.sourceforge.net; Thu, 3 Dec 2026 15:26:30 +0100 From: Gert Doering To: openvpn-devel@lists.sourceforge.net Date: Thu, 3 Dec 2026 15:26:24 +0100 Message-ID: <20261203142630.1244-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 FreeBSD close_tun_dco() is never called: its only call site lives in the Linux close_tun(), behind a TARGET_FREEBSD guard that can never be true there. As a result the DCO control socket and notifi [...] 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: 1xZ7ld-000000000lE-3BtR Subject: [Openvpn-devel] [PATCH v2] dco_freebsd: close DCO fds when closing the tun device 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: 1883565459955081915 X-GMAIL-MSGID: 1883565459955081915 From: Antonio Quartulli On FreeBSD close_tun_dco() is never called: its only call site lives in the Linux close_tun(), behind a TARGET_FREEBSD guard that can never be true there. As a result the DCO control socket and notification pipe leak every time the tun device is closed (e.g. on restart without --persist-tun). Call close_tun_dco() from the FreeBSD close_tun() as well. Since that function already destroys the interface via "ifconfig destroy" (and keeps it when persistent_if is set), reduce close_tun_dco() to closing the fds and drop the now unused remove_interface(). While at it, remove the dead TARGET_FREEBSD guard from the Linux close_tun(). Change-Id: I10326c787cd8149e7617279e45166073d66b9101 Signed-off-by: Antonio Quartulli Acked-by: Razvan Cojocaru Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1897 --- 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/+/1897 This mail reflects revision 2 of this Change. Acked-by according to Gerrit (reflected above): Razvan Cojocaru diff --git a/src/openvpn/dco_freebsd.c b/src/openvpn/dco_freebsd.c index d933aaf..78b8daa 100644 --- a/src/openvpn/dco_freebsd.c +++ b/src/openvpn/dco_freebsd.c @@ -306,26 +306,6 @@ return 0; } -static int -remove_interface(struct tuntap *tt) -{ - int ret; - struct ifreq ifr; - - CLEAR(ifr); - snprintf(ifr.ifr_name, IFNAMSIZ, "%s", tt->dco.ifname); - - ret = ioctl(tt->dco.fd, SIOCIFDESTROY, &ifr); - if (ret) - { - msg(M_ERR, "Failed to remove interface %s", ifr.ifr_name); - } - - tt->dco.ifname[0] = 0; - - return ret; -} - int open_tun_dco(struct tuntap *tt, openvpn_net_ctx_t *ctx, const char *dev) { @@ -348,7 +328,7 @@ void close_tun_dco(struct tuntap *tt, openvpn_net_ctx_t *ctx) { - remove_interface(tt); + /* the interface itself is destroyed by close_tun() via ifconfig */ close_fd(&tt->dco); } diff --git a/src/openvpn/tun.c b/src/openvpn/tun.c index af48921..b793556 100644 --- a/src/openvpn/tun.c +++ b/src/openvpn/tun.c @@ -2240,12 +2240,10 @@ { ASSERT(tt); -#if defined(TARGET_LINUX) || defined(TARGET_FREEBSD) if (tun_dco_enabled(tt)) { close_tun_dco(tt, ctx); } -#endif close_tun_generic(tt); free(tt); } @@ -2825,6 +2823,11 @@ { ASSERT(tt); + if (tun_dco_enabled(tt)) + { + close_tun_dco(tt, ctx); + } + if (tt->persistent_if) /* keep pre-existing if around */ { close_tun_generic(tt);