Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp452858pxb; Thu, 9 Sep 2021 04:57:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx61UpmPPAjGrNVc16yxmN+kNGGpVL6QEUYAti4eevljaAxBQ3Cw5KZoTHJNL9TtP9tiI6E X-Received: by 2002:aa7:c1d0:: with SMTP id d16mr2846052edp.110.1631188641145; Thu, 09 Sep 2021 04:57:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631188641; cv=none; d=google.com; s=arc-20160816; b=p+JQhyHTxcOXkC7JnJ8F2Vlx180CA7bs6v7ctKise9B/YkTBUW3nOhNagN7bhTPqDV pug6729A7b5vAuGu4TX7rFtKjwQ+1xF8+MhbN8RLB/S3ENnrm4p/9nAlZTL6/BVPFUQW GLMnjerwuIQ/mXFp7fw+JIeJNeTNXEOpClX3ppDuJxtTPbxVEcQjvg5iAg/VBY0RDaCI aWmO2iymH+bRj+xowz3Jj/qOEzK7mrW7pG3/MGx3aRqUnDp6iNbU4rHl0sKAhVEQKNFY 7hTZdRamSKBokEz8+i3sCV0jDzP+ajNIZQAtbmxCU+TIjRkC3s0j/bHZmV63ABXLCQed Tivg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=S8f6ozsN+WAIrd0YNLmDRL2MOe1DKvt2+98YuRMQu6o=; b=Wvw67dcWVKeETCyF30nV8dArqf3MpIO3KOlsDY3q6DLPFmiisZbiiKYFDrRqjfgVXc MIzNukOOaNPcmb8041NpIZik58A911Jpa0qNrAY+4vZ7hpUppmZGLEJt5Nq2/wT79Ha1 naUp1/FZu0EMMvPqM3w3RtDutb6Dd75ycBkYZU8VfPA1EhFdSrRb7hE3Rqa8kzJHqk5L vHFukJfmHJK6o1uPhQTUoh9ROjJtjrNLBAe05lgDv8velvbVC8evKPDWqAXe9qglHHsz JoYeBTuRzt9ZgU1hi3QAg+bIBrtNJQXfd4pOiJ3tsKI1r27BgSr6980u6kYc02huL4po Fcjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=d6T9pUpu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s28si437478edw.13.2021.09.09.04.56.57; Thu, 09 Sep 2021 04:57:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=d6T9pUpu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242269AbhIIL4p (ORCPT + 99 others); Thu, 9 Sep 2021 07:56:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:33846 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239664AbhIILyB (ORCPT ); Thu, 9 Sep 2021 07:54:01 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8E3916138F; Thu, 9 Sep 2021 11:44:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631187882; bh=nmZlJjMfVm8UXxDXZfpM14Y9C+so6nIKPHyHfBjxfQ0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d6T9pUpu2zE4ZKGfvDhAGQ2ybYN8sjxL7eXfethF0mRzYfRcj2c2gDzxoow28gTWy Aj0kiLhHpf2+2iYqplHO0LuVLZTRnf3jC2A9ceJ6IUD8grqqLkt9EsIgL4WWluqiLa 1HWWiWO8bEdgzaczlD5/8UfDMRqsAUvUxTxDeDBRr6t+iRVn/XAA7dQdEh8TxZhzg9 rj99Cs2VtrpGo34CSlKWTuNfgDH0Cnvg4BBwpMby+xjq3oMA/Ul7PpYE2ZneEU/o7n 7Uc8hccpsSuA0JhQ0raqDZmHUi3MOirihLod3Eh2KtG+hPWbve2CXfDAkFMlxoBP3Y arNTRiXPqJAHg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Luke Hsiao , Neal Cardwell , Yuchung Cheng , Eric Dumazet , Jakub Kicinski , Sasha Levin , netdev@vger.kernel.org Subject: [PATCH AUTOSEL 5.14 165/252] tcp: enable data-less, empty-cookie SYN with TFO_SERVER_COOKIE_NOT_REQD Date: Thu, 9 Sep 2021 07:39:39 -0400 Message-Id: <20210909114106.141462-165-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210909114106.141462-1-sashal@kernel.org> References: <20210909114106.141462-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Luke Hsiao [ Upstream commit e3faa49bcecdfcc80e94dd75709d6acb1a5d89f6 ] Since the original TFO server code was implemented in commit 168a8f58059a22feb9e9a2dcc1b8053dbbbc12ef ("tcp: TCP Fast Open Server - main code path") the TFO server code has supported the sysctl bit flag TFO_SERVER_COOKIE_NOT_REQD. Currently, when the TFO_SERVER_ENABLE and TFO_SERVER_COOKIE_NOT_REQD sysctl bit flags are set, a server connection will accept a SYN with N bytes of data (N > 0) that has no TFO cookie, create a new fast open connection, process the incoming data in the SYN, and make the connection ready for accepting. After accepting, the connection is ready for read()/recvmsg() to read the N bytes of data in the SYN, ready for write()/sendmsg() calls and data transmissions to transmit data. This commit changes an edge case in this feature by changing this behavior to apply to (N >= 0) bytes of data in the SYN rather than only (N > 0) bytes of data in the SYN. Now, a server will accept a data-less SYN without a TFO cookie if TFO_SERVER_COOKIE_NOT_REQD is set. Caveat! While this enables a new kind of TFO (data-less empty-cookie SYN), some firewall rules setup may not work if they assume such packets are not legit TFOs and will filter them. Signed-off-by: Luke Hsiao Acked-by: Neal Cardwell Acked-by: Yuchung Cheng Signed-off-by: Eric Dumazet Link: https://lore.kernel.org/r/20210816205105.2533289-1-luke.w.hsiao@gmail.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- net/ipv4/tcp_fastopen.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/net/ipv4/tcp_fastopen.c b/net/ipv4/tcp_fastopen.c index 25fa4c01a17f..f1e90fc1cd18 100644 --- a/net/ipv4/tcp_fastopen.c +++ b/net/ipv4/tcp_fastopen.c @@ -379,8 +379,7 @@ struct sock *tcp_try_fastopen(struct sock *sk, struct sk_buff *skb, return NULL; } - if (syn_data && - tcp_fastopen_no_cookie(sk, dst, TFO_SERVER_COOKIE_NOT_REQD)) + if (tcp_fastopen_no_cookie(sk, dst, TFO_SERVER_COOKIE_NOT_REQD)) goto fastopen; if (foc->len == 0) { -- 2.30.2