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 v15 4/4] net/sched: cake: hash before segmenting and reject an overlong split
Date: Tue, 01 Dec 2026 19:43:23 +0000	[thread overview]
Message-ID: <179615420343.3146.545600846329620433@kernel.org> (raw)
In-Reply-To: <20261130183825.229246-5-jhs@mojatatu.com>

Thank you for your contribution! Sashiko AI review found 4 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 3 (1) · Low: 1

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Medium] Several claims in the commit message do not match the code or
  the tree.
- [Medium] This commit tags every segment with QDISC_DROP_OVERLIMIT
  before qdisc_drop_all(), with the comment "__skb_gso_segment() leaves…
- [Medium] Under an mq-style parent (cake_mq, mq, mqprio), the new split-
  admission check gives wrong answers.
- [Low] This commit opens with "The Fix:" but has no Fixes: tag or stable
  marker.

Pre-existing issues:
- [Medium] cake_enqueue() now snapshots flow_mode once with
  READ_ONCE(q->config->flow_mode) (sch_cake.c:1802).

--

net/sched: cake: hash before segmenting and reject an overlong split

This patch splits cake_hash() into a side-effect-free cake_hash_keys() and
a cake_hash_resolve() that runs only after admission. It also moves the
split-GSO segmentation ahead of flow resolution. Before linking any segment,
it sums the segment lengths and refuses the split if its own backlog or an
ancestor's backlog could exceed the ceiling.

Link: https://lore.kernel.org/netdev/179231933068.3135.80340792633077986@kernel.org/
Link: https://lore.kernel.org/netdev/179269577270.3135.16072065138845192450@kernel.org/

> 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.

[Severity: Medium]
A few parts of the commit message don't seem to match the code.

The subject says "hash before segmenting" and the body says "Key extraction
must run on the unsegmented skb". Wasn't that already true before this
patch? The parent commit already has this above the split block in
cake_enqueue():

	b = cake_select_tin(sch, skb);
	idx = cake_hash(b, skb, q->config->flow_mode, flow_override,
			host_override) + 1;

The only real ordering change seems to be that cake_hash_resolve() now runs
after the new admission check. That only matters because this same patch
adds the rejection.

The text "tagging only the head left the rest with a headroom-sized value"
and "Found by our review of an earlier revision of this series" describe
revisions that were never merged. The baseline cake split path has no
rejection, so it never tagged only the head.

The reproducer section says its example "is admitted" and that "The clause
is a defensive bound, not a proven one". Since there is no reproducer,
should "The Fix:" and "Conditions to recreate the bug" be reworded? Also,
none of the listed commands actually hold the tun fd open.

The body says "the split reserves two copies of its growth". The v14 -> v15
note says "reserve two copies of the split growth in the own-counter test".
The own-counter test in cake_enqueue() is:

	if (unlikely(((u64)sch->qstats.backlog + 2 * slen > U32_MAX) ||

That reserves two copies of the whole segment sum, not the growth. The
1081327 figure (2162655 / 2) also only fits 2 * slen.

"The reconciliation's length is signed, so the segment-sum subtraction
cannot be mistaken for growth" reads like a functional fix. Does the (s64)
cast change anything? qdisc_tree_reduce_backlog() only passes len on to
qdisc_qstats_backlog_apply():

	WRITE_ONCE(sch->qstats.backlog, (u32)(backlog - delta));

The old unsigned len-slen gives the same result modulo 2^32.

Finally, no function under net/ is called sock_free(), so "the tail
segment's sock_free()" doesn't match anything. Was sock_wfree() meant?

> Reviewed-by: Victor Nogueira <victor@mojatatu.com>
> Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com>

[Severity: Low]
The message opens with "The Fix:", but there is no Fixes: tag or stable
marker. Should there be one?

The earlier patch in this series, "net/sched: cap the accounted backlog
before it can wrap" (Fixes: 175f9c1bba9b), says:

  "The ancestor-room check covers a split whose segments would grow an
  ancestor past the room: tbf, dualpi2, netem's corrupt split and cake."

Its sch_cake.c hunk only adds the qdisc_backlog_overflow() entry guard,
though. The cake split-path own-counter bound and the
qdisc_ancestors_backlog_room() call only appear in this commit.

Stable could pick up the earlier patch by its Fixes: tag without this one.
The cake split path would then still call qdisc_tree_reduce_backlog() with
no bound. Since the clause is described as "a defensive bound, not a proven
one", the runtime impact of that is unproven.

This patch also depends on "net/sched: cake: return the classifier result
to the caller" and "net/sched: cake: use a dedicated split-GSO list
iterator" from the same series. Could that dependency be recorded?

> diff --git a/net/sched/sch_cake.c b/net/sched/sch_cake.c
> index 25c7e20ec1239..f7ac265bfa176 100644
> --- a/net/sched/sch_cake.c
> +++ b/net/sched/sch_cake.c

[ ... ]

> @@ -1769,11 +1788,18 @@ static s32 cake_enqueue(struct sk_buff *skb, struct Qdisc *sch,
>  	struct cake_sched_data *q = qdisc_priv(sch);
>  	int len = qdisc_pkt_len(skb), ret;
>  	u16 flow_override, host_override;
> +	struct sk_buff *segs = NULL;
> +	struct cake_hash_keys keys;
>  	struct sk_buff *ack = NULL;
>  	ktime_t now = ktime_get();
>  	struct cake_tin_data *b;
>  	struct cake_flow *flow;
>  	bool same_flow = false;
> +	int flow_mode;
> +	u64 slen = 0;
> +	u64 growth;
> +
> +	flow_mode = READ_ONCE(q->config->flow_mode);

[Severity: Medium]
This is a pre-existing issue and was not introduced by this patch. Now that
flow_mode is snapshotted here, what about the dequeue side? cake_dequeue()
still uses plain loads of q->config->flow_mode for the bulk host count
updates and for cake_get_flow_quantum():

	cake_inc_srchost_bulk_flow_count(b, flow, q->config->flow_mode);

cake_enqueue() also still reads q->config->rate_flags with plain loads,
for example:

	q->config->rate_flags & CAKE_FLAG_SPLIT_GSO) {

With cake_mq the config is shared. cake_mq_change()->cake_config_change()
writes these fields before taking any child's tree lock:

	WRITE_ONCE(q->rate_flags, rate_flags);
	WRITE_ONCE(q->flow_mode, flow_mode);

Suppose the dual-src/dual-dst bits change between a flow's enqueue and its
dequeue. Can hosts[].srchost_bulk_flow_count and dsthost_bulk_flow_count
drift? The saturating guards prevent wraparound, but not drift.

The baseline enqueue also read flow_mode live. The commit's narrower claim,
that extraction and resolution within one enqueue use the same mode, does
hold.

[ ... ]

> @@ -1790,12 +1816,53 @@ static s32 cake_enqueue(struct sk_buff *skb, struct Qdisc *sch,

[ ... ]

> +		growth = slen > (u64)len ? slen - len : 0;
> +		if (unlikely(((u64)sch->qstats.backlog + 2 * slen > U32_MAX) ||
> +			     (growth &&
> +			      !qdisc_ancestors_backlog_room(sch,
> +							    2 * growth)))) {

[Severity: Medium]
How does this check behave under an mq-style parent such as cake_mq, mq or
mqprio?

qdisc_ancestors_backlog_room() crosses TCQ_F_NOPARENT and tests the
root's counter:

	if (unlikely((u64)READ_ONCE(p->qstats.backlog) + extra >
		     QDISC_MAX_BACKLOG)) {

For mq-style roots, only mq_dump_common() writes that field:

	WRITE_ONCE(sch->qstats.backlog, qstats.backlog);

That value is the u32 sum of every tx queue's child backlog at the last
dump, and the sum can wrap.

qdisc_tree_reduce_backlog() stops at the NOPARENT child, so the split
growth never reaches that parent. The helper's own comment says "A parent
that does not book it cannot overflow."

Suppose a dump leaves the aggregate within 2 * growth of
QDISC_MAX_BACKLOG. Would every child's growing GSO split then be refused
with QDISC_DROP_OVERLIMIT until the next dump changes the snapshot? Note
that RTM_GETQDISC dumps don't require CAP_NET_ADMIN.

> +			qdisc_qstats_overlimit(sch);
> +			/* __skb_gso_segment() leaves SKB_GSO_CB over
> +			 * tc_skb_cb.drop_reason; tag every segment.
> +			 */
> +			skb_list_walk_safe(segs, seg, nskb)
> +				tcf_set_qdisc_drop_reason(seg,
> +							  QDISC_DROP_OVERLIMIT);
> +
> +			return qdisc_drop_all(segs, sch, to_free);

[Severity: Medium]
The same reasoning applies to the split refusals that "net/sched: cap the
accounted backlog before it can wrap" added to tbf_segment() and
dualpi2_qdisc_enqueue(). Should those tag each segment too? Both pass the
untagged list straight to qdisc_drop_all():

net/sched/sch_tbf.c:tbf_segment() {
    ...
			consume_skb(skb);
			qdisc_qstats_overlimit(sch);
			return qdisc_drop_all(segs, sch, to_free);
    ...
}

net/sched/sch_dualpi2.c:dualpi2_qdisc_enqueue() {
    ...
				consume_skb(skb);
				qdisc_qstats_overlimit(sch);
				return qdisc_drop_all(nskb, sch, to_free);
    ...
}

netem's equivalent path does tag each segment, through
qdisc_drop_reason(..., QDISC_DROP_OVERLIMIT).

SKB_GSO_CB_OFFSET is 32, so tc_skb_cb.drop_reason overlaps
SKB_GSO_CB->mac_offset/data_offset. __skb_gso_segment() writes
skb_headroom(skb) into that spot. __tcf_kfree_skb_list() then reads:

	u32 reason = tc_skb_cb(skb)->drop_reason;

A headroom-sized value has no qdisc subsystem bits. It would therefore be
passed to kfree_skb_reason() as an unrelated core skb_drop_reason.

Won't tbf and dualpi2 split refusals then show the wrong reason in the
kfree_skb tracepoint and in drop monitor?

> +		}
> +	}

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261130183825.229246-1-jhs%40mojatatu.com

      reply	other threads:[~2026-12-01 19:43 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-30 18:38 [PATCH net-next v15 0/4] net/sched: cap the accounted backlog before it can wrap Jamal Hadi Salim
2026-11-30 18:38 ` [PATCH net-next v15 1/4] net/sched: cake: return the classifier result to the caller Jamal Hadi Salim
2026-11-30 18:38 ` [PATCH net-next v15 2/4] net/sched: cake: use a dedicated split-GSO list iterator Jamal Hadi Salim
2026-11-30 18:38 ` [PATCH net-next v15 3/4] net/sched: cap the accounted backlog before it can wrap Jamal Hadi Salim
2026-12-01 19:43   ` netdev-bot+sashiko
2026-11-30 18:38 ` [PATCH net-next v15 4/4] net/sched: cake: hash before segmenting and reject an overlong split Jamal Hadi Salim
2026-12-01 19:43   ` 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=179615420343.3146.545600846329620433@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