Article View: linux.kernel.netdev
Article #27468[PATCH net] net/sched: bound filter replay after action index collision
From: Dickson Wu via B4 Relay
Date: Sat, 05 Dec 2026 14:08
Date: Sat, 05 Dec 2026 14:08
66 lines
13328 bytes
13328 bytes
From: Dickson Wu <dickson.wu@certik.com>
A filter request can create one action with an automatically allocated
index and name that index again for a later action. The first action
holds an IDR reservation until the request commits, so
tcf_idr_check_alloc() returns -EAGAIN for the second action.
tc_new_tfilter() then rebuilds the same request without a limit.
An unprivileged user can trigger this from a user and network namespace.
In KVM, the tc process keeps consuming CPU after SIGKILL. Bound filter
replay so a request that cannot make progress returns -EAGAIN.
Allow 2 * TCA_ACT_MAX_PRIO attempts. Each action slot can need a replay
to load its module; another slot-sized allowance covers classifier,
ematch and textsearch module loads and transient races.
Fixes: 0190c1d452a9 ("net: sched: atomically check-allocate action")
Signed-off-by: Dickson Wu <dickson.wu@certik.com>
---
Tested on net e9d78fc6741a in x86_64 KVM, mapped uid 1000 in
unshare -Urn:
- The self-collision ran through SIGKILL on base until the 80-second
guest timeout; patched, tc returned rc 2 within three seconds and
the guest exited normally.
- The index-2 control returned tc rc 0 on both.
- A fresh-boot, one-request chain of 12 distinct action kinds loaded
12 modules and returned tc rc 0 on base and patched. A variant
capped at ten attempts failed it with rc 2 after ten modules, which
is why the budget is sized per action slot.
- The same 116 existing gact, matchall, flower, and basic tdc cases
passed on both (116 pass, 0 fail, 0 skip). Eight bulk flower cases
involving 100,000 to 1,000,000 filters were excluded from this
selection.
- W=1 cls_api.o built with no warnings on base and patched.
This was found and the fix prepared with AI coding tools (OpenAI Codex
agents, with review by Claude). I went over the analysis and the patch
before signing off.
net/sched/cls_api.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c
index bd0d635fe3fe..0187442bf0f5 100644
--- a/net/sched/cls_api.c
+++ b/net/sched/cls_api.c
@@ -2291,6 +2291,7 @@ static int tc_new_tfilter(struct sk_buff *skb, struct nlmsghdr *n,
int err;
enum tcf_tp_insert_state tp_state;
bool rtnl_held = false;
+ int retries = 2 * TCA_ACT_MAX_PRIO;
u32 flags;
replay:
@@ -2505,7 +2506,7 @@ static int tc_new_tfilter(struct sk_buff *skb, struct nlmsghdr *n,
if (rtnl_held)
rtnl_unlock();
- if (err == -EAGAIN) {
+ if (err == -EAGAIN && --retries > 0) {
/* Take rtnl lock in case EAGAIN is caused by concurrent flush
* of target chain.
*/
--
2.43.0
Technical Details
Message-ID:
<20261205-sched-tfilter3-v1-1-ec7237e72988@certik.com>Path:
mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-378092-linux-kernel-netdev=dewy.ruShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-378092-linux-kernel-netdev=dewy.ru From: devnull+dickson.wu.certik.com@kernel.org (Dickson Wu via B4 Relay) Newsgroups: linux.kernel.netdev Subject: [PATCH net] net/sched: bound filter replay after action index collision Date: Sat, 05 Dec 2026 14:08:59 +0000 Organization: Usenet Network Message-ID: <20261205-sched-tfilter3-v1-1-ec7237e72988@certik.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Injection-Info: usenet.network; logging-data="3088038"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:y+zYOJluHhNR3Mc0gB12+uAxi/s= sha256:TsHwcd7xWfeb3OlfdUxxxF1mq2Oq/ZD3kWkqpYVn7Fk= sha1:emdgMczMWaoKUbce5hg/MzoF/II= sha256:HM2YmBbkJ6/4Q5Qd+I0uSrnQcZ22B9yiYzWMyV7my/c= 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 5D589117E89; Sat, 5 Dec 2026 21:09:22 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -2.464 X-Spam-Status: No, score=-2.464 tagged_above=-9999 required=6.31 tests=[DATE_IN_PAST_03_06=1.076, DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.14, 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] 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 NfxtTrkxyEBX; Sat, 5 Dec 2026 21:09:18 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-378092-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 sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id 33E08117E65; Sat, 5 Dec 2026 21:09:08 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id A4A15291C1; Sat, 5 Dec 2026 18:09:05 +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=3; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796494145; b=ShBD86kZxDyTXCl25XFQ1WVFoXuQGheS9DQdzqqAHKndRZUe7gqkXraHs7NmdTecWDoT WrnlzfatpChnYJFSr5OkNyDNKswAXFRBQtyhRRuH1nQ0BRvr6BDx44tI6mktCOpiAsrKv 04utX3abvEsXOLVpjRPDtqaI+MIVIr7VNhb9Xct/+wM4ts4Pbg2jYH51pJRHQhrbc53qe bJr1j4oD/hg0/+N5zxFNkCtPLBK46t/CNZKX0z51C7Aw+ki1dA5GFkbRFFepeISM8HQse IU5FEBZK4sdFQ1aQfM6nBjVu+YlDb4NusmAR5THvsz1NisCdo/m2YpT8wfsu4vDEz9A== X-ARC-Message-Signature: i=3; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796494145; h=X-Original-To:Received:Received:DKIM-Signature:Received: X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe: List-Unsubscribe:List-Owner:Precedence:MIME-Version:Content-Type: Message-Id:X-B4-Tracking:X-Change-ID:From:Date:Subject:To:Cc:X-Mailer: X-Developer-Signature:X-Developer-Key:X-Endpoint-Received: X-Original-From:Reply-To:Content-Transfer-Encoding; bh=fhoyEhfDJ8qg1l31W3pHKwmpjIb8HuMjRmBzzo6FLJ4=; b=yD/ISE6xkECJWoSTAV5g54EPoZCYEXMwB4+6EZDTN82MRYHk7M5x1f7X2tu3DCkn6Y5f fePCB64Uz3IRekkdGKtuNRNapfjwHbkBRwc1dd9oEiNukz+O/2W1OVYsnSss7yv8nRzz0 E02LAxr7UQdDNF80cKC5wv00p6x0Wnl05mL0QySl9s1ppB9XjLLZOzVZFMGB/RlSqbGKw iOlvcilKHmPVVX6jfbijq/OitBrorh9ixkGDqxyOJhEgH4VATaDS4VsIcUX0AnV4TRfCE ZEnlwERa9FaAEBgOEV75TDLmAhRPlOpnC1dq7Hsk8TIZvGXU4S9hQnWuRaihsdkZbhw== X-ARC-Authentication-Results: i=3; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=CBzEZo+e; 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 76A60606A334; Sat, 5 Dec 2026 18:09:05 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=CBzEZo+e X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796494144; b=HCEMuz4Qm+a0kfvSesHtUL4F/DtL/HdM7zBRTtKHE0PsakIRKj6MTbvS+/mjI/MvEvRJ Gp2Yd93TOLT3cW35TOKpYzrUB4vQlh7zLvPLVdku2IU2nh6ZlTB7l3GbLGsT5wxh97B7C Bfs/ZiGpNjT2b0sDRZ6dkafkk/khNPGsT6w8O9xN6ijCl+zE7Gh4xgjIixjUSrZPQDfvW 7O6Fk0neHii4O8PU2dmEB/Q8FwbNRhaXoA6v33h/GPIOW/Ov2EFV3FPrT7tKrhzH9oeZc uUdhGApBpzpo09pSEWNoanzoVob29qeKiMZxOXUhYFWcXnpYswsYXzivuGe5T4P456w== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796494144; h=Received:DKIM-Signature:Received:MIME-Version:Content-Type: Message-Id:X-B4-Tracking:X-Change-ID:From:Date:Subject:To:Cc:X-Mailer: X-Developer-Signature:X-Developer-Key:X-Endpoint-Received: X-Original-From:Reply-To:Content-Transfer-Encoding; bh=fhoyEhfDJ8qg1l31W3pHKwmpjIb8HuMjRmBzzo6FLJ4=; b=F3aJbrtso469mI7BjBw+qwMzCa4rRf78SUF+SGfbDyamQYCyc3TyfmgaQGmeGoifrPoD F1+sRCeT7GJc4RLvHH4+yxFZCZZTNHsl2jntLm6xiWt/E+uiSDX/rGkYZnlcEYBKSJFjv uhdHCa+ZEKCDTO2nU7cvBz1/w6CObM29yoyCliCIzyQzoCHVeJH2PXDdcatdDgVHcHdXH wt0uau9LLnOIIG0bYdt+zd5BKyZJX4ub07atspDVZWMAe0NhrFIUt8rrskmZi+iaYfdr3 GKmciINYH5td9tiIIkbpForHAnBBPmT5SqOqydSqs7/IV5iSa8GcRV4UaBHoU3e6aYg== 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=CBzEZo+e; arc=pass header.oldest-pass=0 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 90FCB606A31F for <netdev@vger.kernel.org>; Sat, 5 Dec 2026 18:09:04 +0000 (UTC) X-Authentication-Results: smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 X-ARC-Seal: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; cv=none; t=1796494144; b=f3MBmsJG0OwpU0u2+dI9irXmSE0lEji/q2r2AEE421jbhPUQu0Q3BuFuCHIWU4JnbmKB EW5bcUmi8F1a5rh/a/oBz+YoKrJ36hkdL6rfhYFRV9bYVUjI2lya4rNCYVUXEVG22qnX5 wyJ2GlSW4imc7N4F0DVDdn5JjkmNEY9zMKcDTz71iFGyTwXmw9RoMAo/Cmf8xh2BAa1De H7f4/zs8CK74ON8yCOw30V0kNsWz83xpcYZ1Nc6iQ710OVp6eD3wRIfXP/fOjjpM6Cwwp MooTK6+2wJm9Jk9uxX+zD/9xSnOr6e0dn/kIvsysnw3ti+5xL/cafIplZatXb52vr9Q== X-ARC-Message-Signature: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; c=relaxed/relaxed; t=1796494144; h=DKIM-Signature:Received:MIME-Version:Content-Type:Message-Id: X-B4-Tracking:X-Change-ID:From:Date:Subject:To:Cc:X-Mailer: X-Developer-Signature:X-Developer-Key:X-Endpoint-Received: X-Original-From:Reply-To:Content-Transfer-Encoding; bh=fhoyEhfDJ8qg1l31W3pHKwmpjIb8HuMjRmBzzo6FLJ4=; b=qBlb6OgtsXc0s0FGqnlT/iiJxq8sqCEmxoYQoY6sGprjCKqCTtxC+U1Jxr0UhDwYQzNy wcic4daylXsFhYpubGdlv0m+q1i9yuKISiRRG6HXQptE+harrZDS3ZMVTEeTDitTLdpP5 FNxDG8RQSnXSOaKg2Y+T2/dsnm9X8ssEk9DuHNQ+pMlYjULqkiAZhe1BvHyBUYF/weoi+ 7S4rFRpH5jIrAXRp6jcSv5PfcF2KAgM9qV36lnwu5Z/XpLaC/naY2kj92DtSuenSeEIUk VK9CUNCc73GymnctU9JtZxKfYtRhteeNdjQomBWr6Xk3lUhNSeeczGn6eauzz8VU6Vw== X-ARC-Authentication-Results: i=1; smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 X-Received: from lkml.kernel.org (nexus.subspace.kernel.org [100.80.115.77]) (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.kernel.org (Postfix) with ESMTPS id BEF221F0092B; Sat, 5 Dec 2026 18:09:03 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796494144; bh=fhoyEhfDJ8qg1l31W3pHKwmpjIb8HuMjRmBzzo6FLJ4=; h=From:Date:Subject:To:Cc:Reply-To; b=CBzEZo+e6ITKB73Ot96l06X4JJDcUGMDqrc/GxpgIKshwUyNnbOkZ5dRfXM4ISZjg CYsMt+EXqdGb5a4KnAXWFayHjXJQMxfn57kvP3cPkX4pX62020Cx5hicU0RSwrI9/f UXBLPLEJFHK+EsxSUOvUs496Is/+DFBagVNWOWGSq94cBfyQBNpP+MzhKObiQ0vbPE e1i+rGymVx6Br70dxuYadF7IgkWXIAA2OwWlGTdQz1ujdai6aqPdLiSUENDt4P9xAw 5KEiHm7EJ1V+q+CihgA5nePkqUtDBnaYLG/Z/k5/qrNWsVnUEHyq80UEgOiTmGU+7z xhJUJcF97Cdew== X-Received: from nexus.subspace.kernel.org (localhost [IPv6:::1]) by lkml.kernel.org (Postfix) with ESMTP id 52EA75040A; Sat, 5 Dec 2026 18:09:03 +0000 (UTC) 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-B4-Tracking: v=1; b=H4sIADhSFGsC/yWMywrCMBBFf6XM2oE0Yo3+inSRx8SMlFQyUYTSf zfR5TncezYQKkwC12GDQm8WXnOD8TCATzbfCTk0Bq30NGp1QvGJAtbIS6VyRBPjZM5BKxMu0E7 PQpE/v+ANMlWY/1Je7kG+9lSfOSuErtjsU1dCOdR1XbB72PcvjXay45cAAAA= X-Change-ID: 20261205-sched-tfilter3-8ff687d208d9 X-Cc: jhs@mojatatu.com, jiri@resnulli.us, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, willemb@google.com, horms@kernel.org, marcelo.leitner@gmail.com, vladbu@mellanox.com X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1796493880; l=2639; i=dickson.wu@certik.com; s=dickson-b4; h=from:subject:message-id; bh=2TJ4OKMP3KMT5HP/ff0sfU1mQTxI5zXd9xEmjcE6TdU=; b=r0sDG1s1XwD82SMLy4bJggU+MUPfpQAStqQY52PMUS+x2a/JPacRjG7+9UgINJq96u4Fa6Pfk wV577zazl4sD6UbC5YQjrWg1xa8zBT6EXPfUlkzjPsOKSL69KuO1Dc/ X-Developer-Key: i=dickson.wu@certik.com; a=ed25519; pk=fxH7FS4FdojeJSGLJzgKdfO51Rvr4EW30yinj2mc1vg= X-Endpoint-Received: by B4 Relay for dickson.wu@certik.com/dickson-b4 with auth_id=1647 X-Original-From: Dickson Wu <dickson.wu@certik.com> X-Reply-To: dickson.wu@certik.com