Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1055677pxb; Wed, 6 Apr 2022 07:42:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz1Tq0SBYJOwEIZh5ZkkQwBxLyGLi2gekc/ck0YMDEbvk+6SvXjzXHEmsV/ilz0IhrJrFBf X-Received: by 2002:a17:90a:bb17:b0:1ca:b45d:eb39 with SMTP id u23-20020a17090abb1700b001cab45deb39mr10187902pjr.57.1649256119901; Wed, 06 Apr 2022 07:41:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649256119; cv=none; d=google.com; s=arc-20160816; b=mCOUgys1eIW3aJIQ63w+2Lhr87a/di7Nuft2dwHNBS8F8+7VRgJUb7tKzJXFS47dVB fmtDpJhqQzZMemfvG9n3EgN3l1JLd4/gOVzD103nT7K4RLPA2pf+aaHjjGrRrKzytXsU 2fDS9kbTTIxcj4Ktzuz7iE8NqinOe10+K0se9zSZEfsuwMRTxu36pVeHtTDwG48nz86J mEOfcJaVVVAsGOXYPUZGR6XDXQG92DK4j9GQ+M6UY7aPZ4aviS1eLSu8mXLIa14vZlEE bEkLW/ZNtYkm204MmQMGolJtawIGI86wlL9Siq6oa6N59tOHZgPOyHkFYsxuWkfiibl2 /Y2g== 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=5A6luiIUT89y2sfV7qL/61axRntER2CpfNXCweTCqNw=; b=X0sRDG9qKfK/JD0grHO4TkpW57Fm16KuRySC0tgs9tlg6EmDvY+fFCX8gkSwJ8C/ay I3V2POJ3R4gJd0TacgAO7JjNMcVEJJ5hVtgpqO+yKe8PV+ZCRE4IYxDKCbDk6yKhg0RS AreFy3vAgPzMKmhfrQPlepAEn4XTqIT/pnoyGIJPMZO7J4QeJvYX9B2QBilJPvq36EOQ oO0tPpKtmVaZUHh6+CtcC04wlN4HlyzqBARTVWzXOcMLtlyCwtQCDxABQ6U3KL/LcoDY A/Ll4cv46GdAHTfi5qGCXBH2kk2c2yO9sAfFuMIWufQbdKl3VLYfbwLgIkAFBvcMOtPv og7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=2hurj6fg; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id bd11-20020a656e0b000000b00399621efa3csi3640324pgb.317.2022.04.06.07.41.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 07:41:59 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=2hurj6fg; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 94198653F11; Wed, 6 Apr 2022 05:28:00 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1845562AbiDFBzD (ORCPT + 99 others); Tue, 5 Apr 2022 21:55:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43648 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349534AbiDEJuI (ORCPT ); Tue, 5 Apr 2022 05:50:08 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45EAF229; Tue, 5 Apr 2022 02:48:10 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id AB678CE1C6C; Tue, 5 Apr 2022 09:48:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C8F12C385A2; Tue, 5 Apr 2022 09:48:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649152087; bh=rdP+btfujumuIu3/jnl32qr0EKP44WX3lE/wBICng7E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2hurj6fgx/2+w9NsZFd8fLwXKA8xWOhdcdrMqMpU8Yzv7FwUctABnCLuRlO2GUuXj TZY1DWRApUUortzxCF4j9knIjVyoC8GqNPML6J4b/5RQAeF2NVvSQoRI9L8p5Wy78r nmvlLYYCDJuQ92OhINy42+hNGujbSmKXegnmUn7g= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sven Auhagen , Pablo Neira Ayuso , Sasha Levin Subject: [PATCH 5.15 649/913] netfilter: nf_conntrack_tcp: preserve liberal flag in tcp options Date: Tue, 5 Apr 2022 09:28:31 +0200 Message-Id: <20220405070359.292657705@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070339.801210740@linuxfoundation.org> References: <20220405070339.801210740@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Pablo Neira Ayuso [ Upstream commit f2dd495a8d589371289981d5ed33e6873df94ecc ] Do not reset IP_CT_TCP_FLAG_BE_LIBERAL flag in out-of-sync scenarios coming before the TCP window tracking, otherwise such connections will fail in the window check. Update tcp_options() to leave this flag in place and add a new helper function to reset the tcp window state. Based on patch from Sven Auhagen. Fixes: c4832c7bbc3f ("netfilter: nf_ct_tcp: improve out-of-sync situation in TCP tracking") Tested-by: Sven Auhagen Signed-off-by: Pablo Neira Ayuso Signed-off-by: Sasha Levin --- net/netfilter/nf_conntrack_proto_tcp.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/net/netfilter/nf_conntrack_proto_tcp.c b/net/netfilter/nf_conntrack_proto_tcp.c index af5115e127cf..3cee5d8ee702 100644 --- a/net/netfilter/nf_conntrack_proto_tcp.c +++ b/net/netfilter/nf_conntrack_proto_tcp.c @@ -341,8 +341,8 @@ static void tcp_options(const struct sk_buff *skb, if (!ptr) return; - state->td_scale = - state->flags = 0; + state->td_scale = 0; + state->flags &= IP_CT_TCP_FLAG_BE_LIBERAL; while (length > 0) { int opcode=*ptr++; @@ -839,6 +839,16 @@ static bool tcp_can_early_drop(const struct nf_conn *ct) return false; } +static void nf_ct_tcp_state_reset(struct ip_ct_tcp_state *state) +{ + state->td_end = 0; + state->td_maxend = 0; + state->td_maxwin = 0; + state->td_maxack = 0; + state->td_scale = 0; + state->flags &= IP_CT_TCP_FLAG_BE_LIBERAL; +} + /* Returns verdict for packet, or -1 for invalid. */ int nf_conntrack_tcp_packet(struct nf_conn *ct, struct sk_buff *skb, @@ -945,8 +955,7 @@ int nf_conntrack_tcp_packet(struct nf_conn *ct, ct->proto.tcp.last_flags &= ~IP_CT_EXP_CHALLENGE_ACK; ct->proto.tcp.seen[ct->proto.tcp.last_dir].flags = ct->proto.tcp.last_flags; - memset(&ct->proto.tcp.seen[dir], 0, - sizeof(struct ip_ct_tcp_state)); + nf_ct_tcp_state_reset(&ct->proto.tcp.seen[dir]); break; } ct->proto.tcp.last_index = index; -- 2.34.1