[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <50912945-9da4-40c8-adad-34baa2b1e81b@mojatatu.com>
Date: Wed, 21 Jan 2026 16:47:27 -0300
From: Victor Nogueira <victor@...atatu.com>
To: Paul Moses <p@....org>, netdev@...r.kernel.org
Cc: Jamal Hadi Salim <jhs@...atatu.com>, Cong Wang
<xiyou.wangcong@...il.com>, Jiri Pirko <jiri@...nulli.us>,
"David S. Miller" <davem@...emloft.net>, Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
Simon Horman <horms@...nel.org>, linux-kernel@...r.kernel.org,
stable@...r.kernel.org
Subject: Re: [PATCH net v3 7/7] net/sched: act_gate: guard NULL params in
accessors
On 21/01/2026 10:21, Paul Moses wrote:
> Guard NULL params in accessors/dump/timer paths to avoid crashes during
> teardown or failed initialization. Other actions already guard params before
> RCU cleanup (act_pedit, commit 52cf89f78c01bf; act_vlan, commits 4c5b9d9642c859
> and 1edf8abe04090c), so act_gate should tolerate NULL in reader paths too.
> [...]
> diff --git a/include/net/tc_act/tc_gate.h b/include/net/tc_act/tc_gate.h
> index 9587d9e9fa38f..8c3309b0dd779 100644
> --- a/include/net/tc_act/tc_gate.h
> +++ b/include/net/tc_act/tc_gate.h
> @@ -54,12 +54,13 @@ struct tcf_gate {
>
> static inline s32 tcf_gate_prio(const struct tc_action *a)
> {
> - s32 tcfg_prio;
> + s32 tcfg_prio = 0;
> struct tcf_gate_params *p;
>
> rcu_read_lock();
> p = rcu_dereference(to_gate(a)->param);
> - tcfg_prio = p->tcfg_priority;
> + if (p)
> + tcfg_prio = p->tcfg_priority;
I don't believe you need to check for NULL in these helper functions. From
what I understood, the only place setting this to NULL is the cleanup
callback. You also won't be able to run this in parallel with the init
callback.
> [...]
> list_for_each_entry(entry, &p->entries, list)
> diff --git a/net/sched/act_gate.c b/net/sched/act_gate.c
> index e4134b9a4a314..65b53cbf37e67 100644
> --- a/net/sched/act_gate.c
> +++ b/net/sched/act_gate.c
> @@ -82,7 +82,11 @@ static enum hrtimer_restart gate_timer_func(struct hrtimer *timer)
>
> p = rcu_dereference_protected(gact->param,
> lockdep_is_held(&gact->tcf_lock));
> + if (!p)
> + goto out_unlock;
Also don't think you need to check this here.
Unless I'm missing something, cleanup will only set param to NULL after
the timer callback has finished executing.
> [...]
> @@ -643,6 +652,8 @@ static int tcf_gate_dump(struct sk_buff *skb, struct tc_action *a,
>
> rcu_read_lock();
> p = rcu_dereference(gact->param);
> + if (!p)
> + goto nla_put_failure_rcu;
I don't think you need the check here either.
Take a look at act_vlan.
cheers,
Victor
Powered by blists - more mailing lists