Re: warning: calling â__builtin_return_addressâ with a nonzero argument is unsafe

From: Steven Rostedt
Date: Mon Aug 01 2016 - 14:30:51 EST


On Thu, 28 Jul 2016 22:30:43 -0400
Steven Rostedt <rostedt@xxxxxxxxxxx> wrote:

> On Thu, 28 Jul 2016 18:25:33 -0700
> Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:
>
> > I tried something like that, but the CFLAGS games the tracing code
> > does made my thing result in
> >
> > kernel/trace/Makefile:20: *** Recursive variable 'KBUILD_CFLAGS'
> > references itself (eventually). Stop.
> >
> > but yes, if you have the magic fingers to make it work, limiting the
> > -Wno-frame-address to just the tracing code sounds like the
> > RightThing(tm).
>
> Take 2:
>
> It compiles for me, but I don't have a compiler that has that warning
> to test with. See if this works. BTW, it looks like that last comma
> before the ending parenthesis is not needed.

Linus, did you get a chance to test this? I could send a formal patch
if needed. I only have a 4.9 compiler, so I'm not seeing the warnings
others have reported.

-- Steve

>
> Signed-off-by: Steven Rostedt <rostedt@xxxxxxxxxxx>
> ---
> diff --git a/Makefile b/Makefile
> index 393b615..d384848 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -620,7 +620,6 @@ include arch/$(SRCARCH)/Makefile
>
> KBUILD_CFLAGS += $(call cc-option,-fno-delete-null-pointer-checks,)
> KBUILD_CFLAGS += $(call cc-disable-warning,maybe-uninitialized,)
> -KBUILD_CFLAGS += $(call cc-disable-warning,frame-address,)
>
> ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
> KBUILD_CFLAGS += -Os
> diff --git a/kernel/trace/Makefile b/kernel/trace/Makefile
> index 979e7bf..d0a1617 100644
> --- a/kernel/trace/Makefile
> +++ b/kernel/trace/Makefile
> @@ -1,4 +1,8 @@
>
> +# We are fully aware of the dangers of __builtin_return_address()
> +FRAME_CFLAGS := $(call cc-disable-warning,frame-address)
> +KBUILD_CFLAGS += $(FRAME_CFLAGS)
> +
> # Do not instrument the tracer itself:
>
> ifdef CONFIG_FUNCTION_TRACER