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=1796032876; b=wcDevQLyKmRfIz1KmtXlvIOa3AqdvTeu4FWOpoFOyBNAF/jvMf+EfK502Xi8ZAtXhmyd 60Ec2LR8VnQZmo1hqoBY10aaDnbNfqRIG/9bT3DRFJJg5rKWRWeQK7ogB1baypNKWn2Iy TK45zRMOJ4MbLspG+hsb/0Cq7clVyuuM74ZK65MTZjzSyOS7pPnZicUdJm4KWOaLj2Gnj Wy7MNi6ZATM0ctapRLjoJQr6xJB3iFXgyN+6KUCrhRPGEmzSZyRYwQMrEtneuiMDWSuJy N4jeaS/mBvFwOHdIkrPlBFiRf6MVh/Aa9Q2j0KzNF8RGxKobqDLhafbFXSF4dB8yfCQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796032876; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=HKkWOnhsispH5IkYfqVCf+HRLWvQSiXJhchUVy/kmKI=; b=nD5WqfgBYlsoVr+JSm2LSZgHExWRZdsWQAceu09v9exUdYCFqrzciVto6aA3OkGmOABP hjlQ63TQ72BEvuhzGkIuOdK93XBODzAv7YcHnE+hW1vA0s4OI9Zv4ULT2HJxGqxYuEMFA 6BLeaZ8G0oIGsvhMcWF4TdYopqEsvvbCr6l6z7zqCsEOn9hlqUCgpVUyXuqO04K94Dpzs GK0bdh9G596sKOXEQssnfZGAOZDdoDVzF+M7O+s6R7iNZM/BEQiCunSPo7IdB2e6pb3gB o0mEQdJazMCBMvdMR/2RP4BdXhS+YVyFSX0Up4FKdk87++gfR58z/j2STZL+sekY7bg== 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=TBDONCuQ; 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 2E26E606A334 for ; Mon, 30 Nov 2026 10:01:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=TBDONCuQ Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8D66C1F00929; Mon, 30 Nov 2026 10:01:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796032875; bh=HKkWOnhsispH5IkYfqVCf+HRLWvQSiXJhchUVy/kmKI=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=TBDONCuQh8DGpI4AtCik8+P2CLDlw35QyhMZEcs1VNcwe2bzE/AL8BzgEkFgWG7qS x8tc3dQQQRSqTjkb5bYRxAY4RtiXvm9UodW8MGbCX8hT0vTFtqNI0CUUrpc/rCLvSp MHhny1TMvpLBbG0Hba8SHekD/M+NXpcpg6w4cGU9dvaNtmslYyaSf9TKMT0YqsTlSj CqvFJqr/K6WGrqtShRDbkH33HkMStOAZceU/eM11r+G/BljD+O//7KbVmnWM2/WYjj CzwIBxCHtOsGQmb6AlCf4uSNnsgc6JKFe733znP2uYIqEsv3USwGvjfAfCuJeJzIpB wevXuX5xV2L/A== Subject: Re: [PATCH net-next v14 4/4] net/sched: cake: hash before segmenting and reject an overlong split From: netdev-bot+sashiko@kernel.org To: jhs@mojatatu.com Cc: netdev@vger.kernel.org, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, willemb@google.com, horms@kernel.org, jiri@resnulli.us, stephen@networkplumber.org, vinicius.gomes@intel.com, toke@toke.dk, victor@mojatatu.com, bjorn@kernel.org, sashiko-bot@kernel.org Date: Mon, 30 Nov 2026 10:01:14 +0000 Message-ID: <179603287412.3146.1252886963739799647@kernel.org> In-Reply-To: References: X-sashiko-severity: Low Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Thank you for your contribution! Sashiko AI review found more severe issue(s) in other patches of this series. This mail is only an FYI, in case you want to address the nit picks below when you respin. Low priority / nit picks for your consideration: - [Low] The commit message describes a fix that the patch does not demonstrate. Pre-existing issues: - [High] This problem wasn't introduced by this patch, but the patch restructures the split-GSO path and keeps it. -- net/sched: cake: hash before segmenting and reject an overlong split This patch splits cake_hash() into two parts. cake_hash_keys() has no side effects, and cake_hash_resolve() commits the set-associative state. It moves the CAKE_FLAG_SPLIT_GSO segmentation in cake_enqueue() ahead of flow resolution and refuses a split whose segment sum would wrap the backlog or overflow an ancestor's backlog. It also reads flow_mode once with READ_ONCE(). Link: https://lore.kernel.org/netdev/179231933068.3135.80340792633077986@kernel.org/ Link: https://lore.kernel.org/netdev/179269577270.3135.16072065138845192450@kernel.org/ > net/sched: cake: hash before segmenting and reject an overlong split > > The Fix: with CAKE_FLAG_SPLIT_GSO, cake computes the flow keys and then > splits a GSO skb into segments it accounts individually. Key extraction > must run on the unsegmented skb -- skb_gso_segment() can rewrite > encapsulated headers to the inner ones -- and resolution must wait until > admission, since it commits set-associative state a later rejection would > leave mutated. [ ... ] > Conditions to recreate the bug: [ ... ] > # A 65000-byte UDP_SEGMENT datagram with a 1400-byte segment size sums > # to 66316 accounted bytes and is admitted; the refusal needs a segment > # sum above the 2162655 bytes left below U32_MAX, which this example > # does not reach. The clause is a defensive bound, not a proven one: [Severity: Low] Is it accurate to call this a fix? The subject says "hash before segmenting", but keys were already taken from the unsegmented skb before this patch. In cake_enqueue(), the removed code calls cake_hash() before the split block: - idx = cake_hash(b, skb, q->config->flow_mode, flow_override, - host_override) + 1; ... - if (qdisc_pkt_segs(skb) > 1 && q->config->rate_flags & CAKE_FLAG_SPLIT_GSO) { ... - segs = skb_gso_segment(skb, features & ~NETIF_F_GSO_MASK); The real change seems to be that the resolution step, now cake_hash_resolve(), waits until after the new split admission check. The "Conditions to recreate the bug" section also says its example does not reach the new refusal. It calls the U32_MAX clause a defensive bound. The 66316-byte segment sum is well below the 2162655 bytes of room left, so the new branch is never taken. Before this patch, the only rejection after hash resolution on the split path was a skb_gso_segment() failure. On that path cake_hash() kept the host bulk counts consistent: the evicted flow's counts went down and the new host's went up. Only q->tags[] and the way_* statistics changed. Could the message describe this as hardening, plus the refactor the new refusal needs? Opening with "The Fix:" and a reproducer could mislead stable/AUTOSEL selection. > diff --git a/net/sched/sch_cake.c b/net/sched/sch_cake.c > index 25c7e20ec1239..917bbd072a66a 100644 > --- a/net/sched/sch_cake.c > +++ b/net/sched/sch_cake.c [ ... ] > @@ -1822,14 +1894,9 @@ static s32 cake_enqueue(struct sk_buff *skb, struct Qdisc *sch, [ ... ] > + if (segs) { > + struct sk_buff *nskb, *seg; > + unsigned int numsegs = 0; > > skb_list_walk_safe(segs, seg, nskb) { > skb_mark_not_on_list(seg); > @@ -1843,7 +1910,6 @@ static s32 cake_enqueue(struct sk_buff *skb, struct Qdisc *sch, > qdisc_qlen_inc(sch); > numsegs++; > q->buffer_used += seg->truesize; > - slen += seg->len; > WRITE_ONCE(b->packets, b->packets + 1); > } > > @@ -1854,10 +1920,10 @@ static s32 cake_enqueue(struct sk_buff *skb, struct Qdisc *sch, > WRITE_ONCE(b->tin_backlog, b->tin_backlog + slen); > WRITE_ONCE(b->backlogs[idx], b->backlogs[idx] + slen); > > - qdisc_tree_reduce_backlog(sch, 1-numsegs, len-slen); > - consume_skb(skb); > + qdisc_tree_reduce_backlog(sch, 1 - numsegs, > + (s64)len - (s64)slen); > } else { [Severity: High] This is a pre-existing issue, not one introduced by this patch, but the patch reworks this split path. Can segments stay queued in cake while the parent thinks the enqueue was dropped? By this point all N segments are linked into one flow with flow_queue_add(), and the ancestors have been told the qdisc grew by N - 1 packets. If buffer_used is now above buffer_limit, the tail of cake_enqueue() runs: net/sched/sch_cake.c:cake_enqueue() { ... while (q->buffer_used > q->buffer_limit) { drop_id = cake_drop(sch, to_free); if ((drop_id >> 16) == tin && (drop_id & 0xFFFF) == idx) same_flow = true; } ... if (same_flow) { qdisc_tree_reduce_backlog(sch, prev_qlen - 1, prev_backlog - len); return NET_XMIT_CN; } ... } If cake was empty, cake_drop() takes the head of this flow, because it is the fattest one, so same_flow becomes true. The loop can stop after k < N drops. NET_XMIT_CN is then returned with N - k segments still queued, and the ancestors' qlen is left at N - k. Classful parents treat any return other than NET_XMIT_SUCCESS as a drop and return before activating the class. For example, hfsc_enqueue(): net/sched/sch_hfsc.c:hfsc_enqueue() { ... first = !cl->qdisc->q.qlen; err = qdisc_enqueue(skb, cl->qdisc, to_free); if (unlikely(err != NET_XMIT_SUCCESS)) { ... return err; } ... if (first && !cl_in_el_or_vttree(cl)) { ... } qdisc_tree_reduce_backlog() only calls qlen_notify when the child becomes empty, so nothing else activates the class. On later enqueues first is false, because cake never drains. Does that keep the HFSC class out of the eltree/vttree permanently, with packets queued, until an admin reconfigures it? DRR, HTB, QFQ and ETS check cl_is_active() or prio_activity on later successful enqueues. drr_enqueue(), for example, skips the list_add_tail(&cl->alist, &q->active) on a non-success return. In those parents the leftover segments would stall until the next successful enqueue to that class. The trigger needs three things: - a cake leaf with split-gso, which is the default for rates up to 1 Gbit/s - a memlimit small enough that one split's summed truesize exceeds buffer_limit - a GSO skb, from a local UDP_SEGMENT/TSO send or from forwarded GRO traffic The same tail logic was already present with the split path before this patch. It came in with commit 9fefc78f7f02 ("net/sched: sch_cake: Fix incorrect qlen reduction in cake_drop"). -- Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/QDISC-BA27.v14.r0.20261128181551%40mojatatu.com