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: <20180730232512.GA1688@flashbox>
Date:   Mon, 30 Jul 2018 16:25:12 -0700
From:   Nathan Chancellor <natechancellor@...il.com>
To:     Nick Desaulniers <ndesaulniers@...gle.com>
Cc:     akpm@...ux-foundation.org, arnd@...db.de, paul.burton@...s.com,
        christophe.leroy@....fr, shorne@...il.com,
        yamada.masahiro@...ionext.com, keescook@...omium.org,
        mingo@...nel.org, gregkh@...uxfoundation.org, tglx@...utronix.de,
        rdunlap@...radead.org, bp@...e.de, neilb@...e.com,
        linux-kernel@...r.kernel.org, aryabinin@...tuozzo.com,
        dwmw@...zon.co.uk, sandipan@...ux.vnet.ibm.com,
        linux@...musvillemoes.dk, paullawrence@...gle.com,
        andreyknvl@...gle.com, will.deacon@....com, ghackmann@...roid.com,
        stable@...r.kernel.org, ghackmann@...gle.com, mka@...omium.org,
        jpoimboe@...hat.com, wvw@...gle.com, avagin@...nvz.org
Subject: Re: [PATCH v2 2/2] kernel.h: Disable -Wreturn-stack-address for
 _THIS_IP_

On Mon, Jul 30, 2018 at 02:34:12PM -0700, Nick Desaulniers wrote:
> Starting with Clang-7.0, _THIS_IP_ generates -Wreturn-stack-address
> warnings for almost every translation unit. In general, I'd prefer to
> leave this on (returning the address of a stack allocated variable is in
> general a bad idea) and disable it only at whitelisted call sites.
> 
> We can't do something like:
>  #pragma clang diagnostic push
>  #pragma clang diagnostic ignored "-Wreturn-stack-address"
>  <code>
>  #pragma clang diagnostic pop
> 
> in a GNU Statement Expression or macro, hence we use _Pragma, which is
> its raison d'ĂȘtre: https://gcc.gnu.org/onlinedocs/cpp/Pragmas.html
> 
> We also can't use compiler specific pragma's without triggering
> -Werror=unknown-pragmas in other compilers, so use __diag.
> 
> 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>

Tested-and-reviewed-by: Nathan Chancellor <natechancellor@...il.com>

> ---
>  include/linux/kernel.h | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/include/linux/kernel.h b/include/linux/kernel.h
> index 941dc0a5a877..909bb771c0ca 100644
> --- a/include/linux/kernel.h
> +++ b/include/linux/kernel.h
> @@ -168,7 +168,15 @@
>  
>  
>  #define _RET_IP_		(unsigned long)__builtin_return_address(0)
> -#define _THIS_IP_  ({ __label__ __here; __here: (unsigned long)&&__here; })
> +#define _THIS_IP_  (							\
> +{									\
> +	__label__ __here;						\
> +	__diag_push()							\
> +	__diag_ignore(CLANG, 7, "-Wreturn-stack-address", "")		\
> +__here: (unsigned long)&&__here;					\
> +	__diag_pop()							\
> +}									\
> +)
>  
>  #ifdef CONFIG_LBDAF
>  # include <asm/div64.h>
> -- 
> 2.18.0.345.g5c9ce644c3-goog
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ