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: <20180730183943.GA9221@flashbox>
Date:   Mon, 30 Jul 2018 11:39:43 -0700
From:   Nathan Chancellor <natechancellor@...il.com>
To:     Nick Desaulniers <ndesaulniers@...gle.com>
Cc:     akpm@...ux-foundation.org, mka@...omium.org, ghackmann@...roid.com,
        ghackmann@...gle.com, stable@...r.kernel.org,
        Kees Cook <keescook@...omium.org>,
        Ingo Molnar <mingo@...nel.org>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Josh Poimboeuf <jpoimboe@...hat.com>,
        Wei Wang <wvw@...gle.com>,
        Masahiro Yamada <yamada.masahiro@...ionext.com>,
        Randy Dunlap <rdunlap@...radead.org>,
        NeilBrown <neilb@...e.com>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] kernel.h: Disable -Wreturn-stack-address for _THIS_IP_

On Mon, Jul 30, 2018 at 10:06:20AM -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
> 
> Cc: stable@...r.kernel.org # 4.17, 4.14, 4.9, 4.4
> Signed-off-by: Nick Desaulniers <ndesaulniers@...gle.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..5906f5727f90 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_  (							\
> +{									\
> +	_Pragma("clang diagnostic push")				\
> +	_Pragma("clang diagnostic ignored \"-Wreturn-stack-address\"")	\
> +	__label__ __here;						\
> +__here: (unsigned long)&&__here;					\
> +	_Pragma("clang diagnostic pop")					\
> +}									\
> +)
>  
>  #ifdef CONFIG_LBDAF
>  # include <asm/div64.h>
> -- 
> 2.18.0.233.g985f88cf7e-goog
> 

This generates a ton of warnings with GCC:

In file included from ./include/linux/spinlock.h:58,
                 from ./include/linux/mmzone.h:8,
                 from ./include/linux/gfp.h:6,
                 from ./include/linux/slab.h:15,
                 from ./include/linux/crypto.h:24,
                 from arch/x86/kernel/asm-offsets.c:9:
./include/linux/bottom_half.h: In function ‘local_bh_disable’:
./include/linux/bottom_half.h:19: error: ignoring #pragma clang diagnostic [-Werror=unknown-pragmas]
  __local_bh_disable_ip(_THIS_IP_, SOFTIRQ_DISABLE_OFFSET);

./include/linux/bottom_half.h:19: error: ignoring #pragma clang diagnostic [-Werror=unknown-pragmas]   
./include/linux/bottom_half.h:19: error: ignoring #pragma clang diagnostic [-Werror=unknown-pragmas]                             
./include/linux/bottom_half.h: In function ‘local_bh_enable’:
./include/linux/bottom_half.h:32: error: ignoring #pragma clang diagnostic [-Werror=unknown-pragmas]
  __local_bh_enable_ip(_THIS_IP_, SOFTIRQ_DISABLE_OFFSET);

./include/linux/bottom_half.h:32: error: ignoring #pragma clang diagnostic [-Werror=unknown-pragmas]
./include/linux/bottom_half.h:32: error: ignoring #pragma clang diagnostic [-Werror=unknown-pragmas]
cc1: all warnings being treated as errors
make[1]: *** [Kbuild:56: arch/x86/kernel/asm-offsets.s] Error 1
make: *** [Makefile:1081: prepare0] Error 2

A proper solution is probably going to involve what was done for the
-Wattribute-alias warnings from GCC 8 in commits 8793bb7f4a9d ("kbuild:
add macro for controlling warnings to linux/compiler.h") and
bee20031772a ("disable -Wattribute-alias warning for SYSCALL_DEFINEx()")

I'll take a look at it in a bit unless someone beats me to it.

Thanks!
Nathan

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ