From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B9F333DC687; Sat, 28 Feb 2026 17:40:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772300452; cv=none; b=H3NGstQCwwMREaq+x0iTXc/+B0RMJP0kazmUKnHsXM2x+XddwNHTsRvstGSJfvEoYkwMQ+JHRbP/LsHXoVbSB2jFP1nNfucs00EsXGyVmu3/OqP6A7dyDWvRt9HhpyE3reWEFmPewvj7BCFPE/78eVuCqhYEqR34uwMcTyS80ys= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772300452; c=relaxed/simple; bh=xctf/FX59r6/hlv+aEw3/WUbikDEiYAqTmsBHZN29J8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FTy69nazgs0IoyD+Ozt3rOTS3XRRmalhN+Mj/wyBC1bYMNyQstEilQ4Kxyy8E0bJXYnWoNw39ZA4KIpB4UJg5of0ArmZHmaxmx4Gp29EyRGPQqdnkXJ0kZuJ6joEkv5mho4Bga43Qb2RvC0ln4s8s8+cxqPBuPnfm1QqeMQzlvY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ZREm1Jhr; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ZREm1Jhr" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A3AC7C19424; Sat, 28 Feb 2026 17:40:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1772300452; bh=xctf/FX59r6/hlv+aEw3/WUbikDEiYAqTmsBHZN29J8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZREm1Jhrdc6CGojS7X2/PvXVU+dsl3OFKYDsaQaMLCCsNqaAlhxUUPGHqze4WCvc6 C5z6q82jxed2mNWBeXZi8bGU7o0qfM1/DrXhk7vWqnb2YoPkzgV/t2fJh1vtU0KV8Z t8Kz5YLwh8HZL5aWsVXLXWRHNgYj1qsYNpWd2pdJtZ21F5kWwDnKlzvLWuFUzVd38D u26kPoBtpKfT2Stp8b4BN5TwmNBTMzT4HEQVcCu3FGe6XVEZMWFZPTghpRV28C8IcP E3R2qQjZwnRxoiiOpaF6S2zR7h0l//PqxFWia65C5x6lIWgWy5AAcjQOqS/gH/h32H XklSq0D9czZCw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Simon Baatz , Eric Dumazet , Kuniyuki Iwashima , Jakub Kicinski , Sasha Levin Subject: [PATCH 6.19 492/844] tcp: re-enable acceptance of FIN packets when RWIN is 0 Date: Sat, 28 Feb 2026 12:26:45 -0500 Message-ID: <20260228173244.1509663-493-sashal@kernel.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260228173244.1509663-1-sashal@kernel.org> References: <20260228173244.1509663-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit From: Simon Baatz [ Upstream commit 1e3bb184e94125bae7c1703472109a646d0f79d9 ] Commit 2bd99aef1b19 ("tcp: accept bare FIN packets under memory pressure") allowed accepting FIN packets in tcp_data_queue() even when the receive window was closed, to prevent ACK/FIN loops with broken clients. Such a FIN packet is in sequence, but because the FIN consumes a sequence number, it extends beyond the window. Before commit 9ca48d616ed7 ("tcp: do not accept packets beyond window"), tcp_sequence() only required the seq to be within the window. After that change, the entire packet (including the FIN) must fit within the window. As a result, such FIN packets are now dropped and the handling path is no longer reached. Be more lenient by not counting the sequence number consumed by the FIN when calling tcp_sequence(), restoring the previous behavior for cases where only the FIN extends beyond the window. Fixes: 9ca48d616ed7 ("tcp: do not accept packets beyond window") Signed-off-by: Simon Baatz Reviewed-by: Eric Dumazet Reviewed-by: Kuniyuki Iwashima Link: https://patch.msgid.link/20260224-fix_zero_wnd_fin-v2-1-a16677ea7cea@gmail.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- net/ipv4/tcp_input.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 0d080a3e27d6f..aa4f5bf765596 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -4611,15 +4611,24 @@ static enum skb_drop_reason tcp_disordered_ack_check(const struct sock *sk, */ static enum skb_drop_reason tcp_sequence(const struct sock *sk, - u32 seq, u32 end_seq) + u32 seq, u32 end_seq, + const struct tcphdr *th) { const struct tcp_sock *tp = tcp_sk(sk); + u32 seq_limit; if (before(end_seq, tp->rcv_wup)) return SKB_DROP_REASON_TCP_OLD_SEQUENCE; - if (after(end_seq, tp->rcv_nxt + tcp_receive_window(tp))) { - if (after(seq, tp->rcv_nxt + tcp_receive_window(tp))) + seq_limit = tp->rcv_nxt + tcp_receive_window(tp); + if (unlikely(after(end_seq, seq_limit))) { + /* Some stacks are known to handle FIN incorrectly; allow the + * FIN to extend beyond the window and check it in detail later. + */ + if (!after(end_seq - th->fin, seq_limit)) + return SKB_NOT_DROPPED_YET; + + if (after(seq, seq_limit)) return SKB_DROP_REASON_TCP_INVALID_SEQUENCE; /* Only accept this packet if receive queue is empty. */ @@ -6145,7 +6154,8 @@ static bool tcp_validate_incoming(struct sock *sk, struct sk_buff *skb, step1: /* Step 1: check sequence number */ - reason = tcp_sequence(sk, TCP_SKB_CB(skb)->seq, TCP_SKB_CB(skb)->end_seq); + reason = tcp_sequence(sk, TCP_SKB_CB(skb)->seq, + TCP_SKB_CB(skb)->end_seq, th); if (reason) { /* RFC793, page 37: "In all states except SYN-SENT, all reset * (RST) segments are validated by checking their SEQ-fields." -- 2.51.0