From patchwork Tue Dec 27 14:02:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arne Schwabe X-Patchwork-Id: 2950 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7300:c95:b0:82:e4b3:40a0 with SMTP id p21csp2650248dyk; Tue, 27 Dec 2022 06:03:33 -0800 (PST) X-Google-Smtp-Source: AMrXdXscgPQMS58pn1GkE5QW0Inq4M2nmXx9YmfvnLiCH0pmnKgP5JLrKgrCBLPdwXAhKOSf8QWH X-Received: by 2002:a05:6808:1907:b0:35e:1ca6:ff6d with SMTP id bf7-20020a056808190700b0035e1ca6ff6dmr13338327oib.5.1672149813805; Tue, 27 Dec 2022 06:03:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672149813; cv=none; d=google.com; s=arc-20160816; b=ckAu5e1VB3Iw9dCdLUVSS6ZgiSPjT4KcjK4C4T7GtaE/sEJdos7fCW07gPHcJQDFPC 0s+64n1WwHn7hYpDCKVIUh3OMD7YY9cb9Dt1c+rBhVEuP39GdK3XsLXDIiLc3jucV4B1 /pJ7Kk69FUjz+wfCLs8Od5W0PFgZhWw2gjFn2sZmCfyiDIcgFx9S3ZENw9Om9cJrMkTQ YgNscpXTzpugycwDzaoO4OPrpHA88Zxruuu9dYLElNqt0vnxwQO0AwXZCvCOPzhcKNKf 0RFXw8o+zu1L4neN7EMz7HKKI5ev/u0FslArC9sZr7M9kWGDFPPoA+0JPnHC+Kz2XYZb 42fw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; 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; bh=dG8jnEUPlJMZNpdPo3jJ7+guru0S0IfNIfsYBGVLczM=; b=xN2DB8IXOVpHNN8nOyiOHBsB5P+ZEK5AloYdcFE5kfNUVUG0Zb5W9JMAMITKoxEzgc BRA8ckdSPszMCfDcQU26EcNpS9FDrD+9K/H6+8OO+KyztHrTIUAHEIbh40t1x11srb7y zk7yLtLbSCgP4HJNhaN/qoFFdzHbhulf5Q615s9GJfxhkHA221VIsMIgp//QvHwqKoQa hrLLbQir54XWRwX8vSEPEvd6+Hl5bOqy8N6WFfIPamLz62MkZ9xideDtmFYu/bZuZYdD 6VZc9bSYuxb324IwM/BeFLmpynpVGt9N7raDzGxaseYs3IT8ctNNF53Jq/65qYadQB5s 21rw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=SdqGNcH0; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=a6LeSjn8; 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 i1-20020aca0c41000000b0035a31d82948si9575842oiy.83.2022.12.27.06.03.33 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Dec 2022 06:03:33 -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=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=SdqGNcH0; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=a6LeSjn8; 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 [127.0.0.1] (helo=sfs-ml-4.v29.lw.sourceforge.com) by sfs-ml-4.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1pAAXk-0007lE-4w; Tue, 27 Dec 2022 14:03:00 +0000 Received: from [172.30.20.202] (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.95) (envelope-from ) id 1pAAXi-0007kw-2l for openvpn-devel@lists.sourceforge.net; Tue, 27 Dec 2022 14:02:58 +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=lqQgkiBdZd6xFqK4UJvEb/XpGvl9w9hUilpgb5nQHzo=; b=SdqGNcH0vllWnGC92jOvjmysIT KF/Ul3ave/YYlaTPRI008Atx8OApcU6a1nFdcPBiKo/oP3IjZhjI8uOfisWODapKw5/cWPdGKDtg5 MHrC5ChUNLYbc8GA4DWADkQi9bR0hUd+wo/enChOfJzjbICDHYOHxuoI7BANMYnYvIfU=; 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=lqQgkiBdZd6xFqK4UJvEb/XpGvl9w9hUilpgb5nQHzo=; b=a6LeSjn8FttJkF2h4ZQu8TBqL/ 0WyVCbhygsbtnrD5fw5zxDEFo+mdu8mthsV9x2Eopg8pi/QvX8YyZrNzvBNAOsxu8LgClcgT/sq0K Vk5OJpuOkEJHt8ovwVZa9VvcLNq+8v84v9uzKqHAQ+4kmia7FSeDT75gDBYZMmDrMffU=; Received: from mail.blinkt.de ([192.26.174.232]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1pAAXg-0007sY-LE for openvpn-devel@lists.sourceforge.net; Tue, 27 Dec 2022 14:02:58 +0000 Received: from kamera.blinkt.de ([2001:638:502:390:20c:29ff:fec8:535c]) by mail.blinkt.de with smtp (Exim 4.95 (FreeBSD)) (envelope-from ) id 1pAAXZ-0004uM-8B for openvpn-devel@lists.sourceforge.net; Tue, 27 Dec 2022 15:02:49 +0100 Received: (nullmailer pid 3524997 invoked by uid 10006); Tue, 27 Dec 2022 14:02:49 -0000 From: Arne Schwabe To: openvpn-devel@lists.sourceforge.net Date: Tue, 27 Dec 2022 15:02:47 +0100 Message-Id: <20221227140249.3524943-4-arne@rfc2549.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221227140249.3524943-1-arne@rfc2549.org> References: <20221227140249.3524943-1-arne@rfc2549.org> MIME-Version: 1.0 X-Spam-Score: 0.3 (/) X-Spam-Report: Spam detection software, running on the system "util-spamd-1.v13.lw.sourceforge.com", 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: Instead of getting the server in a very weird state, we bail out here. This is only a bandaid solution but better than the alternatives. Signed-off-by: Arne Schwabe --- src/openvpn/mtcp.c | 2 +- src/openvpn/multi.c | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) Content analysis details: (0.3 points, 6.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 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 X-Headers-End: 1pAAXg-0007sY-LE Subject: [Openvpn-devel] [PATCH v2 2/4] Bail out when trying to install a TCP socket with residual data to DCO 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: =?utf-8?q?1753376163421112547?= X-GMAIL-MSGID: =?utf-8?q?1753376163421112547?= Instead of getting the server in a very weird state, we bail out here. This is only a bandaid solution but better than the alternatives. Signed-off-by: Arne Schwabe --- src/openvpn/mtcp.c | 2 +- src/openvpn/multi.c | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/openvpn/mtcp.c b/src/openvpn/mtcp.c index 519630544..c07b5d592 100644 --- a/src/openvpn/mtcp.c +++ b/src/openvpn/mtcp.c @@ -591,7 +591,7 @@ multi_tcp_post(struct multi_context *m, struct multi_instance *mi, const int act struct gc_arena gc = gc_new(); msg(M_INFO, "ovpn-dco installed socket with residual read " "len=%d, mi=%s. This connection will probably" - " break.", BLEN(&c->c2.link_socket->stream_buf.residual), + " break.", BLEN(&c->c2.link_socket->stream_buf.buf), multi_instance_string(mi, false, &gc)); gc_free(&gc); break; diff --git a/src/openvpn/multi.c b/src/openvpn/multi.c index 92e63dd26..6c6385c6e 100644 --- a/src/openvpn/multi.c +++ b/src/openvpn/multi.c @@ -2316,9 +2316,17 @@ multi_client_setup_dco_initial(struct multi_context *m, { if (!dco_enabled(&mi->context.options)) { - /* DCO not enabled, nothing to do, return sucess */ + /* DCO not enabled, nothing to do, return success */ return true; } + + if (socket_read_residual(mi->context.c2.link_socket)) + { + msg(M_INFO, "TCP socket with half read packet. Cannot install to " + "DCO: %s", multi_instance_string(mi, false, gc)); + return false; + } + int ret = dco_multi_add_new_peer(m, mi); if (ret < 0) {