When skb_gro_header_slow() fails to pull the Ethernet header in napi_frags_skb() (for instance on an unreadable net_iov fragment without a linear header, or a short/malformed packet), the skb still has its attached fragments (nr_frags > 0, data_len > 0). Calling napi_reuse_skb() on this error path caches the dirty skb back onto napi->skb without releasing or clearing its fragments, leaking attached fragments and corrupting length metadata for the next napi_get_frags() call. In addition, napi_gro_frags() passes the resulting NULL skb straight into trace_napi_gro_frags_entry() and dev_gro_receive(), dereferencing a NULL pointer. Free the skb with kfree_skb() in napi_frags_skb() on header-pull failure so attached fragments are released cleanly with their original recycling state intact, and return GRO_CONSUMED in napi_gro_frags() when napi_frags_skb() returns NULL. This issue was found by code inspection while developing per-socket devmem RX and reproduced and verified with the accompanying net_test KUnit tests. Fixes: f55720680080 ("gro: Fix page ref count for skbs freed normally") Fixes: 1d11fa696733 ("net-gro: remove GRO_DROP") Assisted-by: LLM Signed-off-by: Octavian Purdila --- net/core/gro.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/net/core/gro.c b/net/core/gro.c index 1241b23d66efa..fb730017fd3ba 100644 --- a/net/core/gro.c +++ b/net/core/gro.c @@ -776,7 +776,7 @@ static struct sk_buff *napi_frags_skb(struct napi_struct *napi) if (unlikely(!eth)) { net_warn_ratelimited("%s: dropping impossible skb from %s\n", __func__, napi->dev->name); - napi_reuse_skb(napi, skb); + kfree_skb(skb); return NULL; } } else { @@ -805,6 +805,9 @@ gro_result_t napi_gro_frags(struct napi_struct *napi) gro_result_t ret; struct sk_buff *skb = napi_frags_skb(napi); + if (unlikely(!skb)) + return GRO_CONSUMED; + trace_napi_gro_frags_entry(skb); ret = napi_frags_finish(napi, skb, dev_gro_receive(&napi->gro, skb)); -- 2.56.1.915.g69d5ec7298-goog