Netdev List
 help / color / mirror / Atom feed
From: Alice Mikityanska <alice.kernel@fastmail.im>
To: Paolo Abeni <pabeni@redhat.com>, Jakub Kicinski <kuba@kernel.org>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	Jason Wang <jasowangio@gmail.com>
Cc: "Eric Dumazet" <edumazet@google.com>,
	"David S. Miller" <davem@davemloft.net>,
	"Simon Horman" <horms@kernel.org>,
	"Xuan Zhuo" <xuanzhuo@linux.alibaba.com>,
	"Eugenio Pérez" <eperezma@redhat.com>,
	HanQuan <eilaimemedsnaimel@gmail.com>,
	"Hyunwoo Kim" <imv4bel@gmail.com>,
	"Sabrina Dubroca" <sd@queasysnail.net>,
	"Jason Xing" <kerneljasonxing@gmail.com>,
	"Kuniyuki Iwashima" <kuniyu@google.com>,
	"Björn Töpel" <bjorn@kernel.org>,
	"Sebastian Andrzej Siewior" <bigeasy@linutronix.de>,
	"Jiayuan Chen" <jiayuan.chen@linux.dev>,
	netdev@vger.kernel.org, "Alice Mikityanska" <alice@isovalent.com>
Subject: [PATCH net-next 3/3] net: Limit to GSO_MAX_SEGS in skb_gro_receive
Date: Thu, 23 Jul 2026 18:51:45 +0300	[thread overview]
Message-ID: <20260723155145.158572-4-alice.kernel@fastmail.im> (raw)
In-Reply-To: <20260723155145.158572-1-alice.kernel@fastmail.im>

From: Alice Mikityanska <alice@isovalent.com>

NAPI_GRO_CB(skb)->count is a 16-bit field used during GRO aggregation,
which gets assigned to skb_shinfo(skb)->gso_segs upon GRO completion.
While doing GRO aggregation in skb_gro_receive, make sure we don't
overflow this field.

Subtraction is intentional to avoid overflow.

Signed-off-by: Alice Mikityanska <alice@isovalent.com>
Assisted-by: Codex:GPT-5.6
---
 net/core/gro.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/net/core/gro.c b/net/core/gro.c
index 35f2f708f010..1a9d2a4f9a80 100644
--- a/net/core/gro.c
+++ b/net/core/gro.c
@@ -126,6 +126,9 @@ int skb_gro_receive(struct sk_buff *p, struct sk_buff *skb)
 	lp = NAPI_GRO_CB(p)->last;
 	pinfo = skb_shinfo(lp);
 
+	if (unlikely(segs > GSO_MAX_SEGS - NAPI_GRO_CB(p)->count))
+		return -E2BIG;
+
 	if (headlen <= offset) {
 		skb_frag_t *frag;
 		skb_frag_t *frag2;
-- 
2.55.0


      parent reply	other threads:[~2026-07-23 15:52 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-23 15:51 [PATCH net-next 0/3] Guard against gso_segs overflows Alice Mikityanska
2026-07-23 15:51 ` [PATCH net-next 1/3] net: Guard for gso_segs overflow in skb_segment Alice Mikityanska
2026-07-23 15:51 ` [PATCH net-next 2/3] virtio-net: Block malformed packets that overflow gso_segs Alice Mikityanska
2026-07-23 16:06   ` Eric Dumazet
2026-07-23 15:51 ` Alice Mikityanska [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260723155145.158572-4-alice.kernel@fastmail.im \
    --to=alice.kernel@fastmail.im \
    --cc=alice@isovalent.com \
    --cc=bigeasy@linutronix.de \
    --cc=bjorn@kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=eilaimemedsnaimel@gmail.com \
    --cc=eperezma@redhat.com \
    --cc=horms@kernel.org \
    --cc=imv4bel@gmail.com \
    --cc=jasowangio@gmail.com \
    --cc=jiayuan.chen@linux.dev \
    --cc=kerneljasonxing@gmail.com \
    --cc=kuba@kernel.org \
    --cc=kuniyu@google.com \
    --cc=mst@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sd@queasysnail.net \
    --cc=xuanzhuo@linux.alibaba.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox