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>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240910-ti-warn-v1-1-afd1e404abbe@kernel.org>
Date: Tue, 10 Sep 2024 08:17:56 +0100
From: Simon Horman <horms@...nel.org>
To: "David S. Miller" <davem@...emloft.net>, 
 Eric Dumazet <edumazet@...gle.com>, Jakub Kicinski <kuba@...nel.org>, 
 Paolo Abeni <pabeni@...hat.com>, Siddharth Vadapalli <s-vadapalli@...com>, 
 Roger Quadros <rogerq@...nel.org>, Nathan Chancellor <nathan@...nel.org>, 
 Nick Desaulniers <ndesaulniers@...gle.com>, 
 Bill Wendling <morbo@...gle.com>, Justin Stitt <justinstitt@...gle.com>
Cc: netdev@...r.kernel.org, linux-omap@...r.kernel.org, 
 llvm@...ts.linux.dev
Subject: [PATCH net-next 1/3] net: ethernet: ti: am65-cpsw: Address
 __percpu Sparse warnings

Sparse flags a mismatch between percpu stats data, and
it's use with actions which handle non-percpu data.

.../am65-cpsw-nuss.c:2658:55: warning: incorrect type in initializer (different address spaces)
.../am65-cpsw-nuss.c:2658:55:    expected struct am65_cpsw_ndev_stats [noderef] __percpu *stats
.../am65-cpsw-nuss.c:2658:55:    got void *data
.../am65-cpsw-nuss.c:2781:15: warning: incorrect type in argument 3 (different address spaces)
.../am65-cpsw-nuss.c:2781:15:    expected void *data
.../am65-cpsw-nuss.c:2781:15:    got struct am65_cpsw_ndev_stats [noderef] __percpu *stats

Address this using casts.

An alternate, approach would be to create a variant of
devm_add_action_or_reset() which expects __percpu data.  This would
avoid discarding the __percpu annotation, and any value it may have
between the casts added by this patch.  However, doing so appears to
require a significant amount of plumbing.  And, as far as I can see, the
code updated by this patch would be the only user of it.  So this patch
takes a simpler approach.

No functional change intended.
Compile tested only.

Signed-off-by: Simon Horman <horms@...nel.org>
---
 drivers/net/ethernet/ti/am65-cpsw-nuss.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
index b7e5d0fb5d19..a4b0e4bb7529 100644
--- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c
+++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
@@ -2671,9 +2671,7 @@ static int am65_cpsw_nuss_init_slave_ports(struct am65_cpsw_common *common)
 
 static void am65_cpsw_pcpu_stats_free(void *data)
 {
-	struct am65_cpsw_ndev_stats __percpu *stats = data;
-
-	free_percpu(stats);
+	free_percpu((void __percpu *)data);
 }
 
 static void am65_cpsw_nuss_phylink_cleanup(struct am65_cpsw_common *common)
@@ -2794,7 +2792,7 @@ am65_cpsw_nuss_init_port_ndev(struct am65_cpsw_common *common, u32 port_idx)
 		return -ENOMEM;
 
 	ret = devm_add_action_or_reset(dev, am65_cpsw_pcpu_stats_free,
-				       ndev_priv->stats);
+				       (__force void *)ndev_priv->stats);
 	if (ret)
 		dev_err(dev, "failed to add percpu stat free action %d\n", ret);
 

-- 
2.45.2


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ