stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nathan Chancellor <natechancellor@gmail.com>
To: Nick Desaulniers <ndesaulniers@google.com>
Cc: akpm@linux-foundation.org, arnd@arndb.de, paul.burton@mips.com,
	christophe.leroy@c-s.fr, shorne@gmail.com,
	yamada.masahiro@socionext.com, keescook@chromium.org,
	mingo@kernel.org, gregkh@linuxfoundation.org, tglx@linutronix.de,
	rdunlap@infradead.org, bp@suse.de, neilb@suse.com,
	linux-kernel@vger.kernel.org, aryabinin@virtuozzo.com,
	dwmw@amazon.co.uk, sandipan@linux.vnet.ibm.com,
	linux@rasmusvillemoes.dk, paullawrence@google.com,
	andreyknvl@google.com, will.deacon@arm.com,
	ghackmann@android.com, stable@vger.kernel.org,
	ghackmann@google.com, mka@chromium.org, jpoimboe@redhat.com,
	wvw@google.com, avagin@openvz.org
Subject: Re: [PATCH v2 2/2] kernel.h: Disable -Wreturn-stack-address for _THIS_IP_
Date: Mon, 30 Jul 2018 16:25:12 -0700	[thread overview]
Message-ID: <20180730232512.GA1688@flashbox> (raw)
In-Reply-To: <20180730213412.242849-3-ndesaulniers@google.com>

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@vger.kernel.org # 4.17, 4.14, 4.9, 4.4
> Suggested-by: Nathan Chancellor <natechancellor@gmail.com>
> Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>

Tested-and-reviewed-by: Nathan Chancellor <natechancellor@gmail.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
> 

  reply	other threads:[~2018-07-31  1:02 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-30 21:34 [PATCH v2 0/2] CLANG_VERSION and __diag macros Nick Desaulniers
2018-07-30 21:34 ` [PATCH v2 1/2] compiler-clang.h: Add " Nick Desaulniers
2018-07-30 23:25   ` Nathan Chancellor
2018-08-31 21:50   ` Nick Desaulniers
2018-08-31 22:16     ` Miguel Ojeda
2018-07-30 21:34 ` [PATCH v2 2/2] kernel.h: Disable -Wreturn-stack-address for _THIS_IP_ Nick Desaulniers
2018-07-30 23:25   ` Nathan Chancellor [this message]
2018-07-31 10:27   ` kbuild test robot
2018-07-31 16:48     ` Nick Desaulniers
2018-07-31 17:02       ` Nathan Chancellor
     [not found]       ` <CAGXu5jJFdbcmSMZi-uz0QySJ5c6uqUKEazztDfCWDeQOMF-T-Q@mail.gmail.com>
2018-07-31 17:09         ` Nick Desaulniers
2018-07-31 18:58         ` Nick Desaulniers
2018-07-31 21:10           ` Nick Desaulniers
2018-07-31 13:53   ` kbuild test robot
2018-07-31 16:55     ` Nick Desaulniers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180730232512.GA1688@flashbox \
    --to=natechancellor@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=andreyknvl@google.com \
    --cc=arnd@arndb.de \
    --cc=aryabinin@virtuozzo.com \
    --cc=avagin@openvz.org \
    --cc=bp@suse.de \
    --cc=christophe.leroy@c-s.fr \
    --cc=dwmw@amazon.co.uk \
    --cc=ghackmann@android.com \
    --cc=ghackmann@google.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jpoimboe@redhat.com \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@rasmusvillemoes.dk \
    --cc=mingo@kernel.org \
    --cc=mka@chromium.org \
    --cc=ndesaulniers@google.com \
    --cc=neilb@suse.com \
    --cc=paul.burton@mips.com \
    --cc=paullawrence@google.com \
    --cc=rdunlap@infradead.org \
    --cc=sandipan@linux.vnet.ibm.com \
    --cc=shorne@gmail.com \
    --cc=stable@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=will.deacon@arm.com \
    --cc=wvw@google.com \
    --cc=yamada.masahiro@socionext.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).