On Sat, Nov 28, 2026 at 7:08 AM <netd…@kernel.org> wrote:
>
> Thank you for your contribution! Sashiko AI review found 8 potential
> issue(s) to consider.
>
> Critical: 0 · High: 2 · Medium: 5 · 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).
>
So version 13 on a friday and still no luck?
> - [High] Signed reinterpretation in qdisc_tree_reduce_backlog() can
> blackhole the parent qdisc for good.
> - [High] taprio's backlog/qlen can leak upward through control-path child
> drops, and the new guard then drops every packet.
So version 13 on a friday and still no luck? The taprio issue is my
fault in v13. So v14 coming up.
cheers,
jamal
> - [Medium] The saturating reconciliation breaks reduce-before-book
> accounting and leaves a phantom backlog.
> - [Medium] The offload exemption depends on a flag that is cleared on
> every stats dump, while the driver still writes non-saturating…
> - [Medium] The core saturation also runs on offloaded ancestors and
> breaks the drivers' signed-delta hardware accounting.
> - [Medium] Segmenting children other than cake still grow ancestors
> without the room check.
> - [Medium] The commit message misdescribes some changes and leaves out
> several separate behavioural changes.
> - [Low] No Fixes: tag.
>
> --
>
> net/sched: cap the accounted backlog before it can wrap
>
> This patch adds an enqueue-time guard, qdisc_backlog_overflow(), across
> the net/sched qdiscs. The guard drops a packet once the 32-bit
> sch->qstats.backlog can no longer hold its accounted length. It also makes
> the core backlog subtraction saturate, routes qdisc_tree_reduce_backlog()
> and sfq through a new signed qdisc_qstats_backlog_apply(), and reworks
> taprio to mirror its children's backlog changes.
>
> Closes: https://lore.kernel.org/netdev/2026…@mojatatu.com/
> Link: https://netdev-ai.bots.linux.dev/sashiko/#/patchset/2026…@mojatatu.com
> Link: https://lore.kernel.org/netdev/CANn…@mail.gmail.com/
> Link: https://lore.kernel.org/netdev/CANn…@mail.gmail.com/
> Link: https://lore.kernel.org/netdev/87a4…@toke.dk/
> Link: https://lore.kernel.org/netdev/87pk…@toke.dk/
> Link: https://lore.kernel.org/netdev/1792…@kernel.org/
> Link: https://lore.kernel.org/netdev/1792…@kernel.org/
>
> > This is a followup of commit 709f34f7c28d ("net/sched: fq: add overflow
> > bounds to quantum and initial quantum") as reported by Sashiko.
>
> [Severity: Low]
> This isn't a bug, but should this have a Fixes: tag for the commit that
> introduced the backlog wrap, and possibly a stable Cc?
>
> 709f34f7c28d is an fq quantum change, not the source of the wrap. The tag
> block only has Reported-by, Closes, Link and Signed-off-by. The separate
> hhf/skbprio and plug fixes bundled here don't have Fixes: tags either.
>
> [ ... ]
>
> > Some context: qdisc_pkt_len() stays truthful for every input, so BPF
> > wire_len, act_police and the HTB/TBF shapers read the real length. RED
> > books the packet on success again, as the tree did before v11.
>
> [Severity: Medium]
> Is the RED sentence accurate for the tree this applies to? The baseline
> red_enqueue() already books the packet on success:
>
> ret = qdisc_enqueue(skb, child, to_free);
> if (likely(ret == NET_XMIT_SUCCESS)) {
> qstats_backlog_add(sch, len);
> qdisc_qlen_inc(sch);
>
> The RED hunk in this patch only adds the new guard. The references to v11,
> "stays truthful" and "at dequeue as well" only make sense relative to
> earlier postings of the series.
>
> The message also leaves out several behavioural changes in the diff:
>
> hhf_enqueue() and skbprio_enqueue() now call qdisc_tree_reduce_backlog()
> on the NET_XMIT_CN path. This fixes a separate, pre-existing drift in
> the parent backlog.
>
> plug_enqueue() now checks its limit against qdisc_pkt_len() instead of
> skb->len, which changes admission for stab and GSO users.
>
> taprio_enqueue_segmented() no longer adds child drops to taprio's own
> drop counter.
>
> netem_enqueue() now pre-books qlen before it re-injects the duplicate,
> so a duplicate near sch->limit can now be dropped where it used to be
> admitted.
>
> Could these be described in the commit message, or split out?
>
> > diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h
> > index 1acaadb3e2cf0..677cd089ad5d3 100644
> > --- a/include/net/sch_generic.h
> > +++ b/include/net/sch_generic.h
> > @@ -735,6 +735,12 @@ void qdisc_destroy(struct Qdisc *qdisc);
> > void qdisc_put(struct Qdisc *qdisc);
> > void qdisc_put_unlocked(struct Qdisc *qdisc);
> > void qdisc_tree_reduce_backlog(struct Qdisc *qdisc, int n, int len);
> > +/* Does every ancestor of @sch have room for @extra more bytes below its
> > + * enqueue ceiling? A child that turns one skb into several reconciles the
> > + * difference through qdisc_tree_reduce_backlog(), growth that never passes
> > + * the ancestors' own enqueue guard.
> > + */
> > +bool qdisc_ancestors_backlog_room(const struct Qdisc *sch, u64 extra);
>
> [Severity: Medium]
> Who calls this helper at this commit? It is exported but has no caller
> here. Later in the series, "net/sched: cake: hash before segmenting and
> reject an overlong split" adds a call in cake_enqueue(), and that is the
> only caller.
>
> tbf_segment() and the netem segment path also turn one skb into several,
> and they grow the ancestors without this room check:
>
> net/sched/sch_tbf.c:tbf_segment() {
> ...
> qstats_backlog_add(sch, len);
> if (nb > 0) {
> qdisc_tree_reduce_backlog(sch, 1 - nb, prev_len - len);
> ...
> }
>
> net/sched/sch_netem.c:netem_enqueue() {
> ...
> qdisc_tree_reduce_backlog(sch, -(nb - 1), -(len - prev_len));
> ...
> }
>
> The QDISC_MAX_BACKLOG comment says "a single enqueue can never run out of
> headroom before it is accounted". That only holds if this growth stays
> under about 2 MiB.
>
> Could a stab table that maps a large encapsulated BIG TCP aggregate to
> just above tbf's max_size push the segment sum past that headroom? That
> would wrap tbf's counter or an ancestor's.
>
> The later cake patch calls this bound defensive rather than proven, so
> this may be hard to reach. It also doesn't match the commit message claim
> that the ceiling covers "every qdisc in net/sched that adds the incoming
> qdisc_pkt_len() to its own backlog".
>
> > @@ -915,6 +921,37 @@ static inline unsigned int qdisc_pkt_len(const struct sk_buff *skb)
> > return qdisc_skb_cb(skb)->pkt_len;
> > }
> >
> > +#define QDISC_PKT_LEN_MAX (1 << 20) /* 1 MiB */
> > +
> > +/* Largest backlog that still has room for a 1 MiB packet and a netem
> > + * duplicate of it, so that a single enqueue can never run out of
> > + * headroom before it is accounted.
> > + */
> > +#define QDISC_MAX_BACKLOG (U32_MAX - 2 * QDISC_PKT_LEN_MAX)
>
> [ ... ]
>
> > +static inline bool qdisc_backlog_overflow(const struct Qdisc *sch,
> > + const struct sk_buff *skb)
> > +{
> > + u32 len = qdisc_pkt_len(skb);
> > + u32 backlog;
> > +
> > + if (unlikely(READ_ONCE(sch->flags) & TCQ_F_OFFLOADED))
> > + return false;
>
> [Severity: Medium]
> Can the qdisc lose this exemption while its counter still carries
> hardware bytes? qdisc_offload_dump_helper() clears the flag around every
> stats query and sets it again only on success:
>
> net/sched/sch_api.c:qdisc_offload_dump_helper() {
> ...
> sch->flags &= ~TCQ_F_OFFLOADED;
> if (!tc_can_offload(dev) || !dev->netdev_ops->ndo_setup_tc)
> return 0;
>
> err = dev->netdev_ops->ndo_setup_tc(dev, type, type_data);
> ...
> if (!err)
> sch->flags |= TCQ_F_OFFLOADED;
> ...
> }
>
> This runs from dump callbacks such as red_dump()->red_dump_offload_stats()
> with only RTNL held, because tc_fill_qdisc() calls q->ops->dump() without
> the qdisc root lock.
>
> Inside that window, mlxsw updates the counter with plain u32 arithmetic.
> That races with the datapath's saturating update:
>
> mlxsw_sp_qdisc_update_stats():
> stats_ptr->qstats->backlog += mlxsw_sp_cells_bytes(mlxsw_sp, backlog);
>
> mlxsw_sp_qdisc_leaf_unoffload():
> qstats->backlog -= backlog;
>
> nfp_abm_stats_propagate() also writes hardware deltas without saturating.
>
> The new comment in qdisc_qstats_backlog_dec() says a datapath update can
> be lost here. If that happens and the hardware then drains, could the
> driver's delta wrap the counter to near U32_MAX?
>
> If so, enqueues during later dump windows would hit the ceiling. After an
> unoffload, where the flag stays cleared, every enqueue would be dropped.
>
> The TCQ_F_OFFLOADED check in qdisc_ancestors_backlog_room() has the same
> window.
>
> [ ... ]
>
> > @@ -991,13 +1028,43 @@ static inline void qdisc_bstats_update(struct Qdisc *sch,
>
> [ ... ]
>
> > +static inline void qdisc_qstats_backlog_apply(struct Qdisc *sch, int delta)
> > +{
> > + u32 backlog = READ_ONCE(sch->qstats.backlog);
> > + u64 next;
> > +
> > + if (delta >= 0)
> > + next = backlog > (u32)delta ? backlog - (u32)delta : 0;
>
> [Severity: Medium]
> Should this clamp also apply to offloaded ancestors? Their counter
> includes hardware deltas that the driver maintains.
>
> mlxsw keeps the hardware share as a modular delta against a per-qdisc
> baseline in mlxsw_sp_qdisc_update_stats(). When an offloaded child is
> destroyed, it rebases the parent on the assumption that the core
> subtracted exactly:
>
> mlxsw_sp_qdisc_reduce_parent_backlog():
> tmp->stats_base.backlog -= mlxsw_sp_qdisc->stats_base.backlog;
>
> The parent and child baselines come from different dumps. The parent's
> counter can therefore be lower than the child's, for example if the parent
> was dumped while the tclass was empty and the child while it was full.
>
> prio_graft()->qdisc_replace()->qdisc_purge_queue()->
> qdisc_tree_reduce_backlog() then subtracts the child's backlog. The clamp
> stops at 0, but the next parent dump still adds back the full hardware
> share of the child.
>
> Wouldn't the parent then stay too high by that amount for good?
> mlxsw_sp_qdisc_leaf_unoffload() only removes stats_base, so the excess
> would also carry over into the software-only qdisc.
>
> > diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c
> > index f36c41224bccf..062e5d6f158eb 100644
> > --- a/net/sched/sch_api.c
> > +++ b/net/sched/sch_api.c
> > @@ -877,13 +877,55 @@ void qdisc_tree_reduce_backlog(struct Qdisc *sch, int n, int len)
> > cops->qlen_notify(sch, cl);
> > }
> > WRITE_ONCE(sch->q.qlen, sch->q.qlen - n);
> > - qstats_backlog_sub(sch, len);
> > + qdisc_qstats_backlog_apply(sch, len);
> > __qdisc_qstats_drop(sch, drops);
>
> [Severity: High]
> Can a large but legitimate removal now be treated as growth here? len is
> an int. qstats_backlog_sub() took it as a u32, so modular arithmetic got
> removals of up to 4 GiB right. qdisc_qstats_backlog_apply() treats a
> negative int as growth and saturates at U32_MAX.
>
> Control-path callers pass unsigned byte counts through this int:
>
> include/net/sch_generic.h:qdisc_purge_queue():
> qdisc_tree_reduce_backlog(sch, qlen, backlog);
>
> net/sched/sch_fq_codel.c:fq_codel_change():
> unsigned int dropped_pkts = 0, dropped_bytes = 0;
> ...
> qdisc_tree_reduce_backlog(sch, dropped_pkts, dropped_bytes);
>
> The codel, fq, fq_pie, hhf, pie, sfq and cake ->change() handlers do the
> same.
>
> With the new ceiling, a child backlog between 2 GiB and about 4 GiB is a
> reachable state. One setup: a root prio/htb/drr/ets/tbf/red, a stab
> overhead as in the reproducer, and an fq_codel child filled to about
> 3 GiB. Then "tc qdisc change ... fq_codel limit 1", a class delete or a
> child replace passes len > INT_MAX.
>
> Would every ancestor then grow by 2^32 - len and stay pinned at U32_MAX?
>
> >From then on, qdisc_backlog_overflow() sees backlog > QDISC_MAX_BACKLOG
> and drops every packet with QDISC_DROP_OVERLIMIT. The children are empty,
> so no dequeue ever brings the counter down. That is the "drop every packet
> for good" outcome the new qdisc_qstats_backlog_dec() comment tries to
> prevent.
>
> [Severity: Medium]
> Moving from modular subtraction to a clamp has a second effect. Some
> children report a reduction to their ancestors before the parent has
> booked the packet. tbf_segment() calls:
>
> qdisc_tree_reduce_backlog(sch, 1 - nb, prev_len - len);
>
> and then returns NET_XMIT_SUCCESS, after which the parent does
> qstats_backlog_add(sch, prev_len). The netem_enqueue() segment path and
> the cake_enqueue() split-GSO path use the same order.
>
> With modular arithmetic, the parent ended up correct once it booked
> prev_len. With the clamp, take B as the parent's current backlog and
> d = prev_len - len. If B < d, the reduction stops at 0, the parent then
> adds prev_len, and later dequeues remove only len.
>
> Doesn't that leave a phantom backlog of d - B bytes with qlen 0?
>
> This can happen with an idle htb/prio/drr parent over a tbf leaf, when
> stab inflation (for example linklayer atm overhead) makes prev_len larger
> than the segment sum, or when some segments are dropped.
> red_calc_qavg(child->qstats.backlog) over such a classful child would
> read the inflated value. The commit message presents the saturation as
> purely protective.
>
> [ ... ]
>
> > diff --git a/net/sched/sch_taprio.c b/net/sched/sch_taprio.c
> > index 5a1dca9d5e9de..42364c785c838 100644
> > --- a/net/sched/sch_taprio.c
> > +++ b/net/sched/sch_taprio.c
>
> [ ... ]
>
> > @@ -585,10 +589,36 @@ static bool taprio_skb_exceeds_queue_max_sdu(struct Qdisc *sch,
> > return exceeds;
> > }
> >
> > +/* The child cannot correct us: taprio_graft() marks it TCQ_F_NOPARENT, so
> > + * its qdisc_tree_reduce_backlog() stops there. Mirror its net change.
> > + */
> > +static void taprio_mirror_child(struct Qdisc *sch, struct Qdisc *child,
> > + u32 backlog_before, int qlen_before)
> > +{
> > + /* apply() takes the amount to remove, so a child growth is negated
> > + * and a child eviction adds.
> > + */
> > + qdisc_qstats_backlog_apply(sch,
> > + -(int)(READ_ONCE(child->qstats.backlog) -
> > + backlog_before));
> > + WRITE_ONCE(sch->q.qlen,
> > + sch->q.qlen + (int)(qdisc_qlen(child) - qlen_before));
> > +}
> > +
> > static int taprio_enqueue_one(struct sk_buff *skb, struct Qdisc *sch,
> > struct Qdisc *child, struct sk_buff **to_free)
> > {
> > struct taprio_sched *q = qdisc_priv(sch);
> > + struct Qdisc *mirror_prev;
> > + u32 backlog;
> > + int qlen;
> > + int ret;
> > +
> > + if (unlikely(qdisc_backlog_overflow(sch, skb))) {
> > + qdisc_qstats_overlimit(sch);
> > + return qdisc_drop_reason(skb, sch, to_free,
> > + QDISC_DROP_OVERLIMIT);
> > + }
>
> [Severity: High]
> What happens to taprio's counters when a child drops packets outside the
> enqueue and dequeue windows?
>
> taprio's backlog and qlen are now updated only from child deltas measured
> around enqueue and dequeue. taprio_graft() and taprio_attach() set
> TCQ_F_NOPARENT on every child, so qdisc_tree_reduce_backlog() stops at the
> child:
>
> net/sched/sch_api.c:qdisc_tree_reduce_backlog() {
> ...
> if (sch->flags & TCQ_F_NOPARENT)
> break;
> ...
> }
>
> A child's ->change() can drop queued packets without taprio seeing it.
> Examples are fq_codel_change() and the codel, pie, fq_pie, hhf, fq, sfq
> and cake equivalents, or a class delete inside a classful child.
>
> Nothing removes those packets from taprio's sch->qstats.backlog or
> sch->q.qlen. taprio_dump() does not resync from the children, and only a
> qdisc_reset() of the root clears the counters.
>
> Take a software-mode taprio with an fq_codel child on a txq and a stab
> overhead that accounts each packet at about 1 MiB. Filling the child and
> running "tc qdisc change dev X parent <taprio>:N fq_codel limit 1", over
> and over, would keep adding leaked bytes. A graft goes through
> dev_deactivate(), which resets the root, so a graft does not leak.
>
> Once the leaked total passes QDISC_MAX_BACKLOG, won't this new guard drop
> every packet on the device with QDISC_DROP_OVERLIMIT? The children are
> empty, so nothing brings the counter back down.
>
> Before this patch the drift only made the stats wrong. The guard now turns
> it into a permanent drop.
>
> [ ... ]
>
> --
> Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/QDIS…%40mojatatu.com