* [PATCH v6] net: gro: fix double aggregation of flush-marked skbs
@ 2026-07-07 2:14 Shiming Cheng
2026-07-07 15:16 ` Willem de Bruijn
0 siblings, 1 reply; 3+ messages in thread
From: Shiming Cheng @ 2026-07-07 2:14 UTC (permalink / raw)
To: davem, edumazet, kuba, pabeni, horms, matthias.bgg,
angelogioacchino.delregno, willemb, daniel.zahka, alice, sd,
eilaimemedsnaimel, imv4bel, nbd, dsahern, netdev, linux-kernel,
linux-arm-kernel, linux-mediatek
Cc: stable, steffen.klassert, lena.wang, shiming.cheng
The skb_gro_receive_list() function is missing a critical safety check
that exists in the skb_gro_receive() implementation. Specifically, it
does not validate NAPI_GRO_CB(skb)->flush before allowing packet
aggregation, as of commit 0ab03f353d36 ("net-gro: Fix GRO flush
when receiving a GSO packet.").
This allows already-GRO'd packets with existing frag_list to be
re-aggregated into a new GRO session, corrupting the frag_list chain
structure. When skb_segment() attempts to unpack these malformed packets,
it encounters invalid state and triggers a kernel panic.
Scenario (Tethering/Device forwarding):
1. Driver: Generated aggregated packet P1 via LRO with frag_list
2. Dev A: Receives aggregated fraglist packet and flush flag set
3. Dev A: Re-enters GRO, skb_gro_receive_list() is called
4. Missing flush check allows re-aggregation despite flush flag
5. Frag_list chain becomes corrupted (loops or dangling refs)
6. Dev B: TX path calls skb_segment(), crashes on corrupted frag_list
Root cause in skb_segment():
The check at line ~4891:
if (hsize <= 0 && i >= nfrags && skb_headlen(list_skb) &&
(skb_headlen(list_skb) == len || sg)) {
When frag_list is corrupted by double aggregation, when list_skb is
a NULL pointer from skb->next, skb_headlen(list_skb) dereference
NULL/corrupted pointers occurs.
Call Trace:
skb_headlen(NULL skb)
skb_segment
tcp_gso_segment
tcp4_gso_segment
inet_gso_segment
skb_mac_gso_segment
__skb_gso_segment
skb_gso_segment
validate_xmit_skb
validate_xmit_skb_list
sch_direct_xmit
qdisc_restart
__qdisc_run
qdisc_run
net_tx_action
Fix: Add NAPI_GRO_CB(skb)->flush validation to the early-return check in
skb_gro_receive_list(), matching the defensive programming pattern of
skb_gro_receive().
Fixes: 3a1296a38d0c ("net: Support GRO/GSO fraglist chaining.")
Cc: stable@vger.kernel.org
Signed-off-by: Shiming Cheng <shiming.cheng@mediatek.com>
---
net/core/gro.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/net/core/gro.c b/net/core/gro.c
index 35f2f708f010..b413f4a6462b 100644
--- a/net/core/gro.c
+++ b/net/core/gro.c
@@ -229,7 +229,9 @@ int skb_gro_receive(struct sk_buff *p, struct sk_buff *skb)
int skb_gro_receive_list(struct sk_buff *p, struct sk_buff *skb)
{
- if (unlikely(p->len + skb->len >= 65536))
+ /* make sure to check flush flag and to not merge */
+ if (unlikely(p->len + skb->len >= 65536 ||
+ NAPI_GRO_CB(skb)->flush))
return -E2BIG;
if (!pskb_may_pull(skb, skb_gro_offset(skb))) {
--
2.45.2
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH v6] net: gro: fix double aggregation of flush-marked skbs
2026-07-07 2:14 [PATCH v6] net: gro: fix double aggregation of flush-marked skbs Shiming Cheng
@ 2026-07-07 15:16 ` Willem de Bruijn
2026-07-08 1:41 ` Shiming Cheng (成诗明)
0 siblings, 1 reply; 3+ messages in thread
From: Willem de Bruijn @ 2026-07-07 15:16 UTC (permalink / raw)
To: Shiming Cheng, davem, edumazet, kuba, pabeni, horms, matthias.bgg,
angelogioacchino.delregno, willemb, daniel.zahka, alice, sd,
eilaimemedsnaimel, imv4bel, nbd, dsahern, netdev, linux-kernel,
linux-arm-kernel, linux-mediatek
Cc: stable, steffen.klassert, lena.wang, shiming.cheng
Shiming Cheng wrote:
> The skb_gro_receive_list() function is missing a critical safety check
> that exists in the skb_gro_receive() implementation. Specifically, it
> does not validate NAPI_GRO_CB(skb)->flush before allowing packet
> aggregation, as of commit 0ab03f353d36 ("net-gro: Fix GRO flush
> when receiving a GSO packet.").
It does not check .. as of commit .. ?
No, skb_gro_receive checkos NAP_GRO_CB(skb)->flush as of that commit.
> This allows already-GRO'd packets with existing frag_list to be
> re-aggregated into a new GRO session, corrupting the frag_list chain
> structure. When skb_segment() attempts to unpack these malformed packets,
> it encounters invalid state and triggers a kernel panic.
>
> Scenario (Tethering/Device forwarding):
> 1. Driver: Generated aggregated packet P1 via LRO with frag_list
> 2. Dev A: Receives aggregated fraglist packet and flush flag set
> 3. Dev A: Re-enters GRO, skb_gro_receive_list() is called
> 4. Missing flush check allows re-aggregation despite flush flag
> 5. Frag_list chain becomes corrupted (loops or dangling refs)
> 6. Dev B: TX path calls skb_segment(), crashes on corrupted frag_list
>
> Root cause in skb_segment():
> The check at line ~4891:
> if (hsize <= 0 && i >= nfrags && skb_headlen(list_skb) &&
> (skb_headlen(list_skb) == len || sg)) {
>
> When frag_list is corrupted by double aggregation, when list_skb is
> a NULL pointer from skb->next, skb_headlen(list_skb) dereference
> NULL/corrupted pointers occurs.
>
> Call Trace:
> skb_headlen(NULL skb)
> skb_segment
> tcp_gso_segment
> tcp4_gso_segment
> inet_gso_segment
> skb_mac_gso_segment
> __skb_gso_segment
> skb_gso_segment
> validate_xmit_skb
> validate_xmit_skb_list
> sch_direct_xmit
> qdisc_restart
> __qdisc_run
> qdisc_run
> net_tx_action
>
> Fix: Add NAPI_GRO_CB(skb)->flush validation to the early-return check in
> skb_gro_receive_list(), matching the defensive programming pattern of
> skb_gro_receive().
>
> Fixes: 3a1296a38d0c ("net: Support GRO/GSO fraglist chaining.")
> Cc: stable@vger.kernel.org
> Signed-off-by: Shiming Cheng <shiming.cheng@mediatek.com>
> ---
> net/core/gro.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/net/core/gro.c b/net/core/gro.c
> index 35f2f708f010..b413f4a6462b 100644
> --- a/net/core/gro.c
> +++ b/net/core/gro.c
> @@ -229,7 +229,9 @@ int skb_gro_receive(struct sk_buff *p, struct sk_buff *skb)
>
> int skb_gro_receive_list(struct sk_buff *p, struct sk_buff *skb)
> {
> - if (unlikely(p->len + skb->len >= 65536))
> + /* make sure to check flush flag and to not merge */
> + if (unlikely(p->len + skb->len >= 65536 ||
> + NAPI_GRO_CB(skb)->flush))
> return -E2BIG;
>
> if (!pskb_may_pull(skb, skb_gro_offset(skb))) {
> --
> 2.45.2
>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH v6] net: gro: fix double aggregation of flush-marked skbs
2026-07-07 15:16 ` Willem de Bruijn
@ 2026-07-08 1:41 ` Shiming Cheng (成诗明)
0 siblings, 0 replies; 3+ messages in thread
From: Shiming Cheng (成诗明) @ 2026-07-08 1:41 UTC (permalink / raw)
To: linux-kernel@vger.kernel.org, dsahern@kernel.org,
imv4bel@gmail.com, linux-mediatek@lists.infradead.org,
alice@isovalent.com, daniel.zahka@gmail.com,
eilaimemedsnaimel@gmail.com, nbd@nbd.name, horms@kernel.org,
kuba@kernel.org, pabeni@redhat.com, edumazet@google.com,
willemdebruijn.kernel@gmail.com, willemb@google.com,
netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
matthias.bgg@gmail.com, davem@davemloft.net,
AngeloGioacchino Del Regno, sd@queasysnail.net
Cc: steffen.klassert@secunet.com, stable@vger.kernel.org,
Lena Wang (王娜)
On Tue, 2026-07-07 at 11:16 -0400, Willem de Bruijn wrote:
> External email : Please do not click links or open attachments until
> you have verified the sender or the content.
>
>
> Shiming Cheng wrote:
> > The skb_gro_receive_list() function is missing a critical safety
> > check
> > that exists in the skb_gro_receive() implementation. Specifically,
> > it
> > does not validate NAPI_GRO_CB(skb)->flush before allowing packet
> > aggregation, as of commit 0ab03f353d36 ("net-gro: Fix GRO flush
> > when receiving a GSO packet.").
>
> It does not check .. as of commit .. ?
>
> No, skb_gro_receive checkos NAP_GRO_CB(skb)->flush as of that commit.
>
Is this wording okay?
Commit 0ab03f353d36 ("net-gro: Fix GRO flush when receiving a GSO
packet.") added a flush check to skb_gro_receive(), but
skb_gro_receive_list() lacks the same validation.
As a result, packets marked with NAPI_GRO_CB(skb)->flush may still be
re-aggregated.
> > This allows already-GRO'd packets with existing frag_list to be
> > re-aggregated into a new GRO session, corrupting the frag_list
> > chain
> > structure. When skb_segment() attempts to unpack these malformed
> > packets,
> > it encounters invalid state and triggers a kernel panic.
> >
> > Scenario (Tethering/Device forwarding):
> > 1. Driver: Generated aggregated packet P1 via LRO with frag_list
> > 2. Dev A: Receives aggregated fraglist packet and flush flag set
> > 3. Dev A: Re-enters GRO, skb_gro_receive_list() is called
> > 4. Missing flush check allows re-aggregation despite flush flag
> > 5. Frag_list chain becomes corrupted (loops or dangling refs)
> > 6. Dev B: TX path calls skb_segment(), crashes on corrupted
> > frag_list
> >
> > Root cause in skb_segment():
> > The check at line ~4891:
> > if (hsize <= 0 && i >= nfrags && skb_headlen(list_skb) &&
> > (skb_headlen(list_skb) == len || sg)) {
> >
> > When frag_list is corrupted by double aggregation, when list_skb
> > is
> > a NULL pointer from skb->next, skb_headlen(list_skb) dereference
> > NULL/corrupted pointers occurs.
> >
> > Call Trace:
> > skb_headlen(NULL skb)
> > skb_segment
> > tcp_gso_segment
> > tcp4_gso_segment
> > inet_gso_segment
> > skb_mac_gso_segment
> > __skb_gso_segment
> > skb_gso_segment
> > validate_xmit_skb
> > validate_xmit_skb_list
> > sch_direct_xmit
> > qdisc_restart
> > __qdisc_run
> > qdisc_run
> > net_tx_action
> >
> > Fix: Add NAPI_GRO_CB(skb)->flush validation to the early-return
> > check in
> > skb_gro_receive_list(), matching the defensive programming pattern
> > of
> > skb_gro_receive().
> >
> > Fixes: 3a1296a38d0c ("net: Support GRO/GSO fraglist chaining.")
> > Cc: stable@vger.kernel.org
> > Signed-off-by: Shiming Cheng <shiming.cheng@mediatek.com>
> > ---
> > net/core/gro.c | 4 +++-
> > 1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/net/core/gro.c b/net/core/gro.c
> > index 35f2f708f010..b413f4a6462b 100644
> > --- a/net/core/gro.c
> > +++ b/net/core/gro.c
> > @@ -229,7 +229,9 @@ int skb_gro_receive(struct sk_buff *p, struct
> > sk_buff *skb)
> >
> > int skb_gro_receive_list(struct sk_buff *p, struct sk_buff *skb)
> > {
> > - if (unlikely(p->len + skb->len >= 65536))
> > + /* make sure to check flush flag and to not merge */
> > + if (unlikely(p->len + skb->len >= 65536 ||
> > + NAPI_GRO_CB(skb)->flush))
> > return -E2BIG;
> >
> > if (!pskb_may_pull(skb, skb_gro_offset(skb))) {
> > --
> > 2.45.2
> >
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-07-08 1:41 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-07 2:14 [PATCH v6] net: gro: fix double aggregation of flush-marked skbs Shiming Cheng
2026-07-07 15:16 ` Willem de Bruijn
2026-07-08 1:41 ` Shiming Cheng (成诗明)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox