From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mail.toke.dk; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=GjW78mOa; arc=none (Message is not ARC signed); dmarc=pass (Used From Domain Record) header.from=gmail.com policy.dmarc=quarantine Received: from mail-pj2-x10.google.com (mail-pj2-x10.google.com [IPv6:2607:f8b0:4864:39::10]) by mail.toke.dk (Postfix) with ESMTPS id 2A83B170A37D for ; Sun, 27 Sep 2026 15:10:30 +0200 (CEST) Received: by mail-pj2-x10.google.com with SMTP id 98e67ed59e1d1-39dacf053eeso1114486a91.2 for ; Sun, 27 Sep 2026 06:10:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1790514629; x=1791119429; darn=lists.bufferbloat.net; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=bkDmzZIfjmIBLLdMK74q6txJ55ZXC/oT66ennoBB6nM=; b=GjW78mOay4arFEnYD0tU731TG+f7MeO7gBslvjGdjQEmz4PqgXz9eWEHfP1P8JDLND XnwV1YgXcjeRGlkt+2TOfeyu3mtqpg2ALFQQmFXhrt3quIj+f014ywGTCKODTZSE793t gYmFkry77tgvqG245sAiNuOX651zFeu7LZc7YKzqA7yLUbNd6ePccHOTN5V1UB/6uqCE fqTM9MNr00ymh27c7PFx41RG8pm/brf9LBSIHrIqRAmCxFyMAFzErLBPA3sKmSgTolAM dvjuGZcGiGR1znuQmJ3hFrOemZcNr1tO39pikaKSul7r3MJFH8HNo4tHUMFmj5BgUo26 gfPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790514629; x=1791119429; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=bkDmzZIfjmIBLLdMK74q6txJ55ZXC/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ytwDaZoFdkzOo6CSMxqdRp47ucHsdkCOiGnA+Dh8XRNq WGm2zp0VYiOECYdj7hBr4JsHnmne8LcaOs= X-Received: by 2002:a17:90a:d883:b0:3a0:2900:f577 with SMTP id 98e67ed59e1d1-3a098dff5b4mr8264184a91.51.1790514628797; Sun, 27 Sep 2026 06:10:28 -0700 (PDT) Received: from localhost.localdomain ([2409:8a1e:2e81:7320:84a7:e3d7:8c7e:980a]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3a0b9589f7esm14890506a91.10.2026.09.27.06.10.20 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 27 Sep 2026 06:10:27 -0700 (PDT) From: Yuchao Zhang To: =?UTF-8?q?Toke=20H=C3=B8iland-J=C3=B8rgensen?= , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Simon Horman , Jamal Hadi Salim , Jiri Pirko , cake@lists.bufferbloat.net, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Yuchao Zhang Date: Sun, 27 Sep 2026 21:10:07 +0800 Message-ID: <20260927131009.24250-1-ndaugoing@gmail.com> X-Mailer: git-send-email 2.50.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-MailFrom: ndaugoing@gmail.com X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation Message-ID-Hash: FGJNUKOUHSQSWT2X5GQDO23RSNBDFDUA X-Message-ID-Hash: FGJNUKOUHSQSWT2X5GQDO23RSNBDFDUA X-Mailman-Approved-At: Mon, 28 Sep 2026 13:06:42 +0200 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Cake] [PATCH net v3 0/2] net/sched: sch_cake: prevent shaper corruption and stall in cake_overhead() List-Id: Cake - FQ_codel the next generation Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: This series addresses two issues in cake_overhead() that can lead to corrupted rate shaper accounting or long dequeue stalls: Patch 1 fixes an integer underflow when segs == 0. When an skb with segs == 0 (such as dodgy GSO packets where gso_segs is not recomputed) reaches cake_overhead(), (segs - 1) wraps around to UINT32_MAX, multiplying per-segment overhead by ~4.29 billion and returning a length close to 4.29 GB. cake_advance_shaper() then charges that length to the shaper, stalling the dequeue queue for tens of seconds at 1 Gbit/s, and for minutes to hours at lower rates. This was introduced by commit c5d34f4583ea ("net_sched: cake: use qdisc_pkt_segs()"). Patch 2 validates the transport header offset computed in cake_overhead(). When the transport header was never set, skb_transport_offset() returns the ~0U sentinel (~65535), which inflates shaper accounting by ~66 KB per segment. Furthermore, if preceding egress BPF filters (e.g. sch_handle_egress()) or cake classifier actions (e.g. act_bpf trimming headers via bpf_skb_adjust_room(BPF_ADJ_ROOM_MAC)) leave the transport header stale (bpf_skb_net_hdr_pop() only re-syncs it when it aliased network_header), skb_transport_offset() can become negative. Because hdr_len was declared as unsigned int, a negative offset wraps to near UINT_MAX. Patch 2 checks !skb_transport_header_was_set() and ensures hdr_len >= 0. Both hunks date back to commit a729b7f0bd5b ("sch_cake: Add overhead compensation support to the rate shaper"), so they share a single Fixes: tag and stable range. Changes in v3: - Split the v2 patch into a 2-patch series per Simon Horman and Sashiko AI review so each logical fix carries its own accurate Fixes: tag and matches proper stable tree backport ranges: - Patch 1 Fixes: c5d34f4583ea ("net_sched: cake: use qdisc_pkt_segs()") - Patch 2 Fixes: a729b7f0bd5b ("sch_cake: Add overhead compensation support to the rate shaper") - Clarify the timing and code paths where header mangling can occur (sch_handle_egress() and cake_classify() before cake_overhead()) rather than inaccurate "post-enqueue mangling" wording. - Link to v2: https://lore.kernel.org/netdev/20260922084124.36858-1-ndaugoing@gmail.com/ Changes in v2: - Accurately describe the impact as shaper accounting corruption / stall rather than OOB read past the allocation. - Fix integer underflow when segs == 0 by checking segs <= 1. - Import companion check !skb_transport_header_was_set(skb) from qdisc_pkt_len_segs_init() to prevent unset transport header sentinel (~0U) from inflating packet length to ~66 KB. - Link to v1: https://lore.kernel.org/netdev/20260917122153.62722-1-ndaugoing@gmail.com/ Yuchao Zhang (2): net/sched: sch_cake: fix shaper stall on segs == 0 in cake_overhead() net/sched: sch_cake: validate transport header offset in cake_overhead() net/sched/sch_cake.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) -- 2.53.0