From: netdev-bot+sashiko@kernel.org
To: jhs@mojatatu.com
Cc: netdev@vger.kernel.org, jiri@resnulli.us, davem@davemloft.net,
edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com,
willemb@google.com, horms@kernel.org,
alexei.starovoitov@gmail.com, victor@mojatatu.com,
Po.Liu@nxp.com, stable@vger.kernel.org,
syzbot+0054fed3dc9085390f51@syzkaller.appspotmail.com,
shawnq1@163.com
Subject: Re: [PATCH net v4 2/3] net/sched: act_gate: refuse schedule entries shorter than 10 us
Date: Wed, 25 Nov 2026 14:15:12 +0000 [thread overview]
Message-ID: <179561611250.3135.13753422220190315891@kernel.org> (raw)
In-Reply-To: <ACT-WEXM.v4.r0.20261124074514-2@mojatatu.com>
Thank you for your contribution! Sashiko AI review found 5 potential
issue(s) to consider.
Critical: 0 · High: 1 · Medium: 2 · Low: 2
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [High] The 10 us floor only limits a single gate action.
- [Medium] The commit message says the bug needs 'CAP_NET_ADMIN in the
initial user namespace (netlink_capable() checks init_user_ns, so a…
- [Medium] The commit message says 'An act_gate schedule is not tied to a
device, so unlike taprio there is no frame time to derive a bound…
- [Low] entry_policy still declares TCA_GATE_ENTRY_INTERVAL as a plain `{
.type = NLA_U32 }`, while fill_gate_entry() enforces the new 10000 ns…
- [Low] The 'Some context' paragraph says 'The request that reproduces
the cycle-time stall also carries a 1 ns entry interval'.
--
net/sched: act_gate: refuse schedule entries shorter than 10 us
This commit changes fill_gate_entry() so that act_gate schedule entries
must be at least 10 us long (GATE_MIN_INTERVAL_NSEC). Before, only a zero
interval was refused. The goal is to stop the soft hrtimer that
gate_timer_func() re-arms from keeping a CPU busy in the timer softirq.
Closes: https://sashiko.dev/#/patchset/tencent_4ED9536B0375C96183B2244CF7709768C605@qq.com
> Some context:
> The request that reproduces the cycle-time stall also carries a 1 ns
> entry interval. With the cycle time derived from the entries, that alone
> sets a 1 ns timer period: the report covers both defects.
[Severity: Low]
Which request does this paragraph mean?
The earlier commit in this series, "net/sched: act_gate: bound the cycle
time and start time arithmetic", documents a cycle-time reproducer that
uses TCA_GATE_BASE_TIME = 1, TCA_GATE_CYCLE_TIME = 0xffffffffffffffff and
"one schedule entry of 1000000 ns". That is 1 ms, not 1 ns.
The second sentence is accurate. gate_timer_func() advances
current_close_time by next->interval, so a single 1 ns entry does set a
1 ns period.
If this refers to a different reproducer, such as the Sashiko one, could
the message name it? As written, the two commits disagree about which
input triggers which defect.
> Conditions to recreate the bug:
> CONFIG_NET_ACT_GATE=y, and CAP_NET_ADMIN in the initial user namespace
> (netlink_capable() checks init_user_ns, so a user namespace of its own
> does not help), in a new network namespace:
[Severity: Medium]
Is this accurate for every way a gate action can be created?
The init_user_ns check is only in the standalone RTM_NEWACTION path:
net/sched/act_api.c:tc_ctl_action() {
...
if ((n->nlmsg_type != RTM_GETACTION) &&
!netlink_capable(skb, CAP_NET_ADMIN))
return -EPERM;
...
}
A gate action can also be created inline with a classifier, for example:
tc filter add dev lo ingress matchall action gate sched-entry close 1
That goes through:
RTM_NEWTFILTER
tc_new_tfilter()
tcf_exts_validate_ex()
tcf_action_init()
tcf_gate_init()
The only capability check on that path is relative to the netns:
net/core/rtnetlink.c:rtnetlink_rcv_msg() {
...
if (kind != RTNL_KIND_GET && !netlink_net_capable(skb, CAP_NET_ADMIN))
return -EPERM;
...
}
So it looks like an unprivileged user who runs unshare -Urn can set up
the 1 ns stall on kernels without this patch.
With Cc: stable on this patch, could the reachability description be
corrected? Backport and security triage will rely on it.
> diff --git a/net/sched/act_gate.c b/net/sched/act_gate.c
> index 4835f65439011..797562dbde693 100644
> --- a/net/sched/act_gate.c
> +++ b/net/sched/act_gate.c
> @@ -25,6 +25,11 @@ static struct tc_action_ops act_gate_ops;
> */
> #define GATE_ENTRIES_MAX 1024U
>
> +/* An entry shorter than this lets the next expiry land before the softirq
> + * servicing the current one can finish, so the timer stays permanently behind.
> + */
> +#define GATE_MIN_INTERVAL_NSEC 10000U
[Severity: High]
Does a per-entry floor bound the total timer softirq load on a CPU?
Each gate action owns a soft hrtimer (HRTIMER_MODE_ABS_SOFT). That timer
re-arms itself on every expiry with no exit condition:
net/sched/act_gate.c:gate_timer_func() {
...
gact->current_close_time = ktime_add_safe(gact->current_close_time,
next->interval);
...
hrtimer_set_expires(&gact->hitimer, close_time);
spin_unlock(&gact->tcf_lock);
return HRTIMER_RESTART;
}
Nothing limits how many gate actions a netns can have. tcf_gate_init()
calls tcf_idr_check_alloc() with a u32 index, and every filter with an
inline action gate creates a new instance and starts a new timer.
The commit message puts one expiry at a few hundred ns. At that cost,
about 33 actions with a single 10000 ns entry each, created from a task
pinned to one CPU, would keep that CPU fully busy in the timer softirq.
On the debug or PREEMPT_RT kernels the message mentions, where an expiry
costs a few us, 3 to 5 actions would be enough.
Wouldn't that bring back the "holds a CPU in the timer softirq for as
long as it exists" condition this patch is meant to remove? Fully fixing
it seems to need a limit on the combined load, for example a per-netns
cap on active gate timers or on their total expiry rate.
[ ... ]
> @@ -199,8 +204,10 @@ static int fill_gate_entry(struct nlattr **tb, struct tcfg_gate_entry *entry,
> if (tb[TCA_GATE_ENTRY_INTERVAL])
> interval = nla_get_u32(tb[TCA_GATE_ENTRY_INTERVAL]);
>
> - if (interval == 0) {
> - NL_SET_ERR_MSG(extack, "Invalid interval for schedule entry");
> + if (interval < GATE_MIN_INTERVAL_NSEC) {
> + NL_SET_ERR_MSG_FMT(extack,
> + "Entry interval must be at least %u ns",
> + GATE_MIN_INTERVAL_NSEC);
> return -EINVAL;
> }
[Severity: Medium]
The commit message says:
An act_gate schedule is not tied to a device, so unlike taprio there is
no frame time to derive a bound from
Does that hold for offloaded gate actions? act_gate is offloaded as
FLOW_ACTION_GATE to 802.1Qci PSFP hardware in sja1105, felix_vsc9959,
ocelot_flower, enetc and sparx5.
fill_gate_entry() runs for every gate action before the offload path
does, including flower skip_sw rules. sja1105 accepts much finer
schedules than 10 us:
drivers/net/dsa/sja1105/sja1105_vl.c:sja1105_vl_gate() {
...
div_s64_rem(entries[i].interval,
sja1105_delta_to_ns(1), &rem);
if (rem) {
NL_SET_ERR_MSG_MOD(extack,
"Interval must be multiple of 200 ns");
rc = -ERANGE;
goto out;
}
if (!entries[i].interval) {
NL_SET_ERR_MSG_MOD(extack,
"Interval cannot be zero");
...
}
Schedules such as "sched-entry OPEN 5000 -1 -1 sched-entry CLOSE 5000
-1 -1" used to install on sja1105. They now fail with -EINVAL and "Entry
interval must be at least 10000 ns". The driver's zero-interval check also
becomes unreachable.
The software hrtimer still runs for offloaded actions, so the CPU cost
argument may still justify the floor. Could the commit message say that
this rejects schedules that offload hardware used to accept? With
Cc: stable, the new limit would also reach deployed TSN setups.
[Severity: Low]
This isn't a bug, but could the minimum go in the policy instead of being
open-coded? entry_policy still declares the interval as a plain u32:
[TCA_GATE_ENTRY_INTERVAL] = { .type = NLA_U32 },
With NLA_POLICY_MIN(NLA_U32, GATE_MIN_INTERVAL_NSEC), nla_parse_nested()
would report the bad attribute in extack, and the policy would advertise
the correct range.
Also, when TCA_GATE_ENTRY_INTERVAL is missing, interval stays 0 and the
user is told the interval must be at least 10000 ns, even though no
interval was sent. Would NL_SET_ERR_ATTR_MISS describe that case better?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/ACT-WEXM.v4.r0.20261124074514%40mojatatu.com
next prev parent reply other threads:[~2026-11-25 14:15 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 14:12 [PATCH net v4 0/3] net/sched: act_gate: bound the cycle time and refuse schedule entries shorter than 10 us Jamal Hadi Salim
2026-11-24 14:12 ` [PATCH net v4 1/3] net/sched: act_gate: bound the cycle time and start time arithmetic Jamal Hadi Salim
2026-11-24 19:56 ` Alexei Starovoitov
2026-11-24 23:31 ` Jamal Hadi Salim
2026-11-24 23:38 ` Alexei Starovoitov
2026-11-25 14:15 ` netdev-bot+sashiko
2026-11-24 14:12 ` [PATCH net v4 2/3] net/sched: act_gate: refuse schedule entries shorter than 10 us Jamal Hadi Salim
2026-11-24 16:12 ` Sebastian Andrzej Siewior
2026-11-24 16:58 ` Jamal Hadi Salim
2026-11-24 17:11 ` Jamal Hadi Salim
2026-11-25 14:15 ` netdev-bot+sashiko [this message]
2026-11-24 14:12 ` [PATCH net v4 3/3] selftests: tc-testing: act_gate: cover the new cycle time and interval limits Jamal Hadi Salim
2026-11-25 14:15 ` netdev-bot+sashiko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=179561611250.3135.13753422220190315891@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=Po.Liu@nxp.com \
--cc=alexei.starovoitov@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=jhs@mojatatu.com \
--cc=jiri@resnulli.us \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=shawnq1@163.com \
--cc=stable@vger.kernel.org \
--cc=syzbot+0054fed3dc9085390f51@syzkaller.appspotmail.com \
--cc=victor@mojatatu.com \
--cc=willemb@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox