lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20260203080109.2682183-1-sun.jian.kdev@gmail.com>
Date: Tue,  3 Feb 2026 16:01:09 +0800
From: Sun Jian <sun.jian.kdev@...il.com>
To: Pablo Neira Ayuso <pablo@...filter.org>,
	Florian Westphal <fw@...len.de>
Cc: 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] netfilter: amanda: fix RCU pointer typing for nf_nat_amanda_hook

The nf_nat_amanda_hook pointer is accessed via rcu_dereference(), but
it lacks the __rcu annotation in its declaration and definition. Sparse
reports "incompatible types in comparison expression (different
address spaces)" errors in nf_conntrack_amanda.c.

Fix this by:
1. Adding __rcu and __read_mostly to the global nf_nat_amanda_hook
   declaration.
2. Adding __rcu to the global nf_nat_amanda_hook definition.
3. Explicitly declaring the local nf_nat_amanda function pointer
   without __rcu to store the dereferenced pointer.
4. Using rcu_dereference_raw() to fetch the hook address, which
   satisfies sparse's type checking for function pointers.

Signed-off-by: Sun Jian <sun.jian.kdev@...il.com>
---
 include/linux/netfilter/nf_conntrack_amanda.h |  3 ++-
 net/netfilter/nf_conntrack_amanda.c           | 11 ++++++++---
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/include/linux/netfilter/nf_conntrack_amanda.h b/include/linux/netfilter/nf_conntrack_amanda.h
index 6f0ac896fcc9..edf1d30135a3 100644
--- a/include/linux/netfilter/nf_conntrack_amanda.h
+++ b/include/linux/netfilter/nf_conntrack_amanda.h
@@ -12,5 +12,6 @@ extern unsigned int (*nf_nat_amanda_hook)(struct sk_buff *skb,
 					  unsigned int protoff,
 					  unsigned int matchoff,
 					  unsigned int matchlen,
-					  struct nf_conntrack_expect *exp);
+					  struct nf_conntrack_expect *exp)
+					  __rcu __read_mostly;
 #endif /* _NF_CONNTRACK_AMANDA_H */
diff --git a/net/netfilter/nf_conntrack_amanda.c b/net/netfilter/nf_conntrack_amanda.c
index 7be4c35e4795..7b3fffea45da 100644
--- a/net/netfilter/nf_conntrack_amanda.c
+++ b/net/netfilter/nf_conntrack_amanda.c
@@ -43,7 +43,7 @@ unsigned int (*nf_nat_amanda_hook)(struct sk_buff *skb,
 				   unsigned int matchoff,
 				   unsigned int matchlen,
 				   struct nf_conntrack_expect *exp)
-				   __read_mostly;
+				   __rcu __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)
@@ -155,7 +160,7 @@ static int amanda_help(struct sk_buff *skb,
 				  &tuple->src.u3, &tuple->dst.u3,
 				  IPPROTO_TCP, NULL, &port);
 
-		nf_nat_amanda = rcu_dereference(nf_nat_amanda_hook);
+		nf_nat_amanda = rcu_dereference_raw(nf_nat_amanda_hook);
 		if (nf_nat_amanda && ct->status & IPS_NAT_MASK)
 			ret = nf_nat_amanda(skb, ctinfo, protoff,
 					    off - dataoff, len, exp);
-- 
2.43.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ