Netdev List
 help / color / mirror / Atom feed
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
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	[thread overview]
Message-ID: <179603287412.3146.1252886963739799647@kernel.org> (raw)
In-Reply-To: <QDISC-BA27.v14.r0.20261128181551-4@mojatatu.com>

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

      reply	other threads:[~2026-11-30 10:01 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-29  9:06 [PATCH net-next v14 0/4] net/sched: cap the accounted backlog before it can wrap Jamal Hadi Salim
2026-11-29  9:06 ` [PATCH net-next v14 1/4] net/sched: cake: return the classifier result to the caller Jamal Hadi Salim
2026-11-29  9:06 ` [PATCH net-next v14 2/4] net/sched: cake: use a dedicated split-GSO list iterator Jamal Hadi Salim
2026-11-29  9:06 ` [PATCH net-next v14 3/4] net/sched: cap the accounted backlog before it can wrap Jamal Hadi Salim
2026-11-30 10:01   ` netdev-bot+sashiko
2026-11-29  9:06 ` [PATCH net-next v14 4/4] net/sched: cake: hash before segmenting and reject an overlong split Jamal Hadi Salim
2026-11-30 10:01   ` netdev-bot+sashiko [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=179603287412.3146.1252886963739799647@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=bjorn@kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=jhs@mojatatu.com \
    --cc=jiri@resnulli.us \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sashiko-bot@kernel.org \
    --cc=stephen@networkplumber.org \
    --cc=toke@toke.dk \
    --cc=victor@mojatatu.com \
    --cc=vinicius.gomes@intel.com \
    --cc=willemb@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox