๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #24546

Re: [PATCH net-next v14 4/4] net/sched: cake: hash before segmenting and reject an overlong split

#24546
From: netdev-bot+sashiko
Date: Mon, 30 Nov 2026 10:01
186 lines
14900 bytes
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
Technical Details
Message-ID: <179603287412.3146.1252886963739799647@kernel.org>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374091-linux-kernel-netdev=dewy.ru
References: <QDISC-BA27.v14.r0.20261128181551-4@mojatatu.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374091-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next v14 4/4] net/sched: cake: hash before segmenting
 and reject an overlong split
Date: Mon, 30 Nov 2026 10:01:14 +0000
Organization: Usenet Network
Message-ID: <179603287412.3146.1252886963739799647@kernel.org>
References: <QDISC-BA27.v14.r0.20261128181551-4@mojatatu.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="1399236"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:uFLnF12S4iYwmRacBBCpndsVt7M= sha256:Er80MdRF8/3IUfIv/nLhRwi72Vhvu2RkQSBr0mOO2CY=
	sha1:KsnOswvzaPhSCyGkmg5E2KrTLHQ= sha256:tPV1qJhda53Td1mgQTyycGGw3AfN47EqaGxzw0ylGlU=
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 E85C9125FCC; Mon, 30 Nov 2026 13:01:35 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.401
X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, 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 Dfp0MD2A8Yx6;
	Mon, 30 Nov 2026 13:01:32 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-374091-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 sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 1471C125FD4; Mon, 30 Nov 2026 13:01:24 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id B1F862E419; Mon, 30 Nov 2026 10:01:17 +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=1796032877;
	b=HffPecQVsLCDZ3oW3QiyLHGA3W4spKEH418B2ilC5puc3czlWTte5EDomoYshnUPE2mL
	 I7yla8tpyrXEtmyvhly9jJ5+aP2FT/9k0j1NtHuct1jArew+UrEt7vfCCHAPo3Sxbguaa
	 nA2+Tmv3eOV2hIhy6RY7P4PQJWuwGStdvvfXinkitvyFrC0AzeVyUfdNh96HS3O7mEFNv
	 kC6UatpjX57wA7ECXOqgE0ZTOGC27oz7q+BJ9poyUtzYiCKMKLn30FUhLmCQpRSBs//VC
	 PKCdhS4YQK/6DlaZlUIyznp/vEAKzkE45lZ9Pq3/GhsmZ0SuENgYDgwAId7hDK4yDAQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796032877;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=HKkWOnhsispH5IkYfqVCf+HRLWvQSiXJhchUVy/kmKI=;
	b=E14Bj8bf/sCGT/FiqaB7f49qVOWDDV43aXk+VDKRSrXrQdsCxtRZbfBPcKr4FqdlowMV
	 E9PwlZ2LEeKQbVFyNdx8LxYytU/b3iFjfZtUTv1/QWLeAoJzjNX/w+i8VRnpm5XAafmd3
	 +YdTtU1tWUB24XRb3nHq4+4FJOTYhsg/wwvk9SD1i/T2P+ux7Wc2tLRDWBmlq36IkJoo2
	 9htPHem4eTjX2KfhheViT6mNhu8DzcFcxZw/YfLLcB0r7uyruDpBRGPVyU6COfcUfS9tt
	 pn342h+KEQ0W/j45DsdF7Xx+zjSpbVlzNN0bbu9kaJsExnKraVGCEXgF/o8RdgC9qUQ==
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=TBDONCuQ;
	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 0CF71606A330;
	Mon, 30 Nov 2026 10:01:17 +0000 (UTC)
X-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
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=1796032876;
	b=wcDevQLyKmRfIz1KmtXlvIOa3AqdvTeu4FWOpoFOyBNAF/jvMf+EfK502Xi8ZAtXhmyd
	 60Ec2LR8VnQZmo1hqoBY10aaDnbNfqRIG/9bT3DRFJJg5rKWRWeQK7ogB1baypNKWn2Iy
	 TK45zRMOJ4MbLspG+hsb/0Cq7clVyuuM74ZK65MTZjzSyOS7pPnZicUdJm4KWOaLj2Gnj
	 Wy7MNi6ZATM0ctapRLjoJQr6xJB3iFXgyN+6KUCrhRPGEmzSZyRYwQMrEtneuiMDWSuJy
	 N4jeaS/mBvFwOHdIkrPlBFiRf6MVh/Aa9Q2j0KzNF8RGxKobqDLhafbFXSF4dB8yfCQ==
X-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==
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=TBDONCuQ;
	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 2E26E606A334
	for <netdev@vger.kernel.org>; Mon, 30 Nov 2026 10:01:15 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8D66C1F00929;
	Mon, 30 Nov 2026 10:01:14 +0000 (UTC)
X-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==
X-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
X-In-Reply-To: <QDISC-BA27.v14.r0.20261128181551-4@mojatatu.com>
X-sashiko-severity: Low
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