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: <20180901101430.GA21877@nautica>
Date:   Sat, 1 Sep 2018 12:14:30 +0200
From:   Dominique Martinet <asmadeus@...ewreck.org>
To:     Miguel Ojeda <miguel.ojeda.sandonis@...il.com>
Cc:     Linus Torvalds <torvalds@...ux-foundation.org>,
        linux-kernel@...r.kernel.org,
        Eli Friedman <efriedma@...eaurora.org>,
        Christopher Li <sparse@...isli.org>,
        Kees Cook <keescook@...omium.org>,
        Ingo Molnar <mingo@...nel.org>,
        Geert Uytterhoeven <geert@...ux-m68k.org>,
        Arnd Bergmann <arnd@...db.de>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Masahiro Yamada <yamada.masahiro@...ionext.com>,
        Joe Perches <joe@...ches.com>,
        Nick Desaulniers <ndesaulniers@...gle.com>
Subject: Re: [PATCH 7/7] Compiler Attributes: use feature checks instead of
 version checks

Miguel Ojeda wrote on Fri, Aug 31, 2018:
> Instead of using version checks per-compiler to define (or not)
> each attribute, use __has_attribute to test for them, following
> the cleanup started with commit 815f0ddb346c
> ("include/linux/compiler*.h: make compiler-*.h mutually exclusive").
> 
> All the attributes that are fairly common/standard (i.e. those that
> do not require extra logic to define them) have been moved
> to a new file include/linux/compiler_attributes.h.
> 
> In an effort to make the file as regular as possible, comments
> stating the purpose of attributes have been removed. Instead,
> links to the compiler docs have been added (i.e. to gcc and,
> if available, to clang as well). In addition, they have been sorted.
> 
> Finally, if an attribute is optional (i.e. if it is guarded
> by __has_attribute), the reason has been stated for future reference.
> 
> Cc: Eli Friedman <efriedma@...eaurora.org>
> Cc: Christopher Li <sparse@...isli.org>
> Cc: Kees Cook <keescook@...omium.org>
> Cc: Ingo Molnar <mingo@...nel.org>
> Cc: Geert Uytterhoeven <geert@...ux-m68k.org>
> Cc: Arnd Bergmann <arnd@...db.de>
> Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
> Cc: Masahiro Yamada <yamada.masahiro@...ionext.com>
> Cc: Joe Perches <joe@...ches.com>
> Cc: Dominique Martinet <asmadeus@...ewreck.org>
> Cc: Nick Desaulniers <ndesaulniers@...gle.com>
> Cc: Linus Torvalds <torvalds@...ux-foundation.org>
> Signed-off-by: Miguel Ojeda <miguel.ojeda.sandonis@...il.com>

Nice work!
Since I'm being Cc'd I took the time to test this as well, and have no
problem with libbcc-building-with-clang (or native x86 gcc build)

Nick already made many comments so I only have one more.

> [...]
> diff --git a/include/linux/compiler_attributes.h b/include/linux/compiler_attributes.h
> new file mode 100644
> index 000000000000..a9dfafc8fd19
> --- /dev/null
> +++ b/include/linux/compiler_attributes.h
> [...]
> +/*
> + * To check for optional attributes, we use __has_attribute, which is supported
> + * on gcc >= 5, clang >= 2.9 and icc >= 17. In the meantime, to support
> + * 4.6 <= gcc < 5, we implement __has_attribute by hand.
> + */
> +#ifndef __has_attribute
> +#define __has_attribute(x) __GCC4_has_attribute_##x
> +#define __GCC4_has_attribute_externally_visible 1
> +#define __GCC4_has_attribute_noclone 1
> +#define __GCC4_has_attribute_optimize 1
> +#if __GNUC_MINOR__ >= 8
> +#define __GCC4_has_attribute_no_sanitize_address 1
> +#endif
> +#if __GNUC_MINOR__ >= 9
> +#define __GCC4_has_attribute_assume_aligned 1
> +#endif
> +#endif

Hmm, if this is in this file and not compiler-gcc, I am not sure about
using GNUC_MINOR without checking the major -- I have no idea what kind
of versions e.g. icc will use (or what attributes ancients version of
clang or old icc support, actually)


It's a bit of research work but I think it'd be cleaner to define
similar macros for all three compilers, if we care about the old
versions... Or actually..

For clang you've implicitely required clang >= 3.0 in patch 3 of this
serie, so presumabely it wouldn't need this compat macro at all.

For icc I think icc 17 is still fairly recent... But I just abused work
to test and linux fails to compile with icc 15/17/18 for other reasons
(unrelated to this patch), so unless anyone helps with this I'm tempted
to suggest leaving it at it, and whoever that is will probably have a
better idea of how far back they want to make icc work / what attributes
are defined there.
It's a bit of a shame there's no linux-compilers list to reach out to :)

(this would need to move the include of this file after the
compiler-specific headers, but from what I can see there is no problem
with that)

-- 
Dominique

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ