summaryrefslogtreecommitdiff
path: root/tools/lib/python/kdoc
diff options
context:
space:
mode:
authorJamal Hadi Salim <jhs@mojatatu.com>2026-10-13 04:54:27 -0400
committerJakub Kicinski <kuba@kernel.org>2026-10-20 12:55:51 -0700
commited9e404dcf9b7bd0bf319bccbdf7ddf90f96dbbb (patch)
tree79c64470e086c137dade8a48029676b77d160655 /tools/lib/python/kdoc
parentdcaa6219648955f7a8160313f1685321dbd1bf28 (diff)
net/sched: act_gate: reject oversized dumps instead of wrapping them
This is a followup of commit cfa165cbfbed ("net/sched: act_gate: budget the per-entry list in get_fill_size") as reported by Sashiko. The issue: An action dump is carried inside nested netlink attributes whose lengths are u16. A gate action with enough schedule entries produces a dump larger than U16_MAX, and the plain nla_nest_end() closes by writing a wrapped length: the reply is structurally corrupt. On a CONFIG_DEBUG_NET kernel a plain nla_nest_end() also warns (DEBUG_NET_WARN_ON_ONCE warns once per call site), which an unprivileged RTM_GETACTION or RTM_GETTFILTER can reach once the action or filter exists. The oversized dump also reaches the filter notification path through tcf_fill_node(), which reports the failure as -EMSGSIZE. tfilter_notify_prep() treats that as socket-buffer exhaustion and retries with an ever larger alloc_skb(); a dump that does not fit a u16 nest cannot be built at any skb size, so the loop only spins until the allocation itself fails. The Fix: Close every wrap-capable nest an action dump travels in with nla_nest_end_safe(), which reports -EMSGSIZE before writing a wrapped length: TCA_GATE_ENTRY_LIST, TCA_ACT_OPTIONS, the per-action nest and TCA_ACT_TAB; the shared action and police containers in tcf_exts_dump()/tcf_exts_terse_dump(); and the caller-owned TCA_OPTIONS of every action-capable classifier (flower, matchall, basic, bpf, cgroup, flow, fw, route4, u32). The output is byte identical for every message that serializes. Bound the tfilter_notify_prep() retry once the skb is already larger than any valid message, while a regular dump that only needs a bigger skb still retries. The retry bound and the checked closes are one change: it is nla_nest_end_safe() that turns an unrepresentable dump into -EMSGSIZE, so a backport has to take both together if either is taken. Context note: A delete notification that cannot be built must not veto the state change the caller asked for. Two delete paths built the notification before the state change and propagated the build failure. tfilter_del_notify() builds the filter's delete notification before calling ->delete(), so a filter whose dump cannot be represented in a u16 nest could be created but never removed by "tc filter del ... handle H" - and only when a notification was actually needed (rtnl_notify_needed(): an RTNLGRP_TC listener or NLM_F_ECHO), which made it intermittent. tcf_del_notify() has the same shape for RTM_DELACTION: it builds the notification before tcf_action_delete(), so an action list whose TCA_ACT_TAB exceeds a u16 nest could not be deleted either. In both cases drop the unbuildable notification instead: on -EMSGSIZE the delete proceeds. This needs tca_get_fill() and tcf_del_notify_msg() to pass -EMSGSIZE up instead of collapsing it to -1/-EINVAL, and tca_get_fill() reports any inner tcf_action_dump() failure as -EMSGSIZE too (tcf_gate_dump() and tcf_action_dump_1() return plain -1 after one of their checked closes fails), so a single oversized action's delete is not vetoed either. On the delete paths the rule is scoped to notification BUILD failures: a delivery failure after the state change (rtnetlink_send() failing once ->delete() has already committed) still reports an error to the caller, as it did before this series. The extack that notes a dropped filter event is set only after ->delete() has returned 0. -EMSGSIZE here is the general tcf_fill_node() outcome for any ->dump() that does not fit, not only a u16 nest overflow; the effect of the new branch is limited to dropping a best-effort notification. why net-next? This is hardening rather than a regression fix: the enclosing action and filter-path nests have wrapped since the actions and classifiers allowed large entry lists - TCA_ACT_TAB is core act_api and the filter-side container predates the act_gate sizing change. A plain nla_nest_end() has always written the wrapped length at U16_MAX; this stops the corruption at the abstraction boundary instead of imposing a new policy limit on accepted gate schedules. A separate patch caps the entry list itself. Conditions to recreate the bug: CONFIG_NET_CLS_ACT=y; CONFIG_NET_ACT_GATE=y; CONFIG_NET_CLS_MATCHALL=y and/or CONFIG_NET_CLS_BASIC=y. Create a matchall or basic filter on an ingress/clsact qdisc whose action list holds two gate actions of 1024 minimal TCA_GATE_ONE_ENTRY elements each (TCA_ACT_MAX_PRIO admits up to 32 actions); the aggregate TCA_ACT_TAB nest is ~74.3 KiB > 65532 and wraps, then RTM_GETTFILTER it (or trigger the notify with NLM_F_ECHO). The same shape as two standalone gate actions is hit on the action path by RTM_DELACTION with NLM_F_ECHO; before this change the fill fails and the delete is refused, after it the actions are removed and only the notification is dropped. For a single action the outermost TCA_ACT_TAB wraps from 1815 entries (1821 for the innermost TCA_GATE_ENTRY_LIST); on the filter path the outermost wrap-capable nest is the classifier's TCA_OPTIONS. Installing needs CAP_NET_ADMIN in a user namespace; the RTM_GETTFILTER trigger needs no capability once it exists. The two-action shape survives the per-action cap added by "net/sched: act_gate: cap the number of scheduling entries": the enclosing nests overflow from aggregate action size, which no per-action cap can bound. Reported-by: Sashiko (nipa) <sashiko-bot@kernel.org> Closes: https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260824153903.4143642-1-victor@mojatatu.com Link: https://netdev-ai.bots.linux.dev/sashiko/#/patchset/QDISC-H19Z.v2.20261007062551%40mojatatu.com Link: https://lore.kernel.org/netdev/QDISC-H19Z.v2.20261007062551@mojatatu.com/ Link: https://lore.kernel.org/netdev/QDISC-H19Z.v1.20261001053234@mojatatu.com/ Link: https://lore.kernel.org/netdev/179111893181.434549.13449660670267048994@kernel.org/ Reviewed-by: Victor Nogueira <victor@mojatatu.com> Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com> Link: https://patch.msgid.link/QDISC-H19Z.v3.r0.20261012193813-1@mojatatu.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'tools/lib/python/kdoc')
0 files changed, 0 insertions, 0 deletions