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: <20180607204927.219329-2-ndesaulniers@google.com>
Date:   Thu,  7 Jun 2018 13:49:25 -0700
From:   Nick Desaulniers <ndesaulniers@...gle.com>
To:     akpm@...ux-foundation.org, hpa@...or.com, mingo@...hat.com,
        tglx@...utronix.de
Cc:     linux-efi@...r.kernel.org, linux-kernel@...r.kernel.org,
        x86@...nel.org, virtualization@...ts.linux-foundation.org,
        astrachan@...gle.com, manojgupta@...gle.com, ghackmann@...gle.com,
        sedat.dilek@...il.com, tstellar@...hat.com, keescook@...gle.com,
        yamada.masahiro@...ionext.com, michal.lkml@...kovi.net,
        linux-kbuild@...r.kernel.org, geert@...ux-m68k.org,
        will.deacon@....com, mawilcox@...rosoft.com, arnd@...db.de,
        rientjes@...gle.com, acme@...hat.com, pombredanne@...b.com,
        aryabinin@...tuozzo.com, kstewart@...uxfoundation.org,
        boris.ostrovsky@...cle.com, jan.kiszka@...mens.com,
        rostedt@...dmis.org, kirill.shutemov@...ux.intel.com,
        ard.biesheuvel@...aro.org, akataria@...are.com,
        brijesh.singh@....com, caoj.fnst@...fujitsu.com,
        gregkh@...uxfoundation.org, jarkko.sakkinen@...ux.intel.com,
        jgross@...e.com, jpoimboe@...hat.com, mka@...omium.org,
        ndesaulniers@...gle.com, thomas.lendacky@....com, tweek@...gle.com,
        mjg59@...gle.com, joe@...ches.com
Subject: [PATCH v4 1/3] compiler-gcc.h: add gnu_inline to all inline declarations

Functions marked extern inline do not emit an externally visible
function when the gnu89 C standard is used. Some KBUILD Makefiles
overwrite KBUILD_CFLAGS. This is an issue for GCC 5.1+ users as without
an explicit C standard specified, the default is gnu11. Since c99, the
semantics of extern inline have changed such that an externally visible
function is always emitted. This can lead to multiple definition errors
of extern inline functions at link time of compilation units whose build
files have removed an explicit C standard compiler flag for users of GCC
5.1+ or Clang.

Signed-off-by: Nick Desaulniers <ndesaulniers@...gle.com>
Suggested-by: H. Peter Anvin <hpa@...or.com>
Suggested-by: Joe Perches <joe@...ches.com>
---
 include/linux/compiler-gcc.h | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h
index b4bf73f5e38f..0c79c588e572 100644
--- a/include/linux/compiler-gcc.h
+++ b/include/linux/compiler-gcc.h
@@ -72,19 +72,22 @@
  * -Wunused-function.  This turns out to avoid the need for complex #ifdef
  * directives.  Suppress the warning in clang as well by using "unused"
  * function attribute, which is redundant but not harmful for gcc.
+ * Prefer gnu_inline, so that extern inline functions do not emit an
+ * externally visible function. This makes extern inline behave as per gnu89
+ * semantics rather than c99. This prevents multiple symbol definition errors
+ * of extern inline functions at link time.
+ * A lot of inline functions can cause havoc with function tracing.
  */
 #if !defined(CONFIG_ARCH_SUPPORTS_OPTIMIZED_INLINING) ||		\
     !defined(CONFIG_OPTIMIZE_INLINING) || (__GNUC__ < 4)
-#define inline inline		__attribute__((always_inline,unused)) notrace
-#define __inline__ __inline__	__attribute__((always_inline,unused)) notrace
-#define __inline __inline	__attribute__((always_inline,unused)) notrace
+#define inline \
+	inline __attribute__((always_inline, unused, gnu_inline)) notrace
 #else
-/* A lot of inline functions can cause havoc with function tracing */
-#define inline inline		__attribute__((unused)) notrace
-#define __inline__ __inline__	__attribute__((unused)) notrace
-#define __inline __inline	__attribute__((unused)) notrace
+#define inline inline		__attribute__((unused, gnu_inline)) notrace
 #endif
 
+#define __inline__ inline
+#define __inline inline
 #define __always_inline	inline __attribute__((always_inline))
 #define  noinline	__attribute__((noinline))
 
-- 
2.17.1.1185.g55be947832-goog

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ