[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CABFUUZFgXooeCgKGypByzePBsHpcPWqnY-Ea0qv4Vd7=yMOk+A@mail.gmail.com>
Date: Wed, 4 Feb 2026 10:31:55 +0800
From: sun jian <sun.jian.kdev@...il.com>
To: Florian Westphal <fw@...len.de>
Cc: Pablo Neira Ayuso <pablo@...filter.org>, Phil Sutter <phil@....cc>, Simon Horman <horms@...nel.org>,
netfilter-devel@...r.kernel.org, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] netfilter: amanda: fix RCU pointer typing for nf_nat_amanda_hook
Hi Florian,
One quick clarification to my previous email regarding the change at line 101.
While line 101 itself doesn't trigger a Sparse warning, using
typeof(nf_nat_amanda_hook)
causes the local variable to inherit the __rcu attribute. This
"attribute inheritance"
is what leads to the "different address spaces" error during
assignment at line 158
when using rcu_dereference().
To keep the code concise while stripping the RCU attribute, I'll use
the typeof(*hook) * pattern
as discussed. I am currently preparing the v4 patch series which will
apply this refined fix to all
affected helpers (amanda, ftp, irc, snmp, and tftp) to clean up these
Sparse warnings across
the subsystem.
Sorry for the confusion in the earlier thread.
Regards,
Sun
On Wed, Feb 4, 2026 at 9:56 AM sun jian <sun.jian.kdev@...il.com> wrote:
>
> On Wed, Feb 4, 2026 at 12:59 AM Florian Westphal <fw@...len.de> wrote:
> >
> > sun jian <sun.jian.kdev@...il.com> wrote:
> > > > Sun Jian <sun.jian.kdev@...il.com> 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.
>
> I re-verified this with GCC 13.3.0 and Sparse v0.6.4-73-gfbdde312.
> Even without LLVM=1, Sparse still reports the "different address spaces"
> error for amanda on my machine:
>
> net/netfilter/nf_conntrack_amanda.c:158:33: error: incompatible types
> in comparison expression (different address spaces):
> net/netfilter/nf_conntrack_amanda.c:158:33: unsigned int ( [noderef]
> __rcu * )( ... ) net/netfilter/nf_conntrack_amanda.c:158:33: unsigned
> int ( * )( ... )
>
> It seems newer Sparse versions are more strict about RCU attributes on
> function pointers.
> To avoid manual declaration while stripping the __rcu attribute, I
> will switch to:
> typeof(*nf_nat_amanda_hook) *nf_nat_amanda;
>
> >
> > 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?
> Ack, I will prepare a V4 patch series to fix it for amanda, snmp,
> tftp, irc, and ftp together.
>
> Regards,
>
> Sun
Powered by blists - more mailing lists