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-next>] [day] [month] [year] [list]
Message-Id: <1e82c551938c32b4dbf8b65dc779c1b772898307.1727853749.git.geert+renesas@glider.be>
Date: Wed,  2 Oct 2024 09:24:50 +0200
From: Geert Uytterhoeven <geert+renesas@...der.be>
To: Tony Ambardar <tony.ambardar@...il.com>,
	Daniel Borkmann <daniel@...earbox.net>,
	Miguel Ojeda <ojeda@...nel.org>,
	Jiri Olsa <jolsa@...nel.org>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Arnd Bergmann <arnd@...db.de>
Cc: linux-kernel@...r.kernel.org,
	Geert Uytterhoeven <geert+renesas@...der.be>
Subject: [PATCH v2] compiler-gcc.h: Disable __retain on gcc-11

All my gcc-11 compilers (Ubuntu 11.4.0-1ubuntu1~22.04) claim to support
the __retain__ attribute, but only riscv64-linux-gnu-gcc-11 and
x86_64-linux-gnu-gcc-11 (not x86_64-linux-gnux32-gcc-11!) actually do.
The arm-linux-gnueabi-gcc-11.5.0 compiler from kernel.org crosstool
fails in the same way:

    error: ‘retain’ attribute ignored [-Werror=attributes]

All my gcc-12 compilers seem to support the attribute.

Play it safe, and disable __retain unconditionally on gcc-11.

Fixes: 0a5d3258d7c97295 ("compiler_types.h: Define __retain for __attribute__((__retain__))")
Signed-off-by: Geert Uytterhoeven <geert+renesas@...der.be>
Reviewed-by: Tony Ambardar <tony.ambardar@...il.com>
---
Tested with the following gcc-11 compilers:

  1. All compilers available on Ubuntu 22.04LTS:

	aarch64-linux-gnu-gcc-11
	alpha-linux-gnu-gcc-11
	arm-linux-gnueabi-gcc-11
	arm-linux-gnueabihf-gcc-11
	hppa64-linux-gnu-gcc-11
	hppa-linux-gnu-gcc-11
	i686-linux-gnu-gcc-11
	m68k-linux-gnu-gcc-11
	powerpc64le-linux-gnu-gcc-11
	powerpc64-linux-gnu-gcc-11
	powerpc-linux-gnu-gcc-11
	riscv64-linux-gnu-gcc-11
	s390x-linux-gnu-gcc-11
	sh4-linux-gnu-gcc-11
	sparc64-linux-gnu-gcc-11
	x86_64-linux-gnu-gcc-11
	x86_64-linux-gnux32-gcc-11

  2. A few from kernel.org crosstool:

	ia64-linux-gcc-11.1.0
	sh2eb-linux-muslfdpic-gcc-11.2.0
	arm-linux-gnueabi-gcc-11.5.0

  3. A compiler from the J-Core folks:

	sh2eb-linux-muslfdpic-gcc-11.2.0

v2:
  - Update comment in <linux/compiler_types.h>,
  - Add Reviewed-by.
---
 include/linux/compiler-gcc.h   | 9 +++++++++
 include/linux/compiler_types.h | 2 +-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h
index f805adaa316e9a21..bedeb76b63a34745 100644
--- a/include/linux/compiler-gcc.h
+++ b/include/linux/compiler-gcc.h
@@ -145,3 +145,12 @@
 #if GCC_VERSION < 90100
 #undef __alloc_size__
 #endif
+
+/*
+ * Most 11.x compilers claim to support it, but only riscv64-linux-gnu-gcc and
+ * x86_64-linux-gnu-gcc actually do.
+ */
+#if GCC_VERSION < 120000
+#undef __retain
+#define __retain
+#endif
diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h
index 1a957ea2f4fe78ed..76ddf04a7e66f890 100644
--- a/include/linux/compiler_types.h
+++ b/include/linux/compiler_types.h
@@ -153,7 +153,7 @@ static inline void __chk_io_ptr(const volatile void __iomem *ptr) { }
  * being optimized out, but operates at the compiler/IR-level and may still
  * allow unintended removal of objects during linking.
  *
- * Optional: only supported since gcc >= 11, clang >= 13
+ * Optional: only supported since gcc >= 11 (partial), clang >= 13
  *
  *   gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-retain-function-attribute
  * clang: https://clang.llvm.org/docs/AttributeReference.html#retain
-- 
2.34.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ