Received: by 2002:a05:6520:4d:b0:139:a872:a4c9 with SMTP id i13csp2566232lkm; Mon, 20 Sep 2021 18:53:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzAZGtlO2B0IuBihXRrLy1cEkrChZnJwDo+VEvRD1BcuSBPcTv66MrltAci4hvtAZocfKC5 X-Received: by 2002:a02:7f4a:: with SMTP id r71mr17083791jac.132.1632189182160; Mon, 20 Sep 2021 18:53:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632189182; cv=none; d=google.com; s=arc-20160816; b=YWSqYbyVV6tXSe24NdDI3HE8jGEPLKyR5HuIYF863txX1wSGKJuI0o9glnUvikzUiK ZUFAylZps+nhVG1nBqcjNZ7Zj7vFMzrEWC+q3u/oMChRRCORv35R0gn6HLD2MNHtQrOx C7tUglcuf/QTguqutk3JRlz2d7RLLpNH644SRdUes2k00UmWaB8k2+MoxwnlynwHfndT louRkv7myz9mmc4G/NtR5FwRJxx3dwYow3q5sGSnA5PGoNCI68LTeUN1ZzaCP2MQ4hm9 aTWEAdYPWFyYu4yi1dqoSvItbuD7LCYIxn7SssrKJt2EQaAnov/iEorTELCDFkrAOQpT NbYA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=sgAFjkhAiNfUPiz7iTaaMJ3sGKyLAjZ7dkIWhxHBYx8=; b=NRbX9CtfaYbr6L2oTiMEFI9KdByAmwsScamq9XcPEkeJ4qV0eUqr4Kvofvy3W6CJzM LjYua2AIzfSsSgj5ydrL32oLr7xVPSa1SmXmx7TPUI9Ic9y79+rAV8Uj/kxDnY2KN5oz 76ByVKJ1bY0wRuXk0PojRl7yezE00JNt850QnK5xRA8yjx4FZcEdQltdQKoW8AVuGKG/ UE/axSQQyTxeUavXC832cp6yl9VpFFmt6upGLrxRl9SAki8vSONxpPKZIXoPkbd2IWE+ Sq9uVCXRrhF84nbkYMkliWd9ClHLi9CKsKPLtXZ+cvpmiTEqMWwpdv7AsIZfZIDXDwkT +eSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=0vtlxBS6; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c1si14808404jaa.58.2021.09.20.18.52.46; Mon, 20 Sep 2021 18:53:02 -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=@linuxfoundation.org header.s=korg header.b=0vtlxBS6; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351253AbhITSP7 (ORCPT + 99 others); Mon, 20 Sep 2021 14:15:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:35216 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359778AbhITSKS (ORCPT ); Mon, 20 Sep 2021 14:10:18 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6B9126326F; Mon, 20 Sep 2021 17:20:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1632158403; bh=VulqvxBtUQTNH3d86yDvRtC5+CUk148V7vQLKRn6wXk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0vtlxBS6ZW3hNim3LfVSkQAReMmBwmIURquw2Vvbiv0GnVjCFtlcsCipMpJJBzOAJ 92glSRWClxfLXEmnmEr9fy5IHCT8fUgUESJQDoYdQiaC4GWGK9QqVpMOFX43E/IhgH 4nOv3KoQbS4bwT1aIPUZtuCEImZEDY/O9N7M3t5g= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Luke Hsiao , Neal Cardwell , Yuchung Cheng , Eric Dumazet , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.4 140/260] tcp: enable data-less, empty-cookie SYN with TFO_SERVER_COOKIE_NOT_REQD Date: Mon, 20 Sep 2021 18:42:38 +0200 Message-Id: <20210920163935.873063837@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210920163931.123590023@linuxfoundation.org> References: <20210920163931.123590023@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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 8af4fefe371f..a5ec77a5ad6f 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