Re: [PATCH v2] netfilter: amanda: fix RCU pointer typing for nf_nat_amanda_hook
From: Florian Westphal
Date: Tue Feb 03 2026 - 12:08:13 EST
sun jian <sun.jian.kdev@xxxxxxxxx> wrote:
> > Sun Jian <sun.jian.kdev@xxxxxxxxx> wrote:
> > > enum amanda_strings {
> > > @@ -98,7 +98,12 @@ static int amanda_help(struct sk_buff *skb,
> > > u_int16_t len;
> > > __be16 port;
> > > int ret = NF_ACCEPT;
> > > - typeof(nf_nat_amanda_hook) nf_nat_amanda;
> > > + unsigned int (*nf_nat_amanda)(struct sk_buff *skb,
> > > + enum ip_conntrack_info ctinfo,
> > > + unsigned int protoff,
> > > + unsigned int matchoff,
> > > + unsigned int matchlen,
> > > + struct nf_conntrack_expect *exp);
> >
> > Why is that needed?
> Correct. Manual declaration is indeed verbose.
>
> The reason I used it was that typeof(nf_nat_amanda_hook) carries over
> the __rcu attribute to the local variable, which triggers a Sparse
> warning when assigning the result of rcu_dereference().
sparse doesn't generate such a warning for me.
Also, this pattern you are changing here isn't specific to amanda, it
exists elsewhere as well:
net/netfilter/nf_conntrack_snmp.c:42:23: error: incompatible types in comparison expression (different address spaces):
net/netfilter/nf_conntrack_tftp.c:78:31: error: incompatible types in comparison expression (different address spaces):
net/netfilter/nf_conntrack_irc.c:242:38: error: incompatible types in comparison expression (different address spaces):
net/netfilter/nf_conntrack_ftp.c:521:22: error: incompatible types in comparison expression (different address spaces):
so why only fix this annotation for amanda?