🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #23064

[PATCH net] net/sched: enforce the FQ-PIE memory limit

#23064
From: shaos
Date: Thu, 26 Nov 2026 12:29
94 lines
12635 bytes
Hello,

fq_pie_qdisc_enqueue() detects when the incoming skb would
exceed memory_limit, but the memory_limited branch only increments
overmemory. It then continues through PIE admission and can enqueue
the packet. The current check also adds skb->truesize to
memory_limit, which can overflow.

With a 4 KiB memory_limit, the reproducer keeps 49 packets queued,
accounts 110592 bytes in memory_usage, and reports overmemory while
dropping no packets. A 32 MiB limit control accepts the same traffic.
Drop an skb when its truesize exceeds the remaining budget, using
subtraction-based bounds checks to avoid overflow.

The test configures the qdisc and TBF parent as root in a disposable
QEMU guest (CAP_NET_ADMIN). Ordinary UDP traffic then exercises the
enqueue path. This violates the qdisc's documented memory_limit
contract; the test does not demonstrate privilege escalation.

HEAD commit:    8d7fe9885c62fc9a95bf55d9db244d9672a8aadc
git tree:       fe970b05333fb8e41da21e9e289f652abcc7cba7
source version: Linux 7.4.0-rc4-g8d7fe9885c62
compiler:       gcc 11.4.0, GNU ld 2.38

The Gist contains the complete console output, kernel configuration,
sender source, and initramfs/QEMU helpers:
https://gist.githubusercontent.com/shaos26/903cfb53571c9271fefaadffde3469e5/raw/a417f18ab4665e1740dc06e06ebaf1c4a07613b8/console-output.txt
https://gist.githubusercontent.com/shaos26/903cfb53571c9271fefaadffde3469e5/raw/a417f18ab4665e1740dc06e06ebaf1c4a07613b8/kernel-config.txt
https://gist.githubusercontent.com/shaos26/903cfb53571c9271fefaadffde3469e5/raw/a417f18ab4665e1740dc06e06ebaf1c4a07613b8/send_burst.c
https://gist.githubusercontent.com/shaos26/903cfb53571c9271fefaadffde3469e5/raw/a417f18ab4665e1740dc06e06ebaf1c4a07613b8/guest-init.sh
https://gist.githubusercontent.com/shaos26/903cfb53571c9271fefaadffde3469e5/raw/a417f18ab4665e1740dc06e06ebaf1c4a07613b8/build-initramfs.sh
https://gist.githubusercontent.com/shaos26/903cfb53571c9271fefaadffde3469e5/raw/a417f18ab4665e1740dc06e06ebaf1c4a07613b8/run-qemu-test.sh
https://gist.githubusercontent.com/shaos26/903cfb53571c9271fefaadffde3469e5/raw/a417f18ab4665e1740dc06e06ebaf1c4a07613b8/verify-log.sh

Build the kernel from the HEAD commit above with kernel-config.txt.
The initramfs script requires BusyBox, iproute2, static gcc, cpio,
gzip, and QEMU. Run the same small-limit and large-limit cases:

    ./build-initramfs.sh
    KERNEL=linux/build/arch/x86/boot/bzImage \
    INITRAMFS="$PWD/initramfs-fqpie-rebuilt.cpio.gz" \
    LOG="$PWD/fqpie-small.log" \
        ./run-qemu-test.sh positive 1
    KERNEL=linux/build/arch/x86/boot/bzImage \
    INITRAMFS="$PWD/initramfs-fqpie-rebuilt.cpio.gz" \
    LOG="$PWD/fqpie-control.log" \
        ./run-qemu-test.sh control 1

The unpatched small-limit run accepts the packet burst and exceeds
the configured memory budget. The patched run drops packets once the
budget is reached and keeps memory_used at 2304 bytes, below 4096.
The large-limit control continues to accept the same traffic.

Fixes: ec97ecf1ebe4 ("net: sched: add Flow Queue PIE packet scheduler")
Cc: stable@vger.kernel.org
Signed-off-by: shaos <shawnq1@163.com>
---
 net/sched/sch_fq_pie.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/net/sched/sch_fq_pie.c b/net/sched/sch_fq_pie.c
index 5982847df8f85..2e14467ae6585 100644
--- a/net/sched/sch_fq_pie.c
+++ b/net/sched/sch_fq_pie.c
@@ -134,7 +134,7 @@ static int fq_pie_qdisc_enqueue(struct sk_buff *skb, struct Qdisc *sch,
 	struct fq_pie_sched_data *q = qdisc_priv(sch);
 	struct fq_pie_flow *sel_flow;
 	int ret;
-	u8 memory_limited = false;
+	bool memory_limited;
 	u8 enqueue = false;
 	u32 pkt_len;
 	u32 idx;
@@ -152,7 +152,8 @@ static int fq_pie_qdisc_enqueue(struct sk_buff *skb, struct Qdisc *sch,
 	sel_flow = &q->flows[idx];
 	/* Checks whether adding a new packet would exceed memory limit */
 	get_pie_cb(skb)->mem_usage = skb->truesize;
-	memory_limited = q->memory_usage > q->memory_limit + skb->truesize;
+	memory_limited = skb->truesize > q->memory_limit ||
+		q->memory_usage > q->memory_limit - skb->truesize;
 
 	/* Checks if the qdisc is full */
 	if (unlikely(qdisc_qlen(sch) >= sch->limit)) {
@@ -160,6 +161,7 @@ static int fq_pie_qdisc_enqueue(struct sk_buff *skb, struct Qdisc *sch,
 		goto out;
 	} else if (unlikely(memory_limited)) {
 		q->overmemory++;
+		goto out;
 	}
 
 	reason = QDISC_DROP_CONGESTED;
-- 
2.43.0
Technical Details
Message-ID: <20261126122902.1504968-1-shawnq1@163.com>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!2.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-372093-linux-kernel-netdev=dewy.ru

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!2.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-372093-linux-kernel-netdev=dewy.ru
From: shawnq1@163.com (shaos)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net] net/sched: enforce the FQ-PIE memory limit
Date: Thu, 26 Nov 2026 12:29:02 +0000
Organization: Usenet Network
Message-ID: <20261126122902.1504968-1-shawnq1@163.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network; logging-data="463586"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:GZlurmNAw55F0nAKH09dj1v8aMw= sha256:2+cnTBCTSt265Z+/PMRG9ar0YATMiQcWiSkNt37h51g= sha1:udZs8wChD8G/rjt6kbkINaQcrKw= sha256:6XxhpoFN/e4X516btzw3Z9BdSjYsvOexMbSJWNNDkO4=
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 D2EC1125ED2; Thu, 26 Nov 2026 15:30:10 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.147
X-Spam-Status: No, score=-3.147 tagged_above=-9999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (1024-bit key) header.d=163.com
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 t47F8805lqyG; Thu, 26 Nov 2026 15:30:06 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-372093-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=163.com
X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74]) by mail.dewy.ru (Postfix) with ESMTPS id 93EBD125ED5; Thu, 26 Nov 2026 15:29: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 5DF69605255; Thu, 26 Nov 2026 12:29:57 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=fail; t=1795696193; b=eGCjXJ1JGPPfRc9PnI0fSZsM9w4Ct9PgSZUy5ZiNgwNd9oh9DLqbG8i4YuIqBaKPNio+ aoxNee502GiRqA2IT1ucgeCI2i6nUOpHAtSxgL2nJsJjHBR4N5THb4VKQoD/C2CCsiz0B DstLfLy0oQuyb0MuLS/RcChooX9zbA+gdAM/X7iRIU8+ahaAvlbdKeipWaRngplleIHdC UUF/w7NdoOHRW2Wx+Enig9d2Wtips3Vt/bBiUa4bcn89YJTOT0awNiAoIHHzN2LYbQCo3 OWxtGFq4R5Vt2vU0QnuyHnsq51rl1qzELZ4OMaefTZCixw1sFbkXz1WmHvvkns7rvjg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795696193; h=X-Original-To:Received:DMARC-Filter:DKIM-Signature:Received:From:To: Cc:Subject:Date:Message-Id:X-Mailer:X-Mailing-List:List-Id:List-Post: List-Help:List-Subscribe:List-Unsubscribe:List-Owner:Precedence: MIME-Version:Content-Transfer-Encoding:X-CM-TRANSID: X-Coremail-Antispam:X-CM-SenderInfo; bh=RnxrMYpTCDIMktD1X0shShcdslhXt1F2LJgmog6mN8Y=; b=zlw7gW9Tten/3Leiy1U4TpnjtrfGRuJuHcUu9VnZxN6vMWTSB8EMO9sKMQbA/Uq1JtL3 ttajPNKjngYzv0oxDCkIYZckng+9CeV2p9tWnv2baGgw/bnPszW2g3ZJ2EAc7Zg2n+4XW 0HQkC338IRwQ1/p87Qt+m6381DZod2LXLpx9+hmIOOHr/S09CzP/l+qvd5bz/UEhctAxQ k4yFo+EWHGAt/Voo+V8zghyD8RNWAxTQVfIseVqrf9aMdnqmUph6FnNrsPlsZ5avATdbA YOq+ikVqVnX+CGpeFRplW4xI9sEpClyorubqzMJVGbSH4aMWgWcXFuizV9j8oZwrr2g==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=163.com header.i=@163.com header.a=rsa-sha256 header.s=s110527 header.b=RDXeEFA6; dmarc=pass header.from=163.com; spf=pass smtp.mailfrom=163.com; arc=fail 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 DA620606A321; Thu, 26 Nov 2026 12:29:53 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.a=rsa-sha256 header.s=s110527 header.b=RDXeEFA6
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=117.135.210.5
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795696193; b=JrzxzwM71C7QgG/ufiOXu4E7lZwBYJuplKEYDpS5qOJcjSomPU5abu3DyK/G1RhvFmZ+ Eaqx06J8sYOEIQQBAGcS5gztg8AUxzuKFsoISNZHQub0sGnq/Jm1vEOxm9+XA+eGqnCom INulTwk+vC5WZ6zKc/S8Phd6GzRx5gx7VAWohhqivSuKO9RoPYwtsJ1CJ9kTeIMHr+GwI pmamb911kN1JN+KMgg9vRxxbySn2yzk3aPMhnp2YTA6dV7ZFN33V9zh2gHdf8zLiJpOp/ PJ3h4GyGyUklc0zz8kSXq3i7MTEM3XB4Q+Gjl2g/K4LzHr3Y9G9R24BqNsfuvwMAMBA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795696193; h=DMARC-Filter:DKIM-Signature:Received:From:To:Cc:Subject:Date: Message-Id:X-Mailer:MIME-Version:Content-Transfer-Encoding: X-CM-TRANSID:X-Coremail-Antispam:X-CM-SenderInfo; bh=RnxrMYpTCDIMktD1X0shShcdslhXt1F2LJgmog6mN8Y=; b=sfArUpGs4N8iLj2WZiMY5CfQj5y57pHvK3NY4HY3oit5vQmk+1yu41h8/x6WgXfdzGGG InivJZt/IH4+nHpta2Y5hmNmB/OZE9TwoGHrs9A13D1QY0BaK7TYQKAK5aWUlddq0yca8 18vcWGkUKBYZfZtmPp/n8hVQVxmHQkDoKtyHt7CmhC87gEcjpUszNm5jJ+FcIEmCGe/6A y4Biu2Xahogwn3QUZcHF7tRZ8zTiuaCSUM2JleYYN7ZolSnzJiWHH5mGyWeK5/AZw33H2 PTLnCUC2ZqwgR6nQWizA84E6fqfgW0ssLFuIa785S0qih5keiMZ24ktIrAgNh507p6A==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=163.com; spf=pass smtp.mailfrom=163.com; dkim=pass header.d=163.com header.i=@163.com header.a=rsa-sha256 header.s=s110527 header.b=RDXeEFA6; arc=none smtp.remote-ip=117.135.210.5
X-Received: from m16.mail.163.com (m16.mail.163.com [117.135.210.5]) (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 046ED606A31C; Thu, 26 Nov 2026 12:29:50 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 046ED606A31C
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=163.com
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=Rn xrMYpTCDIMktD1X0shShcdslhXt1F2LJgmog6mN8Y=; b=RDXeEFA6gnyxlJGb2W x7BorTdGJ0wqQUtbrlO6OxWbQfeS9abcOkfjTuueIQSBgndDd7cVkNRVG8+I/VuW x4RYEJ4pgy3rrRzBaSBz/3s5AIgQ3p3gYqyv6ba+OC0taUQVkzWxMO7N8vmg1Pvv lh8RaoiClpgILxwra40HA9tJ8=
X-Received: from shaos.localdomain (unknown []) by gzga-smtp-mtada-g0-3 (Coremail) with SMTP id _____wDnbxUOJghrUjpBKg--.8135S2; Thu, 26 Nov 2026 20:29:03 +0800 (CST)
X-Cc: "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>, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org
X-Mailer: git-send-email 2.34.1
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
X-CM-TRANSID: _____wDnbxUOJghrUjpBKg--.8135S2
X-Coremail-Antispam: 1Uf129KBjvJXoWxWry5WF1xGr43Aw4rWF4xCrg_yoWrtFy7pF 92vr4fKw1rAF4fJr1vyr1UX3Z3C3sIka4UGa4DZr1Skr43Kw1F9Fyxtw45GFWfuFyrWayS qF4qk34aqw1v9FJanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07UWa0dUUUUU=
X-CM-SenderInfo: pvkd40jtr6il2tof0z/xtbCzw9pd2sIJg8bAAAA3P