Article View: linux.kernel.netdev
Article #6581Re: [PATCH net-next v7 4/4] net/sched: cake: hash before segmenting and reject an overlong split
From: netdev-bot+sashiko
Date: Thu, 22 Oct 2026 19:02
Date: Thu, 22 Oct 2026 19:02
180 lines
14589 bytes
14589 bytes
Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 2
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] cake_enqueue() (net/sched/sch_cake.c:1825-1827): when
skb_gso_segment() fails with IS_ERR_OR_NULL(segs), the original skb is…
- [Low] The commit presents itself as a bug fix ('The Fix:') with user-
visible effects but has no Fixes: trailer.
- [Low] The commit message says cake_enqueue() reads q->config->flow_mode
'once with READ_ONCE()'.
--
net/sched: cake: hash before segmenting and reject an overlong split
This commit splits cake_hash() into a side-effect-free cake_hash_keys(),
which runs on the unsegmented skb, and cake_hash_resolve(), which runs
only once the packet is admitted. The split-GSO path moves ahead of the
resolution: it sums the segment list, checks the total against
QDISC_MAX_BACKLOG and, on rejection, defers the whole list to to_free
with every segment tagged QDISC_DROP_OVERLIMIT. flow_mode is read once
with READ_ONCE() and passed to both hash helpers.
Link: https://lore.kernel.org/netdev/179231933068.3135.80340792633077986@kernel.org/
> net/sched: cake: hash before segmenting and reject an overlong split
>
> The Fix:
> with CAKE_FLAG_SPLIT_GSO, cake computes the flow/host hash keys, then
> splits a GSO skb into segments it accounts individually.
[ ... ]
> Link: https://lore.kernel.org/netdev/179231933068.3135.80340792633077986@kernel.org/
> Reviewed-by: Victor Nogueira <victor@mojatatu.com>
> Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com>
[Severity: Low]
This isn't a bug, but the commit is presented as a fix and has no Fixes:
tag.
It adds the missing check of the segment sum against QDISC_MAX_BACKLOG on
the CAKE_FLAG_SPLIT_GSO path. It also stops cake_hash() state from being
committed for packets that are then dropped. The split-GSO accounting
dates back to when CAKE_FLAG_SPLIT_GSO was added to sch_cake.
Could a Fixes: tag be added so backporters know which kernels need this?
> diff --git a/net/sched/sch_cake.c b/net/sched/sch_cake.c
> index 91c33295b30b..730c90af14bd 100644
> --- a/net/sched/sch_cake.c
> +++ b/net/sched/sch_cake.c
[ ... ]
> @@ -1761,13 +1784,17 @@ static s32 cake_enqueue(struct sk_buff *skb, struct Qdisc *sch,
> {
> u32 idx, tin, prev_qlen, prev_backlog, drop_id;
> struct cake_sched_data *q = qdisc_priv(sch);
> + int flow_mode = READ_ONCE(q->config->flow_mode);
[Severity: Low]
The commit message says:
Read q->config->flow_mode once with READ_ONCE() in cake_enqueue() and
pass that value to both cake_hash_keys() and cake_hash_resolve().
Is the snapshot complete? Further down in the same cake_enqueue() call,
the flowchain code still reloads the live config with plain loads:
net/sched/sch_cake.c:cake_enqueue() {
...
WRITE_ONCE(flow->deficit, cake_get_flow_quantum(b, flow, q->config->flow_mode));
} else if (flow->set == CAKE_SET_SPARSE_WAIT) {
...
cake_inc_srchost_bulk_flow_count(b, flow, q->config->flow_mode);
cake_inc_dsthost_bulk_flow_count(b, flow, q->config->flow_mode);
}
...
}
cake_config_change() publishes the new mode with WRITE_ONCE() before
cake_change() takes sch_tree_lock(). A concurrent tc change can therefore
let cake_hash_resolve() run with a mode that lacks the dual src/dst bits,
so flow->srchost and flow->dsthost are not updated. The later reload can
then see the dual mode and charge hosts[] bulk counts at stale indices.
These plain loads also race with the WRITE_ONCE() store, which KCSAN can
report.
Would passing the local flow_mode to these three calls as well keep one
mode for the whole enqueue?
> int len = qdisc_pkt_len(skb), ret;
> u16 flow_override, host_override;
> + struct sk_buff *segs = NULL;
[ ... ]
> + if (qdisc_pkt_segs(skb) > 1 && q->config->rate_flags & CAKE_FLAG_SPLIT_GSO) {
> + struct sk_buff *nskb, *seg;
> + netdev_features_t features = netif_skb_features(skb);
> +
> + segs = skb_gso_segment(skb, features & ~NETIF_F_GSO_MASK);
> + if (IS_ERR_OR_NULL(segs))
> + return qdisc_drop(skb, sch, to_free);
[Severity: Medium]
The comment a few lines below says SKB_GSO_CB sits over
tc_skb_cb.drop_reason. Doesn't the same aliasing affect this failure
return?
__skb_gso_segment() writes the headroom into that slot before calling
skb_mac_gso_segment(), and that call can still fail. Examples are
-EINVAL on malformed SKB_GSO_DODGY headers from tun/virtio, or -ENOMEM in
skb_segment():
net/core/gso.c:__skb_gso_segment() {
...
SKB_GSO_CB(skb)->mac_offset = skb_headroom(skb);
...
segs = skb_mac_gso_segment(skb, features);
...
}
This overwrites the QDISC_DROP_GENERIC that __dev_xmit_skb() set before
enqueue. qdisc_drop() does not write a reason back. __tcf_kfree_skb_list()
then reads the headroom value, finds no qdisc subsystem bits, and passes it
to kfree_skb_reason() as a core skb_drop_reason:
net/sched/sch_generic.c:__tcf_kfree_skb_list() {
...
if ((reason & SKB_DROP_REASON_SUBSYS_MASK) == __QDISC_DROP_REASON) {
trace_qdisc_drop(q, txq, dev, skb, (enum qdisc_drop_reason)reason);
skb_reason = SKB_DROP_REASON_QDISC_DROP;
} else {
skb_reason = (enum skb_drop_reason)reason;
}
kfree_skb_reason(skb, skb_reason);
...
}
As a result, the drop gets an unrelated core reason and trace_qdisc_drop
is not emitted.
This return is unchanged from the old code. Since the patch moves this
block and re-tags the reject path for this exact aliasing, could this path
use qdisc_drop_reason(skb, sch, to_free, QDISC_DROP_GENERIC) or a more
specific reason?
> +
> + /* The split path accounts the segment sum, not the
> + * stab-adjusted qdisc_pkt_len(), so check it here.
> + */
> + skb_list_walk_safe(segs, seg, nskb)
> + slen += seg->len;
> +
> + if (unlikely((u64)sch->qstats.backlog + slen > QDISC_MAX_BACKLOG)) {
> + qdisc_qstats_overlimit(sch);
> + /* __skb_gso_segment() puts SKB_GSO_CB at cb
> + * offset 32, over tc_skb_cb.drop_reason; every
> + * segment inherits it. Tag each one with the
> + * qdisc drop reason.
> + */
> + skb_list_walk_safe(segs, seg, nskb)
> + tcf_set_qdisc_drop_reason(seg,
> + QDISC_DROP_OVERLIMIT);
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/QDISC-BA27.v7.r0.20261019115505%40mojatatu.com
Technical Details
Message-ID:
<179269577270.3135.16072065138845192450@kernel.org>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-350769-linux-kernel-netdev=dewy.ruReferences:
<QDISC-BA27.v7.r0.20261019115505-4@mojatatu.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-350769-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net-next v7 4/4] net/sched: cake: hash before segmenting and reject an overlong split Date: Thu, 22 Oct 2026 19:02:52 +0000 Organization: Usenet Network Message-ID: <179269577270.3135.16072065138845192450@kernel.org> References: <QDISC-BA27.v7.r0.20261019115505-4@mojatatu.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="298737"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:e3QeFK17x4lUGfE4hGbx8EwTLPs= sha256:ujciPfZqdI8L90RfklDyocS53VjqzHB9ZbqYpghON1E= sha1:azyH3dpDYswlJ0OS5am+JakO26Q= sha256:22WkaPSdUy19pkw2JgV3wXzcjg/wnN2WI3BiVQFeyHM= 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 4983311134D; Thu, 22 Oct 2026 22:07:55 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.738 X-Spam-Status: No, score=-3.738 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.339, 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, URIBL_BLOCKED=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 PsFLnCFvKPzF; Thu, 22 Oct 2026 22:07:52 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-350769-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 sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4]) by mail.dewy.ru (Postfix) with ESMTPS id 630CD111334; Thu, 22 Oct 2026 22:07:43 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sin.lore.kernel.org (Postfix) with ESMTP id 10F9A270F4; Thu, 22 Oct 2026 19:03:00 +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=1792695775; b=Twf6cSZH0QBMZBQ5SBm1Qq84FckHW2iKDnpx/XnRUiS84A/QZoeCNDniF29xLVlWa/a/ uhZXUwj7NeRc6/ysW8jSjP+P3F9anUxJB43TDf7MOxi7LLRIdrNxtrtAHVg+uT6/VYIoR S6UwCzRZ6STqSK5O0VdBle5l4Z/YyGUpuawZnvYB9yi5p+u85T7P/S6SJ6OCZZhUKE1Zz FonPMIIP4B9yvq3/Vnsed2XvV6j4VgUFrcW7JGilFldf1e+tnV5kw+ABZt0bRcodkliRb 9KHpfxgEhMGZLpUT4zCSKZloyTQGtZLq7ocCkkL7+OmBvmhSOqGE3YyuQDfwsaAZXxw== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1792695775; 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=NDpuli4IqtoNpm+YHK8wWRZYUu/reWo+WKo0tRkJcOA=; b=reN05Ocz8P7dXSmX6+lr/1oCwA/Cbo/kC9/S0G+gvWyy5oJuzUiPR0IDfPLr+P8Ot0B9 hnf/wpfIkZ7/SfyDzNgrN0lh3o9QAD/EepR4AbKUU9aw5ppDP7cp5Jx/QOq0tvaazWqjI ZJmBl6fim3RoK7deXf9XVEZE6/6w3FE6sRO8Fmfxu0kXjoM2H4bC7LFD/SAyHrj8RhaXH N2+7SiP/WAoycHFXDuK0qfgj36uJlCvrLVz2ugAlBp4Q2+sebkHHwuF9Zx5Y18iWJmg9k 9yNTXUBeZFaPeqSypmu8QKbkqun49/V83NLu/9RZaC6JyFynF1G6LpSAiaBO5MnGOcg== 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=O9VGrljH; 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 122AD606A323; Thu, 22 Oct 2026 19:02:55 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=O9VGrljH 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=1792695774; b=d1C1TL3EW6Gkr+U3lZZ/QkS3Pvdy/29uDTFZXNoTGVYDpfQxZjjCfqoEH5JfEl5B3lQp Pl5D91kAe32H1xuUC0bZysbuA7DZqBHtQ//pdvSr9UCWAg1o/73RIpFohqIL5AtX2AZyt hSceMNMHnF97UIBksOOaCe+nUm6R9wqCoVu4K12rsn82TWE2zZ6AnpeyUMYEQOQyzmR6s z8lus1qWXG1gWu9B0xDjUhzSJCZywKqxRMzFe47Uj2pLL8LJ6jJShX9SMZfcs6ZiStz4y B0D3UoJl+DTgm59nna7ofOLYKNfJwNsNm92k3RKhnltkqKRspjoAhRRbvdiGkRAQPEA== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1792695774; 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=NDpuli4IqtoNpm+YHK8wWRZYUu/reWo+WKo0tRkJcOA=; b=fMiIqCpNqztR8Vc4GmL0qwPUX+mv8+TkGUw/bMQf9VOifVArjO/RlwJg1MRFCSMcXbvK 137jdow876oTOanHaUl1QBYWvuCHxAn1PzXOnB1Cni2WDfQHzE5/cVjOtGWiZqY1ZR8m9 b5sQF2LVx9F8fmeGclmuRy+4WDU7H9MUI0lfegVstt1lbR/iDQODvQFpblZgaqrUZnupG CTIAV80vefzBYRaP+ZycLC3BlmvpYtWUJXneKLVWruEhvyoIpqm+eG/Nqx8VTceb5tUDF 8QkZ4SSChHimYVnARs1qYkTLfjlISq9F3Cq13nX7C7rIi9JR/9Of9DlsJG1rduuadng== 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=O9VGrljH; 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 E65EE606A329 for <netdev@vger.kernel.org>; Thu, 22 Oct 2026 19:02:53 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 263FB1F01828; Thu, 22 Oct 2026 19:02:53 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1792695773; bh=NDpuli4IqtoNpm+YHK8wWRZYUu/reWo+WKo0tRkJcOA=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=O9VGrljHODp2tLS5reDAAqxzVZB3fQV6NDVvVdbalxAPIiHTyq4H3entF3XQqsJGm nCtjprRnyoFEKQXq7SxFmQOejuBHBqRn9FQhq+n/nbVm/Z6w8ZwGnd3dCGHr5c1Ddp TO1qVjeUMvsgu0VjZ9EpEvbsWpfxgExT4n3yY30SBdVgmMQBdbvQMyrLJdjhteBmxd fYwDCaGGSFjk8O6skhMdCarj6oRKbgAiPB6uESC8A6oq5qoIp6FCeoWogXQGSxGyw3 GAyj0aLm01JT81UAvYrlN/rf0I8OFz0c50WIJeQTajRKukg7EBQ4njG9paNO07z+1L /Rdbc68bfOAlg== X-Cc: netdev@vger.kernel.org, jiri@resnulli.us, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, victor@mojatatu.com, toke@toke.dk, bjorn@kernel.org, sashiko-bot@kernel.org X-In-Reply-To: <QDISC-BA27.v7.r0.20261019115505-4@mojatatu.com> X-sashiko-severity: Medium 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