From patchwork Tue Dec 27 02:24:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arne Schwabe X-Patchwork-Id: 2944 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7300:c95:b0:82:e4b3:40a0 with SMTP id p21csp2355300dyk; Mon, 26 Dec 2022 18:24:38 -0800 (PST) X-Google-Smtp-Source: AMrXdXu3A7WDnyZn/NGcMXV6xbSxb2CsEsCW73sD2kuePlDQJSWikF4+jOYefZBgnlJmfdr2KY5a X-Received: by 2002:aa7:9255:0:b0:566:900e:1023 with SMTP id 21-20020aa79255000000b00566900e1023mr21767940pfp.3.1672107878524; Mon, 26 Dec 2022 18:24:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672107878; cv=none; d=google.com; s=arc-20160816; b=j2Mai8IQNcf8YYKxy6XqkMGInY4brbN3MtVumVM7aq4v2/mKf8YpSYu/cqJ+A5JtbO RgQgT2I4f77QLbIYtg1Csj3J3Q/S+GvxlUAux3Jg1RUxBst5mtTU/ao76wiOw/Up3Yxs wIb7rmRgecUfSPh5BRW+TCNxuW/8vS7mpYynSu/LcZoiAnOdeGTSxytdA9wUKlK/ewWt RkA3XhhEobd6vjXuDIF899vf7hkvxHAG0G9WuwhIn4z545QB86HGPRuXd6JVQMy08HIq 67s9z2235cW7BlWypwosF2kq+l7X/VzJarCbHBetAHFr9y7dViMmQ4gluSxfo5B868hh 16Nw== 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=luyVHUp5OSaSVXLiBcvztj1zGCXA0lshpKSfZOvVoIO2rgtsMzcNGdTltzNuRSEgkD A5sAllpl5CCb6eFDsLQ0Vgb0QIF2F6CVA0Gzc2TvmV+s3qUrNKp7sbaaOGC0fTxv744R TUPnDNluofZkKUz+8FHm72K3gc/nXhahs/43gx3UliOvTy5nOTrs8zjnomuthnaANbM9 B//AlvWfEGap64NbAVMwCznd1pPSyOKvEdgsJAClmUChfg4i4z5Z95+UjVTJv3YawYe6 l9CnfQqyNrRYbbYhmT/OI85V7RkYFfgzEj0vglQdJLXI6Nl++4r1wVI3EaNqQ/qjlwGs cA0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=cpxQRj6l; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b="XG/LV7j7"; 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 s9-20020a056a00194900b0054114c6685asi13077202pfk.129.2022.12.26.18.24.38 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 26 Dec 2022 18:24:38 -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=cpxQRj6l; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b="XG/LV7j7"; 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 1p9zdZ-0002fL-Rb; Tue, 27 Dec 2022 02:24:17 +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 1p9zdX-0002fE-Tu for openvpn-devel@lists.sourceforge.net; Tue, 27 Dec 2022 02:24:15 +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=cpxQRj6l85nVlOi+NEUvKFp98E 8ljm/G0vDDKbICujI2kKbAGwgnKHm98v3xxLvegbRFLt6Jl/4ea5GHzIgYeS+7kzQCEKS6NCyvD+9 m1zwqh1Fc0CzhxNpqDPiaTvU2ZmfR9dRfqxMMiSyu8OIqiNQQ3JZO1y3Mq9kb/vQHhj0=; 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=XG/LV7j7hQIyQnhhMvPxwuupCp GNusFUPWIYwOCHgVAtA3f50t6I87Sl8evTTK96kqIRhA0MndG75RpDDA/jGtzzAkhlxxElRGNFy5Z iS1aEjy4uhp9+vHnkIntxhBDRwzXE7hRf5Jd6BqbvncSTl0i2py0jlDRbddOIOdJMeUk=; 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 1p9zdT-0007HE-D0 for openvpn-devel@lists.sourceforge.net; Tue, 27 Dec 2022 02:24:15 +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 1p9zdM-0002IW-2Y for openvpn-devel@lists.sourceforge.net; Tue, 27 Dec 2022 03:24:04 +0100 Received: (nullmailer pid 3468186 invoked by uid 10006); Tue, 27 Dec 2022 02:24:04 -0000 From: Arne Schwabe To: openvpn-devel@lists.sourceforge.net Date: Tue, 27 Dec 2022 03:24:02 +0100 Message-Id: <20221227022404.3468137-2-arne@rfc2549.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221227022404.3468137-1-arne@rfc2549.org> References: <20221227022404.3468137-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-2.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_NONE SPF: sender does not publish an SPF Record 0.2 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level mail domains are different 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record X-Headers-End: 1p9zdT-0007HE-D0 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?1753332190839362491?= X-GMAIL-MSGID: =?utf-8?q?1753332190839362491?= 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) {