Article View: linux.kernel.netdev
Article #6517[PATCH net] net: harden qdisc_pkt_len_segs_init() against malicious GSO packets
From: Eric Dumazet
Date: Thu, 22 Oct 2026 15:54
Date: Thu, 22 Oct 2026 15:54
62 lines
9990 bytes
9990 bytes
An SKB_GSO_DODGY packet can carry untrusted gso_size and headers.
For instance, gso_size=1 and hdr_len=65532 for a 524275-byte frame
makes qdisc_pkt_len_segs_init() compute an accounted length of
about 4,294,574,091 bytes (after gso_segs silently wrapped in a u16).
With DRR quantum 256, the dequeue path then needs ~16.8 million
deficit refills before it can dequeue the skb, keeping the CPU in
the qdisc path long enough to trigger the soft-lockup watchdog.
Commit 8f735d64382d ("net/sched: bound qdisc_pkt_len to prevent
qdisc soft lockup") added QDISC_PKT_LEN_MAX to bound size table
amplification. Use the same bound for DODGY packets:
- Make gso_segs a u32 and drop packets whose segment count does
not fit GSO_MAX_SEGS, instead of silently truncating it.
- Drop packets whose estimated qdisc_pkt_len() would exceed
QDISC_PKT_LEN_MAX.
Fixes: 15e5a0307164 ("net_sched: better precise estimation on packet length for untrusted packets")
Reported-by: shaos <shawnq1@163.com>
Closes: https://lore.kernel.org/netdev/20261022144755.65025-1-shawnq1@163.com/
Signed-off-by: Eric Dumazet <edumazet@kernel.org>
Cc: Jamal Hadi Salim <jhs@mojatatu.com>
Cc: "Michael S. Tsirkin" <mst@redhat.com>
---
net/core/dev.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/net/core/dev.c b/net/core/dev.c
index e76762e29360ea87ade0846e4a4f9016dca587d6..573bcc9d67b1b1e21e844f054f0b51a172713a90 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -4175,7 +4175,7 @@ static enum skb_drop_reason qdisc_pkt_len_segs_init(struct sk_buff *skb)
{
struct skb_shared_info *shinfo = skb_shinfo(skb);
unsigned int hdr_len, tlen;
- u16 gso_segs;
+ u32 gso_segs;
qdisc_skb_cb(skb)->pkt_len = skb->len;
if (!shinfo->gso_size) {
@@ -4226,6 +4226,15 @@ static enum skb_drop_reason qdisc_pkt_len_segs_init(struct sk_buff *skb)
if (payload <= 0)
return SKB_DROP_REASON_SKB_BAD_GSO;
gso_segs = DIV_ROUND_UP(payload, shinfo->gso_size);
+ /* shinfo->gso_segs is a 16bit field.
+ * Also make sure untrusted gso_size/hdr_len can not inflate
+ * qdisc_pkt_len() beyond QDISC_PKT_LEN_MAX, or deficit
+ * schedulers could spin in their refill loops.
+ */
+ if (unlikely(gso_segs > GSO_MAX_SEGS ||
+ skb->len + (u64)(gso_segs - 1) * hdr_len >
+ QDISC_PKT_LEN_MAX))
+ return SKB_DROP_REASON_SKB_BAD_GSO;
shinfo->gso_segs = gso_segs;
qdisc_skb_cb(skb)->pkt_segs = gso_segs;
}
--
2.53.0
Technical Details
Message-ID:
<20261022155436.117507-1-edumazet@kernel.org>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-350673-linux-kernel-netdev=dewy.ruShow 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-350673-linux-kernel-netdev=dewy.ru From: edumazet@kernel.org (Eric Dumazet) Newsgroups: linux.kernel.netdev Subject: [PATCH net] net: harden qdisc_pkt_len_segs_init() against malicious GSO packets Date: Thu, 22 Oct 2026 17:54:36 +0200 Organization: Usenet Network Message-ID: <20261022155436.117507-1-edumazet@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="249596"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:sXa3QLFrt6JAxcUWxOVGOkFaOPE= sha256:m40YFUW0I3ZWAF32WxFdZD7kTaQY8eQLhZCtGKBbpsA= sha1:dPpEDG2JzdCxje8Mca2KYdTtXwM= sha256:6FEPjD3ii360WiJ/hq+kH4a6+RQfJp3+A6Z4+HlBoaE= 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 3A7C81112E8; Thu, 22 Oct 2026 18:57:55 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.739 X-Spam-Status: No, score=-3.739 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.339, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org 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 BGL02nysCnQw; Thu, 22 Oct 2026 18:57:51 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-350673-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id 54F5A1112E6; Thu, 22 Oct 2026 18:57:41 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by tor.lore.kernel.org (Postfix) with ESMTP id 915DE29C97; Thu, 22 Oct 2026 15:54:44 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1792684482; b=v2RUIfJ+bdO/2OyeECAXDhSfM/epUtyBgX8eB94aY/gBIK/Q9q/QocdiAh7JcB6DmjyI inzfrWu7UIz2P0V2mCXBib+7AtKl1Q5RAMby0vLpB65Mc/qj4YeSy0u2RIIj83kIEtCkR OWqk0Q0VyXqcQwuFgSufEHBM38tGt1dpKHbxdxmYHCOHcVdjCTStCqmzl+C6a0c9kFFqN tIXnKM7/WpxLKdbRQxpJlhiaCH8tnh0lx0ATFkTg8l+HPW5AkzZI9lAqXsNdJbb2r15mf HcWf0o/EdrXxB7e+lNKQPPRXMco4q5nXHttgPndKn+C+VGn9jfQjpI9dhPNZFmQbkRg== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1792684482; h=X-Original-To:Received:Received:DKIM-Signature:From:To:Cc:Subject: Date:Message-ID:X-Mailer:X-Mailing-List:List-Id:List-Post:List-Help: List-Subscribe:List-Unsubscribe:List-Owner:Precedence:MIME-Version: Content-Transfer-Encoding; bh=fw9MZRcOmU8Ehb4tKOD55KkHpTquvtk01ZhunBeT+b8=; b=2V2C9I0EzlcW5SrMwqX90Uk3prmeml/7Xzpm6h0PkDnYWEH7+Tq83HAPm6Nd53gzM7zX gJZ3A9pK9X5wzgkiUvyl1MrP9PAH/O1vEPWIEChaVSo7x5r1tfv8N6e6YdPpfcERbGFkE ghwubtsRDz+G7+2+yPvThz1oYVgKSbE1NJ2cCCLxA30k5joukxC19EDfkyFxNQ6k4uuyB kbe3czIHnKzvNaLy+bLw6D7sp7XZAN6qejRrKI1+Sfew0dx+8xgxzxNsCyEpKbypMp2O9 KF3u+9ulUoZvYNtWRE8EhbZ0NT+uj3A8avkMd5OPVLMDJQ/CIF44vaO9FHI5QFVjuBQ== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=gTvUvctM; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 48A27606A31F; Thu, 22 Oct 2026 15:54:42 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=gTvUvctM X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1792684481; b=W+cyGOi+Dldx5Yl72157X/zjJMJZqy1dAkvkd5/irMg3m9J4/hYxsDqk4FB1nvob+bit dTvCubETbzFjheQVK0mcTTia4lB3D+OpS6AMN/le0tuihV49sUvh8/SVhBaAbkoWgnzVL fHxzq9SbqT+DPgDU4Q5NYpaaQytbqJIY376mEAQk8JnF44U+22drEv33K6icfDMfKhfXx utQaOvJQ8fkNv9ciO3flszGquTgDCP9HotGhRVFjzu3bUzYLsVzx1LIJm33/aS1PAqWnQ dE9wQ5Rh3oTXZpAz5Y8obc6FIlWlC2e6Gb1aqupQpacbtqidtfbI12bsAYZBXJ0kbHQ== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1792684481; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: MIME-Version:Content-Transfer-Encoding; bh=fw9MZRcOmU8Ehb4tKOD55KkHpTquvtk01ZhunBeT+b8=; b=hr1qoWIdBzgsKX1AvIhIonXlq17KGdJ+4BnyNawnSuBJx32Qq/PT5jJEvJK8bYFqPAhE KIbeMpNfb6ffLYqfJkVYMsGY22yakv09rLH2KNrPpbBbkGEE+KvUtq6ednEy/yiXhNgOu AET8cZ3qBDTXsqmIue4dAT7Sukur2Y7QU649oMGl88Ec/awJ9fBpIOZtJQ9QVV3Kv0ghQ ZDL+IybfzisSOAEpCQQ2w4aMj0TaZpK5weJFcLfD19xSZSVI2nUhRWiiRSfikpqkQWPzr nlu9DcgsJnfsRU19mOp93I3mUcRDlY2X/Bzlh9qvjhESzY4fo69BnTDQSKo7djDPglg== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=gTvUvctM; arc=none smtp.remote-ip=100.103.45.18 X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 28ED5606A31A for <netdev@vger.kernel.org>; Thu, 22 Oct 2026 15:54:40 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id A58BF1F01825; Thu, 22 Oct 2026 15:54:38 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1792684480; bh=fw9MZRcOmU8Ehb4tKOD55KkHpTquvtk01ZhunBeT+b8=; h=From:To:Cc:Subject:Date; b=gTvUvctMpSAIH6x4EfkBneI6lDwjKW47MzbKS+qLmVvLispfvp4teLSl1W+6HaaUt kMH1bLoE7NADid68I823+BpPWtICyKb3hxlBSiMw63Bzr/LGTqrVd8tIiazTkHcRDf CmJTZDuz/lUXRsJ/312RhTWyM4bbxnUdSbH1RGrKc80Fki2UDJ6pU9IkN4G8bFvkya hj3N4TojvDQZ35emfXugFIj4NQ1U2JcJY/Wi2SIP7OWQnr7ulV8/5eg/ZWtOTq/QMF kJA1CnVWH7u6NAwiIbSXARiX10yxUZfseon2lsp6UpJZVrQBLLsPv2GCeNYHMzJUNZ a5Oenct6vxI+g== X-Cc: Willem de Bruijn <willemb@google.com>, Simon Horman <horms@kernel.org>, netdev@vger.kernel.org, Eric Dumazet <edumazet@kernel.org>, shaos <shawnq1@163.com>, Jamal Hadi Salim <jhs@mojatatu.com>, "Michael S. Tsirkin" <mst@redhat.com> X-Mailer: git-send-email 2.53.0 X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list