Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1849070pxb; Thu, 16 Sep 2021 17:49:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyTOdNmRsBp6KBOk9JL6zmCK6eEAMgWWYnEkxoKNYN4q27jET4U0As78NRjjZ+bAEvoSs6N X-Received: by 2002:a5d:9488:: with SMTP id v8mr6409891ioj.195.1631839794401; Thu, 16 Sep 2021 17:49:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631839794; cv=none; d=google.com; s=arc-20160816; b=mDgKcpeA8wosYh+OQ+YGao5wujzWD7dIHz5vuIi7wKObwMeKwStEhkjecY0CIEViAj GChcuK5y75ajLi9b7u6YgVfkbZzM5ePCI0BezdZC8luyah/Alw241hyjnYl37WdnzhZD 2Nq9d2stEdwKBczqmiqqHv1W5DvxSd7gtmwqXosnNpAc113jaEUTsH7hMoa0/AXWmIBw /FBI05tDXposZm4n7hKxQIaCr+pf4eNsLwgtxSyumaoTQ1HR+3USPLpWUd/4R3od3CHU h3LUw8y6r0yfk31cG1r/sgrK/Ln0wXO6grp0Wk7YYe6cnvm0gdqhFh2EegN6MCdnmzEc aRHQ== 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=ohIraiuLa+qheo6eYvWsxoCEerWEqWQQ3Z6Wr8C9hGM=; b=ijestUxBD4NdvIKYsUwyY+wF/0QAQCsg0cisP+lxei+1+wG8W5p+6iB/tyRTheklID 8cMrS1/RESEkTErrSp3UxMSOhKRgS0GShpJhgQTVNySp03i//AhjOmiHKfoqHBwLJuia Pnb1r/HJybSD/0vwZDpPaDMkmt2BNZYlMExSaVvfY/0bY30XhWoKtKW6SJrspYwk4o4g 1grtpCw4w0775LIXWrkGOUCl9VotEppcMkU+0JlmZhOzTMGHunIyamriJVFXbEqggVa1 meAA5Btsll9dVrFpRzoOdMOROyV2J3nMkS16HhYDg1P5G0lp4Py5NqPZ1Tg+w/0BLZN7 3jDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="r/nJ1DoR"; 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 c17si4698141jam.29.2021.09.16.17.49.42; Thu, 16 Sep 2021 17:49:54 -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="r/nJ1DoR"; 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 S245139AbhIPRK4 (ORCPT + 99 others); Thu, 16 Sep 2021 13:10:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:54402 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347129AbhIPQ5q (ORCPT ); Thu, 16 Sep 2021 12:57:46 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 758A661ACE; Thu, 16 Sep 2021 16:31:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631809889; bh=yqZajeSzuZRjAZq/e6DFxJmN7kiugX54XlOTrOdtcWY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=r/nJ1DoR/SkWhgP7Yqb1nM89t6Tn6669siE7etvbBA/kop0Gu46s4EEqUwXH2NM4u 7boqpKDLVcCN5/YjeFXhSc+WFJ6oLWBA8tbFU+5MuOmSotRUXF7iEwa6iCVL6lwpzg E6rPdWgvPOsBm4amXe9uO0aNKY89OJgInu4dBHVA= 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.13 278/380] tcp: enable data-less, empty-cookie SYN with TFO_SERVER_COOKIE_NOT_REQD Date: Thu, 16 Sep 2021 18:00:35 +0200 Message-Id: <20210916155813.538801797@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210916155803.966362085@linuxfoundation.org> References: <20210916155803.966362085@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 d49709ba8e16..107111984384 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