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: <6ca2bf5a-f0c3-b972-2313-f09c39b67e3b@kernel.org>
Date:   Mon, 21 Jun 2021 16:41:37 -0700
From:   Nathan Chancellor <nathan@...nel.org>
To:     Nick Desaulniers <ndesaulniers@...gle.com>,
        Kees Cook <keescook@...omium.org>
Cc:     Peter Zijlstra <peterz@...radead.org>,
        Bill Wendling <wcw@...gle.com>,
        Sami Tolvanen <samitolvanen@...gle.com>,
        Peter Oberparleiter <oberpar@...ux.ibm.com>,
        Masahiro Yamada <masahiroy@...nel.org>,
        Miguel Ojeda <miguel.ojeda.sandonis@...il.com>,
        Luc Van Oostenryck <luc.vanoostenryck@...il.com>,
        Ard Biesheuvel <ardb@...nel.org>,
        Will Deacon <will@...nel.org>, Arnd Bergmann <arnd@...db.de>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Rasmus Villemoes <linux@...musvillemoes.dk>,
        linux-kernel@...r.kernel.org, clang-built-linux@...glegroups.com,
        x86@...nel.org, Borislav Petkov <bp@...en8.de>,
        Martin Liska <mliska@...e.cz>, Marco Elver <elver@...gle.com>,
        Jonathan Corbet <corbet@....net>,
        Fangrui Song <maskray@...gle.com>, linux-doc@...r.kernel.org,
        linux-kbuild@...r.kernel.org, Dmitry Vyukov <dvyukov@...gle.com>,
        johannes.berg@...el.com, linux-toolchains@...r.kernel.org,
        Heiko Carstens <hca@...ux.ibm.com>,
        Vasily Gorbik <gor@...ux.ibm.com>,
        Christian Borntraeger <borntraeger@...ibm.com>,
        linux-s390@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
        Catalin Marinas <catalin.marinas@....com>,
        Miguel Ojeda <ojeda@...nel.org>
Subject: Re: [PATCH v2 1/3] compiler_attributes.h: define __no_profile, add to
 noinstr

On 6/21/2021 4:18 PM, 'Nick Desaulniers' via Clang Built Linux wrote:
> noinstr implies that we would like the compiler to avoid instrumenting a
> function.  Add support for the compiler attribute
> no_profile_instrument_function to compiler_attributes.h, then add
> __no_profile to the definition of noinstr.
> 
> Link: https://lore.kernel.org/lkml/20210614162018.GD68749@worktop.programming.kicks-ass.net/
> Link: https://reviews.llvm.org/D104257
> Link: https://reviews.llvm.org/D104475
> Link: https://reviews.llvm.org/D104658
> Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80223
> Reviewed-by: Fangrui Song <maskray@...gle.com>
> Reviewed-by: Miguel Ojeda <ojeda@...nel.org>
> Suggested-by: Peter Zijlstra <peterz@...radead.org>
> Signed-off-by: Nick Desaulniers <ndesaulniers@...gle.com>

Reviewed-by: Nathan Chancellor <nathan@...nel.org>

> ---
> Changes V1 -> V2:
> * s/no_profile/no_profile_instrument_function/
> * fix trailing double underscore on GCC 4 define, as per Fangrui+Miguel.
> * Pick up Fangrui + Miguel's reviewed-by tag.
> * Add link to GCC's doc.
> * Fix clang's doc format; will appear once clang-13 is released.
> 
>   include/linux/compiler_attributes.h | 13 +++++++++++++
>   include/linux/compiler_types.h      |  2 +-
>   2 files changed, 14 insertions(+), 1 deletion(-)
> 
> diff --git a/include/linux/compiler_attributes.h b/include/linux/compiler_attributes.h
> index c043b8d2b17b..225511b17223 100644
> --- a/include/linux/compiler_attributes.h
> +++ b/include/linux/compiler_attributes.h
> @@ -33,6 +33,7 @@
>   # define __GCC4_has_attribute___externally_visible__  1
>   # define __GCC4_has_attribute___no_caller_saved_registers__ 0
>   # define __GCC4_has_attribute___noclone__             1
> +# define __GCC4_has_attribute___no_profile_instrument_function__ 0
>   # define __GCC4_has_attribute___nonstring__           0
>   # define __GCC4_has_attribute___no_sanitize_address__ (__GNUC_MINOR__ >= 8)
>   # define __GCC4_has_attribute___no_sanitize_undefined__ (__GNUC_MINOR__ >= 9)
> @@ -237,6 +238,18 @@
>   # define __nonstring
>   #endif
>   
> +/*
> + * Optional: only supported since GCC >= 7.1, clang >= 13.0.
> + *
> + *      gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-no_005fprofile_005finstrument_005ffunction-function-attribute
> + *    clang: https://clang.llvm.org/docs/AttributeReference.html#no-profile-instrument-function
> + */
> +#if __has_attribute(__no_profile_instrument_function__)
> +# define __no_profile                  __attribute__((__no_profile_instrument_function__))
> +#else
> +# define __no_profile
> +#endif
> +
>   /*
>    *   gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-noreturn-function-attribute
>    * clang: https://clang.llvm.org/docs/AttributeReference.html#noreturn
> diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h
> index d29bda7f6ebd..d509169860f1 100644
> --- a/include/linux/compiler_types.h
> +++ b/include/linux/compiler_types.h
> @@ -210,7 +210,7 @@ struct ftrace_likely_data {
>   /* Section for code which can't be instrumented at all */
>   #define noinstr								\
>   	noinline notrace __attribute((__section__(".noinstr.text")))	\
> -	__no_kcsan __no_sanitize_address
> +	__no_kcsan __no_sanitize_address __no_profile
>   
>   #endif /* __KERNEL__ */
>   
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ