Article View: linux.kernel.netdev
Article #3052Re: [PATCH] net: tcp: fix fraglist GRO flushing on alternating TCP PSH flag
From: Willem de Bruijn
Date: Wed, 14 Oct 2026 04:10
Date: Wed, 14 Oct 2026 04:10
251 lines
16500 bytes
16500 bytes
netdev-bot+sashiko@ wrote:
> Thank you for your contribution! Sashiko AI review found 3 potential
> issue(s) to consider.
>
> Critical: 0 Ā· High: 2 Ā· Medium: 1 Ā· Low: 0
>
> If you believe none of the issues are legitimate, please reply to each
> issue of Medium severity or higher and explain why the AI is wrong.
> If any of them are legitimate and you plan to respin, please let patchwork
> know by including "pw-bot: cr" as a separate line at the end of your reply
> (one such reply per series is enough).
>
> - [High] Forwarded TCP FIN/PSH can be dropped from the wire when a
> fraglist GRO skb falls back to tcp_gso_segment()/skb_segment().
> - [High] FIN/PSH in a fraglist tail segment is invisible to netfilter,
> conntrack, flowtable, tc and BPF, which all read only the aggregate'sā¦
> - [Medium] The commit message calls the removed check 'redundant' and
> only discusses PSH.
>
> --
>
> net: tcp: fix fraglist GRO flushing on alternating TCP PSH flag
>
> This patch removes the unmasked TCP flag word comparison from the is_flist
> branch of tcp_gro_receive(). Segments whose PSH/FIN flags differ from the
> held packet can then be appended to a fraglist GRO skb. The goal is to stop
> premature flushes when a sender alternates [ACK] and [PSH, ACK] segments
> in forwarding and tethering setups.
>
> > This redundant check causes premature flushing on any incoming PSH packet,
> > shattering aggregation and increasing softirq overhead.
>
> [ ... ]
>
> > a single fraglist, and are safely flushed together upon encountering the
> > PSH flag at `out_check_final`, preserving the required TCP push semantics.
>
> [Severity: Medium]
> Is the removed check really redundant? Commit 8d95dc474f85 ("net: add code
> for TCP fraglist GRO") added it to the is_flist branch on purpose.
>
> The general path can mask FIN|PSH out of its first comparison only because
> it later ORs those flags into the held packet's header:
>
> tcp_flag_word(th2) |= flags & (TCP_FLAG_FIN | TCP_FLAG_PSH);
Indeed. PSH bits are important information and are expected to close
a context.
> The is_flist branch jumps to out_check_final before it reaches that line.
> So the unmasked comparison was what kept every fraglist member's flags
> identical to the head's.
>
> The removal also relaxes FIN, not only PSH. Data-carrying FIN segments,
> such as the last segment of a response, can now join a fraglist. The
> commit message doesn't mention this.
>
> The claim that push semantics are preserved seems to hold only when the
> skb goes through skb_segment_list(). Could the commit message describe the
> FIN change and the cases raised in the comments on the diff below?
>
> > diff --git a/net/ipv4/tcp_offload.c b/net/ipv4/tcp_offload.c
> > index e74d99ca9face..54b40ec95a080 100644
> > --- a/net/ipv4/tcp_offload.c
> > +++ b/net/ipv4/tcp_offload.c
> > @@ -328,7 +328,6 @@ struct sk_buff *tcp_gro_receive(struct list_head *head, struct sk_buff *skb,
> > flush |= skb_cmp_decrypted(p, skb);
> >
> > if (unlikely(NAPI_GRO_CB(p)->is_flist)) {
> > - flush |= (__force int)(flags ^ tcp_flag_word(th2));
>
> [Severity: High]
> Can this drop a forwarded FIN or PSH from the wire?
>
> Without this check, skb_gro_receive_list() links an in-sequence [PSH, ACK]
> or [FIN, ACK] data segment into the held skb's frag_list. The is_flist
> branch then jumps to out_check_final. That skips the only place where
> FIN/PSH reach the head header:
>
> tcp_flag_word(th2) |= flags & (TCP_FLAG_FIN | TCP_FLAG_PSH);
>
> tcp4_gro_complete() and tcp6_gro_complete() return early for is_flist.
> The head can't carry FIN/PSH itself, because out_check_final would have
> flushed it. So the head header has neither flag, while the last frag_list
> member has them.
>
> tcp4_gso_segment() uses __tcp4_gso_segment_list() only when the geometry
> still matches and SKB_GSO_DODGY is clear:
>
> if ((skb_pagelen(skb) - th->doff * 4 == skb_shinfo(skb)->gso_size) &&
> !(skb_shinfo(skb)->gso_type & SKB_GSO_DODGY))
> return __tcp4_gso_segment_list(skb, features);
>
> Otherwise it falls back to tcp_gso_segment()->skb_segment(). That path
> copies head_skb's headers, TCP flags included, into every segment.
>
> tcp_gso_segment() then clears fin/psh on every segment except the last:
>
> while (skb->next) {
> th->fin = th->psh = 0;
>
> The last segment keeps the head's flags, which never had FIN/PSH.
> tcp6_gso_segment() has the same fallback.
>
> These can trigger the fallback on forwarded traffic:
>
> bpf_skb_proto_4_to_6() and bpf_skb_proto_6_to_4(), reached through
> bpf_skb_change_proto() (for example CLAT/464xlat when tethering), set
> SKB_GSO_DODGY on GSO skbs.
>
> bpf_skb_net_grow() and bpf_skb_net_shrink() set SKB_GSO_DODGY.
> bpf_skb_net_grow() can also linearize frag_list skbs when
> BPF_F_ADJ_ROOM_FIXED_GSO is not set.
>
> Any pull or linearize that changes the geometry has the same effect,
> for example skb_ensure_writable(skb, skb->len) in NAT mangling.
>
> In those cases the receiver doesn't get the FIN until the sender
> retransmits it, and PSH is silently cleared.
>
> A fraglist skb redirected to a local TCP socket after GRO (DNAT/TPROXY) is
> also parsed from the head header only. TCP has nothing like UDP's
> local-delivery fraglist handling, so the FIN would be missed there too.
>
> ORing the tail's flags into th2 in the is_flist branch doesn't seem to fix
> this. skb_segment_list() emits the head skb with its own TCP header, so the
> first segment would then carry a spurious FIN/PSH.
>
> [Severity: High]
> Does this also hide the tail's FIN/PSH from netfilter, conntrack,
> flowtable, tc and BPF? All of these read only the aggregate's head header
> before segmentation.
>
> In conntrack, get_conntrack_index() only checks the head's tcph->fin, so
> the FIN transition never fires. tcp_in_window() computes:
>
> end = segment_seq_plus_len(seq, skb->len, dataoff, tcph);
>
> skb->len covers all of the fraglist payload. The +1 for FIN is missing,
> because tcph is the head header. The peer's ACK of the FIN then hits:
>
> if (!before(sack, receiver->td_end + 1))
> return nf_tcp_store_invalid(ct, sender, log, NFCT_TCP_INVALID,
> NF_TCP_LOG_ACK_OVER, receiver->td_end + 1);
>
> That ACK is classified invalid, and so are the peer's own FIN and the
> final ACK. A typical "ct state invalid drop" rule would then drop the
> teardown packets. Without such a rule, the entry stays ESTABLISHED instead
> of moving to FIN_WAIT/CLOSE_WAIT.
>
> In the flowtable, nf_flow_state_check() reads fin/rst only from the head
> header, so NF_FLOW_CLOSING is never set for the offloaded flow.
>
> tcp_mt() in xt_tcpudp and the nft tcp flags match also read only the head
> header, so a FORWARD rule that matches FIN or PSH won't fire.
> skb_segment_list() copies only the MAC header from the head and keeps each
> member's own TCP header. The FIN/PSH therefore still goes out on the wire
> and bypasses that policy.
>
> Before this patch, the unmasked comparison guaranteed that the head header
> described every member of the fraglist.
>
> [ ... ]
>
> --
> Sashiko AI review Ā· https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261009060319.6229-1-shiming.cheng%40mediatek.com
Technical Details
Message-ID:
<willemdebruijn.kernel.26605ed441a3a@gmail.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-346010-linux-kernel-netdev=dewy.ruReferences:
<20261009060319.6229-1-shiming.cheng@mediatek.com> <179161428655.434549.7066789783316941855@kernel.org>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-346010-linux-kernel-netdev=dewy.ru
From: willemdebruijn.kernel@gmail.com (Willem de Bruijn)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH] net: tcp: fix fraglist GRO flushing on alternating TCP
PSH flag
Date: Wed, 14 Oct 2026 00:10:23 -0400
Organization: Usenet Network
Message-ID: <willemdebruijn.kernel.26605ed441a3a@gmail.com>
References: <20261009060319.6229-1-shiming.cheng@mediatek.com>
<179161428655.434549.7066789783316941855@kernel.org>
MIME-Version: 1.0
Content-Type: text/plain;
charset=utf-8
Content-Transfer-Encoding: quoted-printable
Injection-Info: usenet.network;
logging-data="2213316"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:G0HAf5Z/pBuyHxuHAVowInWLZLk= sha256:Jg4KrrpJ7Zk9/LGemBuDCMZlatSo2xJ9n2FtIsm6rGs=
sha1:iyBvEdA9/B/wQviwuVqT7DtSrb0= sha256:+QW2Ek4Yf8SZkP1uktT7TaFEbU6XQlK+q9QP8y+cE24=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
by mail.dewy.ru (Postfix) with ESMTP id E5FBD10FFDA; Wed, 14 Oct 2026 07:11:00 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.046
X-Spam-Status: No, score=-3.046 tagged_above=-9999 required=6.31
tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
DKIM_VALID_AU=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001,
FREEMAIL_FROM=0.001, FSL_HELO_FAKE=0.001,
HEADER_FROM_DIFFERENT_DOMAINS=0.25, MAILING_LIST_MULTI=-1,
RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001,
URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
header.d=gmail.com
X-Received: from mail.dewy.ru ([127.0.0.1])
by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
with ESMTP id vi5RwiWLI_Zn;
Wed, 14 Oct 2026 07:10:53 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-346010-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
by mail.dewy.ru (Postfix) with ESMTPS id 47D6F10FFC4; Wed, 14 Oct 2026 07:10:44 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1])
by sea.lore.kernel.org (Postfix) with ESMTP id 8968530F82; Wed, 14 Oct 2026 04:10:29 +0000 (UTC)
X-Received: from localhost.localdomain (localhost.localdomain [127.0.0.1])
by smtp.subspace.kernel.org (Postfix) with ESMTP id ACACF3C1D7E;
Wed, 14 Oct 2026 04:10:27 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="crh0/b6q"
X-Received: from mail-yx1-f41.google.com (mail-yx1-f41.google.com [74.125.224.41])
(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
(No client certificate requested)
by smtp.subspace.kernel.org (Postfix) with ESMTPS id 20B83279DCC
for <netdev@vger.kernel.org>; Wed, 14 Oct 2026 04:10:25 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.224.41
X-ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
t=1791951027; cv=none; b=ufg8KmLpJdxTnViJ9o6V1xJ/f1gHwo/Xq2FUKOV/gevXTZd8BpLosn7pd+cMBkMjkQK2XYsE8dRfa1EnKvjNBF1uhDWSL8b5fdkhT2M2p/fuOaH/Bs5/fnUxGvLNYWS+/GQTQwjWb/r1O8wZHvxiJ5MTgonsUiP4Rgtu70Hp88k=
X-ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org;
s=arc-20240116; t=1791951027; c=relaxed/simple;
bh=V4ngBpPUODuuWu2An2bhgPhwDi9OupCikjo5ZiTj6uY=;
h=Date:From:To:Cc:Message-ID:In-Reply-To:References:Subject:
MIME-Version:Content-Type; b=cRz7pDFz+3E3V9X1Khedb7CC8UceGEHHRmZj9IH0W2ZpaqusYQC1/TKYVg+AwRf4hY6M2Db0wvOwwR2H5BR3zXYMZf4feNjvEkvNkO4ZIdW2F+sCMp7Q1M/0AbjSeCr8r+dcYpRwXdt2PUizrBj0DRht+vPRMRhkaHZ+Yrpai3s=
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=crh0/b6q; arc=none smtp.client-ip=74.125.224.41
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-yx1-f41.google.com with SMTP id 956f58d0204a3-675617e81f9so3946725d50.3
for <netdev@vger.kernel.org>; Tue, 13 Oct 2026 21:10:25 -0700 (PDT)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20251104; t=1791951025; x=1792555825; darn=vger.kernel.org;
h=content-transfer-encoding:content-type:mime-version:subject
:references:in-reply-to:message-id:cc:to:from:date:from:to:cc
:subject:date:message-id:reply-to:content-type;
bh=ljQtddetZrnHdZkhpewiA0nv8+K0Dn1c6TsFqcV3Ues=;
b=crh0/b6qeHxfbLpCS7mTQbEah3x1+AZmPE5EIHcMjrrHZ7tgdUI14W9aOugAZxzycw
ohqQ3RhOypRFYyX84th92UAoznpNg7eXE40Ff9viYmYCQ/xagSMX3LD3jTEB+6vK/Myo
savjdWLABbnm4y44VYj8ukZSOZo9+ifBtqgJYkvi7yots4Wg+W0VgbmOZ/rhEZnMCSoi
ueY2Cr+oR72Pf/GBgTrBytPqL5uZaHI7p5E6/+EtbWNWiMoxM++YQabo7TmP4LXtW9qO
0YIbr9wup7rLsRKaiu4dvE3LwsuErwwdqYXo1ktFjw+P72lhMbYAgKnJz+q52/jCPc0j
G3WA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1791951025; x=1792555825;
h=content-transfer-encoding:content-type:mime-version:subject
:references:in-reply-to:message-id:cc:to:from:date:x-gm-gg
:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to
:content-type;
bh=ljQtddetZrnHdZkhpewiA0nv8+K0Dn1c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3g/09b6bVpD1z6tPxygeJ4dWEN+6eN7mVDFmc/Q+4hDKGcqzbSK
0Kkn588ywayZDzUXoaku55uh4MWh9R+Ujwc+h4kMIDWluBUJM44RVEto7etp8daUgZYSfO5HVWV
LDmybEn7nmsbPOOACG2YmvrJzEctzEJbW9h3OQ==
X-Received: by 2002:a05:690e:e8b:b0:675:4269:156b with SMTP id 956f58d0204a3-679369e3642mr4947534d50.59.1791951024885;
Tue, 13 Oct 2026 21:10:24 -0700 (PDT)
X-Received: from gmail.com (111.46.245.35.bc.googleusercontent.com. [35.245.46.111])
by smtp.gmail.com with ESMTPSA id 956f58d0204a3-67986a16470sm592229d50.4.2026.10.13.21.10.23
(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
Tue, 13 Oct 2026 21:10:24 -0700 (PDT)
X-Cc: davem@davemloft.net,
edumazet@google.com,
kuba@kernel.org,
pabeni@redhat.com,
horms@kernel.org,
matthias.bgg@gmail.com,
angelogioacchino.delregno@collabora.com,
willemb@google.com,
daniel.zahka@gmail.com,
alice@isovalent.com,
sd@queasysnail.net,
eilaimemedsnaimel@gmail.com,
imv4bel@gmail.com,
nbd@nbd.name,
dsahern@kernel.org,
netdev@vger.kernel.org,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-mediatek@lists.infradead.org,
stable@vger.kernel.org,
steffen.klassert@secunet.com
X-In-Reply-To: <179161428655.434549.7066789783316941855@kernel.org>
X-Precedence: bulk
X-Mailing-List: netdev@vger.kernel.org
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>