From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796379353; b=hD3SSvRuP4ZV5z0vzSJB7YfT2tW9WbKjQtWah2GOhi32mpUOK/WHclCziwX7YavSt5LX +9tcbyV8OxT3z1J4i6dXmBndhoIuPlUZYOIhJ3d8NyrB/m1rbWqj6nVTdLF/mpFcTTnnz 8VD27SfEofSLSUa94QHEmgfZ8/Nujp61OB+d5+eAt7H9O5SDyXZRpxPeU1K5oTyt91DeT PEaKRVsIK8R9GP9eH0zT7orTFY0CEYv2EWanK5tmoFiHRSXvsBqkmrTGuxdY1a3idSt8j EblTt4C4b+gfEclEyoRrPDiJVEVRAb/Bbj2xjuJwaoHDl0BJXRB0WVu359Fh78iqs9w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796379353; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=YwBLnS436MpufJQ3+q6UekuHm4ArA3EhsK28UZ67qWQ=; b=ZVXi59D42XP2Rb8wryFPz7vgddRXeTEQ/LilERY3TNSD7gA7MPN+bZY4LwF3BUiU856p NWUGmRKirFqWJmQzSdtZwrskkUcDdbsrF94FeW3xP9bc9l1yvTvRTDF20TPowhSW8fBfc JmWKczfS7A8I9YAHuC0ZALAKAwLumxu8Z/JP+8ETVVDCt8LWKRlOGraluPqY5khlJUIEh y4sQu1S/3XGHHXGI0/R5xecYbsPE/ekysfSdlr2/0bgBnrgK+jlQCKT8OI5RTvW95gWlF 5RXIR9WHObX2zU4VS5XfW36UKF0fObhTGIPTS5gQDftNTPVNorLDcHTl+mwurf9IL+w== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=tlJtpdXe; arc=none smtp.remote-ip=100.103.45.18 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 1FA89606A322; Fri, 4 Dec 2026 10:15:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=tlJtpdXe Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8B2111F000CE; Fri, 4 Dec 2026 10:15:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796379353; bh=YwBLnS436MpufJQ3+q6UekuHm4ArA3EhsK28UZ67qWQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=tlJtpdXe96Lqq0kyITf+jmMxLggY/Q1DFwMrLswYtW2IaKPV/gDTqP0ApvC0iGzRm tMasXTKLLCiDcOTAdJcAqYzL5P6ItpLa0eqn8SoUlVEtEUmzeiIu8EcH0Ns+2VRI8s Qb5acKYX1kb8NN5uXR2ku1vK0vAECsnDoNh5AWYM= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, shaos , Eric Dumazet , Jamal Hadi Salim , "Michael S. Tsirkin" , Willem de Bruijn , Jakub Kicinski , Artem Dinaburg , Sasha Levin Subject: [PATCH 6.18 007/703] net: harden qdisc_pkt_len_segs_init() against malicious GSO packets Date: Fri, 4 Dec 2026 18:58:26 +0900 Message-ID: <20261204100627.734647282@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100627.522266145@linuxfoundation.org> References: <20261204100627.522266145@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Eric Dumazet [ Upstream commit c6648c9f3b51c5a8a3df470c1542b2aa378d88f9 ] 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 Closes: https://lore.kernel.org/netdev/20261022144755.65025-1-shawnq1@163.com/ Signed-off-by: Eric Dumazet Cc: Jamal Hadi Salim Cc: "Michael S. Tsirkin" Acked-by: Michael S. Tsirkin Reviewed-by: Willem de Bruijn Link: https://patch.msgid.link/20261022155436.117507-1-edumazet@kernel.org Signed-off-by: Jakub Kicinski [ Backport to 6.18.y: context adjusted; 6.18.y keeps the name qdisc_pkt_len_init() and has no qdisc_skb_cb()->pkt_segs. The code change is identical to upstream. ] Signed-off-by: Artem Dinaburg Signed-off-by: Sasha Levin --- 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 792cc34fc218a..40f3bb73c0ca3 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -4140,7 +4140,7 @@ static enum skb_drop_reason qdisc_pkt_len_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) @@ -4189,6 +4189,15 @@ static enum skb_drop_reason qdisc_pkt_len_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_len += (gso_segs - 1) * hdr_len; -- 2.53.0