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

From: Pablo Neira Ayuso <[email-masked]>
Date: Fri, 22 Nov 2024 14:51:33 +0100

On Fri, Nov 22, 2024 at 02:45:29PM +0100, Florian Westphal wrote:
> Pei Xiao <[email-masked]> wrote:
> > syzbot complain about using smp_processor_id in preemptible.
> > use get_cpu_ptr to preempt_disable.
> 
> > Reported-by: [email-masked]
> > Closes: https://syzkaller.appspot.com/bug?extid=84d0441b9860f0d63285
> > Fixes: 0e795b37ba04 ("netfilter: nft_inner: add percpu inner context")
> > Signed-off-by: Pei Xiao <[email-masked]>
> > ---
> >  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.