Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp509481pxb; Thu, 9 Sep 2021 06:08:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzJGZZeA0yfmM9rkYy+1ahcTFzQpNoW/ppbu81YtYYPccTeje541TBg8h2G90Qr7EblapUP X-Received: by 2002:a05:6638:408b:: with SMTP id m11mr2757554jam.136.1631192902775; Thu, 09 Sep 2021 06:08:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631192902; cv=none; d=google.com; s=arc-20160816; b=TmZKAFbe4Wvx8z3Pw7Uzjql4HaJyJAhSE5llyRjFzhXPIM/KnT8NuvceV/tuwDj76S bi1P/5YRAjJluGB43VSbkWYIqNRwPlmAP4v9Vrc3ea0D0QoVd0D+i5HR1WwNusC383TW bg2FxkX33/gjnXGf4JN3I42Om/K9cHx/Yug38Ckaz725HIyXjpQ+MPgssgb5wZfFl11v fpOU6rZ0VtCz76rq+SMYzA5Mt3UpcwVqwJ7vxEiqTmUbY4CzTGjTO1neHaGF2uGqqLZH 33/9vxFMW838smWl56S7rBVgeazOkEu239XiU86ibbUfamqTBLLe9vinvLh5ENFM9Dhm UuIA== 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=sgAFjkhAiNfUPiz7iTaaMJ3sGKyLAjZ7dkIWhxHBYx8=; b=c9d8GZtYJE4tgMeJnydVqtCc4supzz6+qEvYKU0tRA+CS5RQNKX43i8iVn98Erxfny 5xupNQf6yvRMAwev7om1NeGE3nIiyi7taUgcbegActroC14LpNXNU9F5hYSO6QlI8FsP WT5EjtOWdkWVkpymEAIeu+bnFNul+1uX/QkO8Ehm2Yt3F+/XI/IqnXRNYgw6OYnYiH7f sVgZT1s/48C/FdZCocFBzfslxKYMgAnallRfwuqmnOr3/zJRz0tHNq3YHHVoPA2lD7s4 wEEg2/RSpj81q95h+7b2Ca6VECFrUSFhD/7m1SmXEzmZrcThUqDIfu/rJLO7tiQwoYTq m+zw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RkwfQ1p7; 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 a10si1574415jaa.15.2021.09.09.06.08.00; Thu, 09 Sep 2021 06:08:22 -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=RkwfQ1p7; 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 S1358579AbhIINHm (ORCPT + 99 others); Thu, 9 Sep 2021 09:07:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:40848 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353172AbhIIMtG (ORCPT ); Thu, 9 Sep 2021 08:49:06 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id CC672611C1; Thu, 9 Sep 2021 11:56:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631188600; bh=VulqvxBtUQTNH3d86yDvRtC5+CUk148V7vQLKRn6wXk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RkwfQ1p7eP37UIioJpW3sewG3Mo3g0kA1g1ZJF47CBrskldzUcovlgVDH3KRnVFTq mDNoGxo5kONQxa4lMRvjdlRKnzFot8N8Z5FuclBRiyfykEcPRa2eqLItZ5d4Q+nTcJ LMpu75DcVjapxhRc2eYzngvztQ5yOgdBDa207uQTlJsoc4MbK6ZygTfOREQmOPTJOG j3qoxHSX1RfnRbbzzc0/IR1p6KqjvL9O93cOVWvixYLsEiIWA6voL2DWj2AYs8B/SS AqbjLOdkoKGyZp1F62AP9shzD5SM4q3glMBAUWMqvt1UFrtWE60Ilbijrt8xBSlsAX zJU9e9LUyfBRg== 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.4 073/109] tcp: enable data-less, empty-cookie SYN with TFO_SERVER_COOKIE_NOT_REQD Date: Thu, 9 Sep 2021 07:54:30 -0400 Message-Id: <20210909115507.147917-73-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210909115507.147917-1-sashal@kernel.org> References: <20210909115507.147917-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 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