Re: [PATCH] netfilter: nf_tables: Use get_cpu_ptr in nft_inner_eval

From: Pablo Neira Ayuso
Date: Fri Nov 22 2024 - 08:52:11 EST


On Fri, Nov 22, 2024 at 02:45:29PM +0100, Florian Westphal wrote:
> Pei Xiao <xiaopei01@xxxxxxxxxx> wrote:
> > syzbot complain about using smp_processor_id in preemptible.
> > use get_cpu_ptr to preempt_disable.
>
> > Reported-by: syzbot+84d0441b9860f0d63285@xxxxxxxxxxxxxxxxxxxxxxxxx
> > Closes: https://syzkaller.appspot.com/bug?extid=84d0441b9860f0d63285
> > Fixes: 0e795b37ba04 ("netfilter: nft_inner: add percpu inner context")
> > Signed-off-by: Pei Xiao <xiaopei01@xxxxxxxxxx>
> > ---
> > net/netfilter/nft_inner.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/net/netfilter/nft_inner.c b/net/netfilter/nft_inner.c
> > index 928312d01eb1..ae85851bab77 100644
> > --- a/net/netfilter/nft_inner.c
> > +++ b/net/netfilter/nft_inner.c
> > @@ -248,7 +248,7 @@ static bool nft_inner_parse_needed(const struct nft_inner *priv,
> > static void nft_inner_eval(const struct nft_expr *expr, struct nft_regs *regs,
> > const struct nft_pktinfo *pkt)
> > {
> > - struct nft_inner_tun_ctx *tun_ctx = this_cpu_ptr(&nft_pcpu_tun_ctx);
> > + struct nft_inner_tun_ctx *tun_ctx = get_cpu_ptr(&nft_pcpu_tun_ctx);
> > const struct nft_inner *priv = nft_expr_priv(expr);
>
> This can't be right, where is it re-enabled?
>
> Not related to your patch:
> Why is this percpu? How is this softirq safe?

I can add an owner skbuff to nft_inner_tun_ctx area, so this
information can be canceled in case of softirq interference, then
trigger a reparsing of the header.