From nobody Sat Feb 7 18:15:54 2026 Received: from mail-yx1-f49.google.com (mail-yx1-f49.google.com [74.125.224.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5E40A369964 for ; Tue, 3 Feb 2026 08:01:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.224.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770105700; cv=none; b=lzE5DV8jau1BGpJmnCnrzlvfbwk17yjOmn+csW1y/0Duk2k1jyTzKqzz3QHAGOMA9cj+3CyTHzQ6+5fQFFcIorvKJR4fo3ltHpyFpuLjcPkAClJvVRyN9EZgS7ry59vWFhTVQ/FNuI07xREjubZrmhrX3nWVg6/Jj9/hm9bRK8A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770105700; c=relaxed/simple; bh=q3X6LXGY4pvrxPIY1+ZdGtvX1s6x9ZtFOSXn48a+I78=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=iswS5PeWVrRkazpoqWZzFzmNlS7Gce++FT0lqwSFBPgV4xbxOfjx/bh8TJJOrQE6OBt7NEqeQZaWVU0xwZRoFFEn3cZ5M3E095JfT/4KqgWWTiFoo/gcjQYp2eMMmTHvReqofpclu6qHVKguINZePl5ypYn6WlEHcjXA2NOsKVw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=L63pAZLn; arc=none smtp.client-ip=74.125.224.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="L63pAZLn" Received: by mail-yx1-f49.google.com with SMTP id 956f58d0204a3-64938fce805so4753839d50.1 for ; Tue, 03 Feb 2026 00:01:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1770105696; x=1770710496; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=qnK1EPBJzbPse5QDMYYT7zPjH8hy43jPBzPzSg4c+hU=; b=L63pAZLnProgbZeVf8Xr500kKtlCp+q8LRJHWZyhyoDMmVyZDOrTVFo6/fiAcCg//k Qlmq+avt/MG5/Ek1+lHhaxmXkCUdYv09FjJsQC8gf/7lac5SEIqgQPN3Na/RICVchTSm rr+MI+gC6gWxB8D4qQXhJDD1giF1fh56y4l7qf/AqnKEWi0sB4PUwQRk4uh2TnyILrhD GPbHSKPtgceM5H6TOk4etDlA2yaxX/4AAXihR00IoXsoy4mfhcMOS4aF7EE0sR7XF1wO 62XHPp4ufppMe4x4tsZpIW5h0EKGArjF5BvhpbIW5vIGZ1QlidrdjKCQf6qN4MCZANBC vFXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770105696; x=1770710496; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=qnK1EPBJzbPse5QDMYYT7zPjH8hy43jPBzPzSg4c+hU=; b=qkjfwDQAx9oh7IYF3P6MJBpWxeb0NJceoomhq/7arHi7paclna1m8jSPFa6t3C/WEa 5c9Rd9EalFbT+OtK9wgIKglJr57MQMH/uqeKL79z2vu/No0EH7xDPZ2+s/lmXLKoXiIo Z9Ml372AKjesCBjKEeqp3OKdqEny0xshIbVWYaLU2+rgaGnekrj/vTzcGY9b4sqGsVP6 22OU5VvBLPGaC2PejV1VYuYrnXC/kiZEoMSX+YupAg+qlj2rhPTYvZgCLwYSMCS6zKkV WTHOfozNCufH9ZN4BjzIunbURtPjnlh4CuWq5LEMYHRvzQ4vvho1ZkYmntrZnFrQOLVr qZNQ== X-Forwarded-Encrypted: i=1; AJvYcCXqNyymzBnlheuvy/ivq/OjeXZsRXdE7bUcCoimteBwLpuS22H+MvQziIeHft9z8w8Wl4ppkEHATtHJfko=@vger.kernel.org X-Gm-Message-State: AOJu0Yw4f7CZ26f6JHXugVHTnLTbrEDUsogOYVnglMPooQwyYqUEwFKC ArjKGyd6Jz7twgECfVZwDiDZHDt5FhT9/yEHDjy0gsyOqWICzWirAOQOqaCbW3upn3U= X-Gm-Gg: AZuq6aIjl5epPo2NxyhfCO8OFBTjtzsU3jKFBzAxD1Q7olKdeQJ5qJMKxSsPgyaMSzL 9jL7hX0Z1hVWYLR+yJs2YD76QPGOfFQH+vkqClnr1/y/cWr95H7RXWY99w3SMk60zdTa+SFypd9 9CqCI0gFsfhdIPJniEm5gpOZblqZAm2lnXABQE0wUdLPpyrf4kH/Xsc7VAqohQgaZ/CnR7po5t9 qjnMGcSlTu3JRekkPr19BCHK3fm5k4YpeCgGd7jwxb5Tvs6oqQRuPJtLFG+t3vNAeUn081LE/ji +V0RnbSWuMkv3SEQcmDACwc8jH21eWfeDInTMIoTtHipN3J+XMz9pvgMyF42cHn7vRmau7pma2r yl87DPqNal40JKbWHoeeTssVlwWey9OSYEwfc0PCniIpiimq531L2tBKtwzWoSp6JA3wR0ooKlg /68RrOjxOlC7PTfkcR5wS4EHdGfTOkKbuUjha8WNjpoRCdMe/Jvetv10OgnB0hcaaxYxJJuWYiF Uw4H88wOCsmG0IkO0WhHEi57277tERyRteV X-Received: by 2002:a05:690e:1484:b0:649:6581:a683 with SMTP id 956f58d0204a3-649a83c1a29mr11604677d50.12.1770105696377; Tue, 03 Feb 2026 00:01:36 -0800 (PST) Received: from u2404-VMware-Virtual-Platform.localdomain (108-214-96-168.lightspeed.sntcca.sbcglobal.net. [108.214.96.168]) by smtp.gmail.com with ESMTPSA id 956f58d0204a3-649d51511cdsm803782d50.6.2026.02.03.00.01.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Feb 2026 00:01:36 -0800 (PST) From: Sun Jian To: Pablo Neira Ayuso , Florian Westphal Cc: Phil Sutter , Simon Horman , netfilter-devel@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Sun Jian Subject: [PATCH] netfilter: amanda: fix RCU pointer typing for nf_nat_amanda_hook Date: Tue, 3 Feb 2026 16:01:09 +0800 Message-ID: <20260203080109.2682183-1-sun.jian.kdev@gmail.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 --- 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_conntra= ck_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); =20 enum amanda_strings { @@ -98,7 +98,12 @@ static int amanda_help(struct sk_buff *skb, u_int16_t len; __be16 port; int ret =3D 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); =20 /* Only look at packets from the Amanda server */ if (CTINFO2DIR(ctinfo) =3D=3D 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); =20 - nf_nat_amanda =3D rcu_dereference(nf_nat_amanda_hook); + nf_nat_amanda =3D rcu_dereference_raw(nf_nat_amanda_hook); if (nf_nat_amanda && ct->status & IPS_NAT_MASK) ret =3D nf_nat_amanda(skb, ctinfo, protoff, off - dataoff, len, exp); --=20 2.43.0