🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #5068

Re: [PATCH net-next v7 3/4] net/sched: cap the accounted backlog before it can wrap

#5068
From: Toke Høiland-Jørgensen
Date: Mon, 19 Oct 2026 18:20
91 lines
11715 bytes
Jamal Hadi Salim <jhs@mojatatu.com> writes:

> This is a followup of commit 709f34f7c28d ("net/sched: fq: add overflow
> bounds to quantum and initial quantum") as reported by Sashiko.

The rest of this commit message is somewhat obtuse - too much run-on
information. I think it can be pretty easily fixed by a couple of
rearrangements and paragraph breaks, like this:

> The issue: fq_codel, cake, codel, pie, fq_pie, dualpi2, RED, pfifo,
> plug and (non-WRED) gred account every enqueued packet's stab-adjusted
> length into the 32-bit sch->qstats.backlog. A crafted tc size table
> inflates qdisc_pkt_len() up to QDISC_PKT_LEN_MAX (1 MiB), and a dodgy
> GSO skb can account even more through qdisc_pkt_len_segs_init(), so a
> few thousand packets wrap the counter mod 2^32.
>
> The AQM then reads a small backlog and makes the wrong drop decision,
> and the dequeue-side subtractions leave it corrupt (for non-WRED gred
> it is the reported stats and the dequeue-side subtractions that go
> wrong instead). In fq_codel a wrapped per-flow backlog can also make
> fq_codel_drop()'s scan pick an empty flow, dereferencing a NULL
> flow->head.
>
> The Fix: drop at enqueue once the stored backlog cannot represent the
> incoming packet's accounted length.
>
> Ordinary packets (qdisc_pkt_len() at most QDISC_PKT_LEN_MAX) are
> covered by a standing ceiling: drop once the backlog is within
> QDISC_MAX_BACKLOG (U32_MAX - QDISC_PKT_LEN_MAX) of the wrap point, the
> largest backlog one more 1 MiB packet cannot wrap, so there is no
> per-enqueue 64-bit add.
>
> A larger wire estimate is checked against the space that actually
> remains (len > U32_MAX - backlog): qdisc_pkt_len_segs_init() adds the
> headers replicated on every output segment, so a supported small-MSS
> BIG TCP aggregate can carry a wire estimate above 1 MiB while its raw
> length stays within GSO_MAX_SIZE, and such traffic must pass on an
> empty queue.
>
> qdisc_pkt_len() itself stays truthful for every input: it is not
> clamped and the initializer keeps succeeding, so BPF
> __sk_buff.wire_len, act_police and the HTB/TBF shapers read the real
> length, and sch_handle_ingress() -- which ignores the initializer's
> return value and reads pkt_segs for packet statistics -- keeps
> complete metadata.
>
> Cover sch_plug and non-WRED sch_gred too: plug admits on skb->len
> while qdisc_enqueue_tail() adds qdisc_pkt_len(), and gred bounds each
> virtual queue but adds every VQ into the one aggregate. pfifo is
> included because RED reads a grafted child's backlog into
> red_calc_qavg(); it can be reached standalone or as the default child
> of SFB. In RED, account the packet to the aggregate before handing it
> to the child, because a duplicating netem child re-enqueues its clone
> at the root while the stored backlog is still un-updated -- one guard
> check must not authorize two additions.
>
> The guard bounds each qdisc's own enqueue path: a child that segments a
> GSO skb (tbf, netem) can still grow a parent's aggregate through
> qdisc_tree_reduce_backlog()'s unclamped byte delta, which is left to a
> separate change.
>
> Conditions to recreate the bug:
>   ip tuntap add tun0 mode tun
>   ip link set tun0 txqueuelen 32 up
>   ip addr add 10.99.0.1/24 dev tun0
>   tc qdisc add dev tun0 root handle 1: stab overhead 2000000000 \
>       fq_codel flows 1 limit 20000 ecn
>   # hold the tun fd open without reading so the backlog persists, then
>   # send 6000 packets: the counter wraps and the unfixed kernel reports
>   # a wrapped backlog, while the fixed one drops at the ceiling.
>
> Reported-by: Sashiko (nipa) <sashiko-bot@kernel.org>
> Closes: https://lore.kernel.org/netdev/20260818101130.16203-1-jhs@mojatatu.com/
> Link: https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260818101130.16203-1-jhs@mojatatu.com
> Link: https://lore.kernel.org/netdev/CANn89iLfMJV7ancKH1Gjzzm7ZUG-gKcrczkJjJEWN5sCuWd-ug@mail.gmail.com/
> Link: https://lore.kernel.org/netdev/CANn89i+GOFH_8g+vSV0jUj0aBqLYVWuFOrHuDggZu9kPC_m6tQ@mail.gmail.com/
> Link: https://lore.kernel.org/netdev/87a4oottcj.fsf@toke.dk/
> Link: https://lore.kernel.org/netdev/87pkxks68f.fsf@toke.dk/
> Link: https://lore.kernel.org/netdev/179231932946.3135.7497478990186385688@kernel.org/
> Reviewed-by: Victor Nogueira <victor@mojatatu.com>
> Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com>

With the above rewording:

Reviewed-by: Toke Høiland-Jørgensen <toke@toke.dk>
Technical Details
Message-ID: <87qzhlwo0a.fsf@toke.dk>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-348780-linux-kernel-netdev=dewy.ru
References: <QDISC-BA27.v7.r0.20261019115505@mojatatu.com> <QDISC-BA27.v7.r0.20261019115505-3@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-348780-linux-kernel-netdev=dewy.ru
From: toke@toke.dk (Toke Høiland-Jørgensen)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next v7 3/4] net/sched: cap the accounted backlog
 before it can wrap
Date: Mon, 19 Oct 2026 20:20:37 +0200
Organization: Usenet Network
Message-ID: <87qzhlwo0a.fsf@toke.dk>
References: <QDISC-BA27.v7.r0.20261019115505@mojatatu.com>
 <QDISC-BA27.v7.r0.20261019115505-3@mojatatu.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
Injection-Info: usenet.network;
	logging-data="3683692"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:f3giDt+APMl6QcSI7/jR81+R1yE= sha256:R7flgIeN7rEtQJEuMagz6t1KWw0Wcr0RqzdzhOhZ0W8=
	sha1:8f4FQlXnEhvM5TNNq/wPO3G69aU= sha256:Q05JEJTps9zy/RxZy28fCR5BnHxdwy1+yegXD95H9n4=
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 3629A110ABC; Mon, 19 Oct 2026 21:21:04 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -1.95
X-Spam-Status: No, score=-1.95 tagged_above=-9999 required=6.31
	tests=[DKIM_ADSP_ALL=1.1, HEADER_FROM_DIFFERENT_DOMAINS=0.25,
	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-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 qGgJIrFeW1_V;
	Mon, 19 Oct 2026 21:21:00 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-348780-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=toke.dk
X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])
	by mail.dewy.ru (Postfix) with ESMTPS id 7C96F110AB9; Mon, 19 Oct 2026 21:20:57 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sto.lore.kernel.org (Postfix) with ESMTP id C3E106069E8; Mon, 19 Oct 2026 18:20:43 +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=1792434042;
	b=d0VyJ78BAaopTVqAMuX/quKf+4CjfSC+QVeLF6VENcYCEDXtnpc4ooHaXws7k7HodczN
	 aibPpUT1vKsr9HLj77X/HKnuADlIk5JMN9kk3y3IH7gZCN/rq7cVpNxv/YehtURxb7B1d
	 gy6Kyicv5UbchPw8An8aDTrNqqe58zrTv+sYjIVJp+RV4tEGbKPtl3rTMa6v1nxgzmTt8
	 iAgF01OK/5RD6RK6122ccpk3P353tag/NJFS5TauPkJAr4UAHIckH6UiBTeeqqUmqD15l
	 CTiIwPWuNQ0XCJKcuLrHSRWq2VwYU+8VBBGBI/7tq82Lmr+VeWV540VoJlI7eoQ05Vw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1792434042;
	h=X-Original-To:Received:DMARC-Filter:From:To:Cc:Subject:In-Reply-To:
	 References:Date:X-Clacks-Overhead:Message-ID:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version:Content-Type:Content-Transfer-Encoding;
	bh=ZcbHoxrfqEHfDq1Rfpu4r8aohSSEvh2uhD95y+eK840=;
	b=u6vHnFancHIhuJPkzdP4W4UOuUx++LRd43EpPAEFKY/sJ2C5rQzSOxr7uz15c6ayCNwt
	 UYRH9QHlWkSsC29P3RQoaoPsoz9Ws1a4t5nASqNZ1eiiMWOheDPtBaEQ5+jBgpu6/p/cB
	 oYj/NgJu9qX8DPBxDi5TvtRS2NjjRLfvaTDBKVn7lTvsCUz1trNrqolPNc4eF8c7k/ZLC
	 jQ3S9+dMMy+81GiUDk859gG2Q+1TFvRvs/aCKYR+zPNMn4NBUOPNdPp4+rjui1KhJsBYj
	 ShI238NgVEvcbb/bHikKei33pbTo1omc+/v4PXcVarZ3iVDlYqnsExMIrrU8YevFcrQ==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dmarc=pass header.from=toke.dk;
	spf=pass smtp.mailfrom=toke.dk;
	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 DB735606A31C;
	Mon, 19 Oct 2026 18:20:42 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=45.145.95.4
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1792434042;
	b=fHFdVV8u53mKKSrO8/R5VWy81TXvHHZd+NuzsmDZFQvkItxhh1QVCNYnlR/1q3Vvi3nJ
	 3CK7NIkpgrKVYJqPoks84DIky6M4pl9X2ZH3BlZcs6vNfMCoFsm7wJupPLoQ0AmFLV3Ql
	 i9N+67r1SRK7BWp+YVJ/WoKyLBfUgMUbdeCe51c7V+v4wGhGmT6hlOPOp/Hc3/UpirI/Z
	 58khXT0AcWFXvOuAqYo8Tw0GUJWW4jtqemx7b1nwBcu0sBWrVX41c1on4re+yIEl1iwmm
	 cY9U3I62qEfq4nGLjOTTgrWvQHwmGIJLratjlU6uOSplaT8S95uNKsSExVXheHsb9Ng==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1792434042;
	h=DMARC-Filter:From:To:Cc:Subject:In-Reply-To:References:Date:
	 X-Clacks-Overhead:Message-ID:MIME-Version:Content-Type:
	 Content-Transfer-Encoding;
	bh=ZcbHoxrfqEHfDq1Rfpu4r8aohSSEvh2uhD95y+eK840=;
	b=ZmF7kdoI47B9yo5DtzsRwQq2L0MsoWSXB1baCMJQnSvgDr/ms/QTjRTst230YeeiIAUQ
	 wzG1yCeP7AbsNamqTKkmXGvALK9wOUxNJ6/m+dWn11x0vguOFZVuLiYsWNteJP5HscPzA
	 ePqOW+ief9Qk2TEe26bK9oCovk7d/u0q1JBROtFV/MzRNVb41Qoez6Rp8EdW0pQC6sdmg
	 Q7uA3Pav9PdbV7xmf+wZGsziLpSFta6jbIUg9XliiTxWkSoLZwoR5MvGvpcJie3F7yHOI
	 tAcUlUvYOw47VadkskBSVXWR/0lEEAQF6fjn/UWjGWAN3kBhC0HU1G3WlZoMq0BMDLw==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=toke.dk;
	spf=pass smtp.mailfrom=toke.dk;
	arc=none smtp.remote-ip=45.145.95.4
X-Received: from mail.toke.dk (mail.toke.dk [45.145.95.4])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id A8AD5606A31A
	for <netdev@vger.kernel.org>; Mon, 19 Oct 2026 18:20:40 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org A8AD5606A31A
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=toke.dk
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=toke.dk
X-Authentication-Results: mail.toke.dk; dkim=none
X-Cc: Jamal Hadi Salim <jhs@mojatatu.com>, Jiri Pirko <jiri@resnulli.us>,
 "David S . Miller" <davem@davemloft.net>, Eric Dumazet
 <edumazet@kernel.org>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni
 <pabeni@redhat.com>, Simon Horman <horms@kernel.org>, Victor Nogueira
 <victor@mojatatu.com>, Björn Töpel <bjorn@kernel.org>,
 cake@lists.bufferbloat.net, Sashiko <sashiko-bot@kernel.org>
X-In-Reply-To: <QDISC-BA27.v7.r0.20261019115505-3@mojatatu.com>
X-Clacks-Overhead: GNU Terry Pratchett
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