[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250708125411.GG452973@horms.kernel.org>
Date: Tue, 8 Jul 2025 13:54:11 +0100
From: Simon Horman <horms@...nel.org>
To: Eric Dumazet <edumazet@...gle.com>
Cc: "David S. Miller" <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
Jamal Hadi Salim <jhs@...atatu.com>,
Cong Wang <xiyou.wangcong@...il.com>, Jiri Pirko <jiri@...nulli.us>,
Kuniyuki Iwashima <kuniyu@...gle.com>, netdev@...r.kernel.org,
eric.dumazet@...il.com
Subject: Re: [PATCH net-next 08/11] net_sched: act_nat: use RCU in
tcf_nat_dump()
On Mon, Jul 07, 2025 at 01:01:07PM +0000, Eric Dumazet wrote:
> Also storing tcf_action into struct tcf_nat_params
> makes sure there is no discrepancy in tcf_nat_act().
>
> Signed-off-by: Eric Dumazet <edumazet@...gle.com>
...
> @@ -268,21 +268,20 @@ static int tcf_nat_dump(struct sk_buff *skb, struct tc_action *a,
> int bind, int ref)
> {
> unsigned char *b = skb_tail_pointer(skb);
> - struct tcf_nat *p = to_tcf_nat(a);
> + const struct tcf_nat *p = to_tcf_nat(a);
> + const struct tcf_nat_parms *parms;
> struct tc_nat opt = {
> .index = p->tcf_index,
> .refcnt = refcount_read(&p->tcf_refcnt) - ref,
> .bindcnt = atomic_read(&p->tcf_bindcnt) - bind,
> };
> - struct tcf_nat_parms *parms;
> struct tcf_t t;
>
> - spin_lock_bh(&p->tcf_lock);
> -
> - opt.action = p->tcf_action;
> + rcu_read_lock();
>
> - parms = rcu_dereference_protected(p->parms, lockdep_is_held(&p->tcf_lock));
> + parms = rcu_dereference(p->parms);
>
> + opt.action = parms->action;
> opt.old_addr = parms->old_addr;
> opt.new_addr = parms->new_addr;
> opt.mask = parms->mask;
> @@ -294,12 +293,12 @@ static int tcf_nat_dump(struct sk_buff *skb, struct tc_action *a,
> tcf_tm_dump(&t, &p->tcf_tm);
> if (nla_put_64bit(skb, TCA_NAT_TM, sizeof(t), &t, TCA_NAT_PAD))
> goto nla_put_failure;
> - spin_unlock_bh(&p->tcf_lock);
> + rcu_read_lock();
Hi Eric,
Should this be rcu_read_unlock()?
^^
Flagged by Smatch.
>
> return skb->len;
>
> nla_put_failure:
> - spin_unlock_bh(&p->tcf_lock);
> + rcu_read_unlock();
> nlmsg_trim(skb, b);
> return -1;
> }
> --
> 2.50.0.727.gbf7dc18ff4-goog
>
Powered by blists - more mailing lists