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: <CAKwvOdk3mL87ZA_7ifGdmbztzxdFzJhFAwKoGfv6OiH0ECV0vg@mail.gmail.com>
Date:   Fri, 31 Aug 2018 14:50:05 -0700
From:   Nick Desaulniers <ndesaulniers@...gle.com>
To:     Miguel Ojeda <miguel.ojeda.sandonis@...il.com>, joe@...ches.com
Cc:     Arnd Bergmann <arnd@...db.de>, paul.burton@...s.com,
        christophe.leroy@....fr, Stafford Horne <shorne@...il.com>,
        Masahiro Yamada <yamada.masahiro@...ionext.com>,
        Kees Cook <keescook@...omium.org>,
        Ingo Molnar <mingo@...nel.org>,
        Greg KH <gregkh@...uxfoundation.org>,
        Thomas Gleixner <tglx@...utronix.de>, rdunlap@...radead.org,
        bp@...e.de, neilb@...e.com, LKML <linux-kernel@...r.kernel.org>,
        Andrey Ryabinin <aryabinin@...tuozzo.com>, dwmw@...zon.co.uk,
        sandipan@...ux.vnet.ibm.com,
        Rasmus Villemoes <linux@...musvillemoes.dk>,
        Paul Lawrence <paullawrence@...gle.com>,
        Andrey Konovalov <andreyknvl@...gle.com>,
        Will Deacon <will.deacon@....com>, ghackmann@...roid.com,
        stable@...r.kernel.org, Greg Hackmann <ghackmann@...gle.com>,
        Matthias Kaehlcke <mka@...omium.org>,
        Josh Poimboeuf <jpoimboe@...hat.com>,
        Wei Wang <wvw@...gle.com>, avagin@...nvz.org,
        Nathan Chancellor <natechancellor@...il.com>,
        Andrew Morton <akpm@...ux-foundation.org>
Subject: Re: [PATCH v2 1/2] compiler-clang.h: Add CLANG_VERSION and __diag macros

+ Miguel and Joe

This is the old patch I had sent for detecting Clang version.  If we
wanted to set a minimal version, this plus the actual version should
do it.  Probably could drop the diag stuff, as we changed clang to not
warn in this case, so my solution using _Pragma is obsolete.
On Mon, Jul 30, 2018 at 2:34 PM Nick Desaulniers
<ndesaulniers@...gle.com> wrote:
>
> These are needed for doing proper version checks, though feature
> detection via __has_attribute,  __has_builtin, and __has_feature should
> be preferred, see:
> https://clang.llvm.org/docs/LanguageExtensions.html#feature-checking-macros
>
> Also adds __diag support, for generating compiler version specific
> _Pragma()'s.
>
> __diag support based on commit 8793bb7f4a9d ("kbuild: add macro for
> controlling warnings to linux/compiler.h")
>
> Cc: stable@...r.kernel.org # 4.17, 4.14, 4.9, 4.4
> Suggested-by: Nathan Chancellor <natechancellor@...il.com>
> Signed-off-by: Nick Desaulniers <ndesaulniers@...gle.com>
> ---
>  include/linux/compiler-clang.h | 19 +++++++++++++++++++
>  include/linux/compiler_types.h |  4 ++++
>  2 files changed, 23 insertions(+)
>
> diff --git a/include/linux/compiler-clang.h b/include/linux/compiler-clang.h
> index 7087446c24c8..9442e07a361e 100644
> --- a/include/linux/compiler-clang.h
> +++ b/include/linux/compiler-clang.h
> @@ -7,6 +7,10 @@
>   * for Clang compiler
>   */
>
> +#define CLANG_VERSION (__clang_major__ * 10000 \
> +                      + __clang_minor__ * 100  \
> +                      + __clang_patchlevel__)
> +
>  #ifdef uninitialized_var
>  #undef uninitialized_var
>  #define uninitialized_var(x) x = *(&(x))
> @@ -46,3 +50,18 @@
>      __has_builtin(__builtin_sub_overflow)
>  #define COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW 1
>  #endif
> +
> +#define __diag_str1(s) #s
> +#define __diag_str(s) __diag_str1(s)
> +#define __diag(s) _Pragma(__diag_str(clang diagnostic s))
> +#define __diag_CLANG_ignore ignored
> +#define __diag_CLANG_warn warning
> +#define __diag_CLANG_error error
> +#define __diag_CLANG(version, severity, s) \
> +       __diag_CLANG_ ## version(__diag_CLANG_ ## severity s)
> +
> +#if CLANG_VERSION >= 70000
> +#define __diag_CLANG_7(s) __diag(s)
> +#else
> +#define __diag_CLANG_7(s)
> +#endif
> diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h
> index a8ba6b04152c..a04e6bd63476 100644
> --- a/include/linux/compiler_types.h
> +++ b/include/linux/compiler_types.h
> @@ -279,6 +279,10 @@ struct ftrace_likely_data {
>  #define __diag_GCC(version, severity, string)
>  #endif
>
> +#ifndef __diag_CLANG
> +#define __diag_CLANG(version, severity, string)
> +#endif
> +
>  #define __diag_push()  __diag(push)
>  #define __diag_pop()   __diag(pop)
>
> --
> 2.18.0.345.g5c9ce644c3-goog
>


-- 
Thanks,
~Nick Desaulniers

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ