[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260203145511.164485-1-sun.jian.kdev@gmail.com>
Date: Tue, 3 Feb 2026 22:55:11 +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,
Sun Jian <sun.jian.kdev@...il.com>
Subject: [PATCH v2] netfilter: amanda: fix RCU pointer typing for nf_nat_amanda_hook
Sparse reports "incompatible types in comparison expression" error in
nf_conntrack_amanda.c because nf_nat_amanda_hook is used with
rcu_dereference() but lacks the proper __rcu annotation.
Fix this by correctly placing the __rcu annotation inside the pointer
parentheses in both the declaration and definition. This allows the
standard rcu_dereference() to work correctly.
Suggested-by: Florian Westphal <fw@...len.de>
Signed-off-by: Sun Jian <sun.jian.kdev@...il.com>
---
v2:
- Correctly place __rcu annotation inside the parentheses as
suggested by Florian Westphal.
- Use standard rcu_dereference() instead of rcu_dereference_raw().
---
include/linux/netfilter/nf_conntrack_amanda.h | 12 +++++------
net/netfilter/nf_conntrack_amanda.c | 21 ++++++++++++-------
2 files changed, 19 insertions(+), 14 deletions(-)
diff --git a/include/linux/netfilter/nf_conntrack_amanda.h b/include/linux/netfilter/nf_conntrack_amanda.h
index 6f0ac896fcc9..9f957598a9da 100644
--- a/include/linux/netfilter/nf_conntrack_amanda.h
+++ b/include/linux/netfilter/nf_conntrack_amanda.h
@@ -7,10 +7,10 @@
#include <linux/skbuff.h>
#include <net/netfilter/nf_conntrack_expect.h>
-extern unsigned int (*nf_nat_amanda_hook)(struct sk_buff *skb,
- enum ip_conntrack_info ctinfo,
- unsigned int protoff,
- unsigned int matchoff,
- unsigned int matchlen,
- struct nf_conntrack_expect *exp);
+extern unsigned int (__rcu *nf_nat_amanda_hook)(struct sk_buff *skb,
+ enum ip_conntrack_info ctinfo,
+ unsigned int protoff,
+ unsigned int matchoff,
+ unsigned int matchlen,
+ struct nf_conntrack_expect *exp);
#endif /* _NF_CONNTRACK_AMANDA_H */
diff --git a/net/netfilter/nf_conntrack_amanda.c b/net/netfilter/nf_conntrack_amanda.c
index 7be4c35e4795..2e3753758b9b 100644
--- a/net/netfilter/nf_conntrack_amanda.c
+++ b/net/netfilter/nf_conntrack_amanda.c
@@ -37,13 +37,13 @@ MODULE_PARM_DESC(master_timeout, "timeout for the master connection");
module_param(ts_algo, charp, 0400);
MODULE_PARM_DESC(ts_algo, "textsearch algorithm to use (default kmp)");
-unsigned int (*nf_nat_amanda_hook)(struct sk_buff *skb,
- enum ip_conntrack_info ctinfo,
- unsigned int protoff,
- unsigned int matchoff,
- unsigned int matchlen,
- struct nf_conntrack_expect *exp)
- __read_mostly;
+unsigned int (__rcu *nf_nat_amanda_hook)(struct sk_buff *skb,
+ enum ip_conntrack_info ctinfo,
+ unsigned int protoff,
+ unsigned int matchoff,
+ unsigned int matchlen,
+ struct nf_conntrack_expect *exp)
+ __read_mostly;
EXPORT_SYMBOL_GPL(nf_nat_amanda_hook);
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);
/* Only look at packets from the Amanda server */
if (CTINFO2DIR(ctinfo) == IP_CT_DIR_ORIGINAL)
--
2.43.0
Powered by blists - more mailing lists