From: Dickson Wu <dick…@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 <dick…@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