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]
Date: Fri, 29 Mar 2024 17:59:59 +0100
From: Alexander Lobakin <aleksander.lobakin@...el.com>
To: "David S. Miller" <davem@...emloft.net>,
	Eric Dumazet <edumazet@...gle.com>,
	Jakub Kicinski <kuba@...nel.org>,
	Paolo Abeni <pabeni@...hat.com>
Cc: Alexander Lobakin <aleksander.lobakin@...el.com>,
	Dmitry Safonov <0x7f454c46@...il.com>,
	Heiner Kallweit <hkallweit1@...il.com>,
	nex.sw.ncis.osdt.itp.upstreaming@...el.com,
	netdev@...r.kernel.org,
	linux-kernel@...r.kernel.org
Subject: [PATCH net-next 1/2] net/tcp: fix -Wshadow / Sparse shadow warnings in tcp_hash_fail()

Fix the following spam coming from <net/tcp_ao.h> when building with
W=12 and/or C=1:

Clang:

In file included from drivers/net/ethernet/intel/idpf/idpf_txrx.c:4:
In file included from drivers/net/ethernet/intel/idpf/idpf.h:24:
In file included from drivers/net/ethernet/intel/idpf/idpf_txrx.h:8:
/include/net/tcp.h:2812:3: warning: declaration shadows a local variable [-Wshadow]
 2812 |                 tcp_hash_fail("TCP segment has incorrect auth options set",
      |                 ^
/include/net/tcp_ao.h:153:23: note: expanded from macro 'tcp_hash_fail'
  153 |         const struct tcphdr *th = tcp_hdr(skb);                         \
      |                              ^
/include/net/tcp.h:2805:23: note: previous declaration is here
 2805 |         const struct tcphdr *th = tcp_hdr(skb);
      |                              ^
/include/net/tcp.h:2820:4: warning: declaration shadows a local variable [-Wshadow]
 2820 |                         tcp_hash_fail("TCP connection can't start/end using TCP-AO",
      |                         ^
/include/net/tcp_ao.h:153:23: note: expanded from macro 'tcp_hash_fail'
  153 |         const struct tcphdr *th = tcp_hdr(skb);                         \
      |                              ^
/include/net/tcp.h:2805:23: note: previous declaration is here
 2805 |         const struct tcphdr *th = tcp_hdr(skb);
      |                              ^
/include/net/tcp.h:2840:4: warning: declaration shadows a local variable [-Wshadow]
 2840 |                         tcp_hash_fail("AO hash is required, but not found",
      |                         ^
/include/net/tcp_ao.h:153:23: note: expanded from macro 'tcp_hash_fail'
  153 |         const struct tcphdr *th = tcp_hdr(skb);                         \
      |                              ^
/include/net/tcp.h:2805:23: note: previous declaration is here
 2805 |         const struct tcphdr *th = tcp_hdr(skb);
      |                              ^
/include/net/tcp.h:2846:4: warning: declaration shadows a local variable [-Wshadow]

Sparse:

drivers/net/ethernet/intel/idpf/idpf_main.c: note: in included file (through drivers/net/ethernet/intel/idpf/idpf_txrx.h, drivers/net/ethernet/intel/idpf/idpf.h):
/include/net/tcp.h:2812:17: warning: symbol 'th' shadows an earlier one
/include/net/tcp.h:2805:29: originally declared here
/include/net/tcp.h:2820:25: warning: symbol 'th' shadows an earlier one
/include/net/tcp.h:2805:29: originally declared here
/include/net/tcp.h:2840:25: warning: symbol 'th' shadows an earlier one
/include/net/tcp.h:2805:29: originally declared here
/include/net/tcp.h:2846:25: warning: symbol 'th' shadows an earlier one
/include/net/tcp.h:2805:29: originally declared here

Just use __UNIQUE_ID() for the variables declared inside
tcp_hash_fail().

Signed-off-by: Alexander Lobakin <aleksander.lobakin@...el.com>
---
 include/net/tcp_ao.h | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/include/net/tcp_ao.h b/include/net/tcp_ao.h
index 471e177362b4..c5303c9c6f80 100644
--- a/include/net/tcp_ao.h
+++ b/include/net/tcp_ao.h
@@ -148,7 +148,7 @@ static inline bool tcp_hash_should_produce_warnings(void)
 	return static_branch_tcp_md5() || static_branch_tcp_ao();
 }
 
-#define tcp_hash_fail(msg, family, skb, fmt, ...)			\
+#define _tcp_hash_fail(msg, family, skb, th, hdr_flags, f, fmt, ...)	\
 do {									\
 	const struct tcphdr *th = tcp_hdr(skb);				\
 	char hdr_flags[6];						\
@@ -179,6 +179,10 @@ do {									\
 				hdr_flags, ##__VA_ARGS__);		\
 	}								\
 } while (0)
+#define tcp_hash_fail(msg, family, skb, fmt, ...)			\
+	_tcp_hash_fail(msg, family, skb, __UNIQUE_ID(th_),		\
+		       __UNIQUE_ID(hdr_flags_), __UNIQUE_ID(f_), fmt,	\
+		       ##__VA_ARGS__)
 
 #ifdef CONFIG_TCP_AO
 /* TCP-AO structures and functions */
-- 
2.44.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ