stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Patch "ftrace/x86: Set ftrace_stub to weak to prevent gcc from using short jumps to it" has been added to the 4.4-stable tree
@ 2017-01-20 14:53 gregkh
  0 siblings, 0 replies; only message in thread
From: gregkh @ 2017-01-20 14:53 UTC (permalink / raw)
  To: rostedt, gregkh, hjl.tools, jslaby, matt, mhiramat, namhyung
  Cc: stable, stable-commits


This is a note to let you know that I've just added the patch titled

    ftrace/x86: Set ftrace_stub to weak to prevent gcc from using short jumps to it

to the 4.4-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     ftrace-x86-set-ftrace_stub-to-weak-to-prevent-gcc-from-using-short-jumps-to-it.patch
and it can be found in the queue-4.4 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@vger.kernel.org> know about it.


>From 8329e818f14926a6040df86b2668568bde342ebf Mon Sep 17 00:00:00 2001
From: Steven Rostedt <rostedt@goodmis.org>
Date: Mon, 16 May 2016 23:00:35 -0400
Subject: ftrace/x86: Set ftrace_stub to weak to prevent gcc from using short jumps to it

From: Steven Rostedt <rostedt@goodmis.org>

commit 8329e818f14926a6040df86b2668568bde342ebf upstream.

Matt Fleming reported seeing crashes when enabling and disabling
function profiling which uses function graph tracer. Later Namhyung Kim
hit a similar issue and he found that the issue was due to the jmp to
ftrace_stub in ftrace_graph_call was only two bytes, and when it was
changed to jump to the tracing code, it overwrote the ftrace_stub that
was after it.

Masami Hiramatsu bisected this down to a binutils change:

8dcea93252a9ea7dff57e85220a719e2a5e8ab41 is the first bad commit
commit 8dcea93252a9ea7dff57e85220a719e2a5e8ab41
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Fri May 15 03:17:31 2015 -0700

    Add -mshared option to x86 ELF assembler

    This patch adds -mshared option to x86 ELF assembler.  By default,
    assembler will optimize out non-PLT relocations against defined non-weak
    global branch targets with default visibility.  The -mshared option tells
    the assembler to generate code which may go into a shared library
    where all non-weak global branch targets with default visibility can
    be preempted.  The resulting code is slightly bigger.  This option
    only affects the handling of branch instructions.

Declaring ftrace_stub as a weak call prevents gas from using two byte
jumps to it, which would be converted to a jump to the function graph
code.

Link: http://lkml.kernel.org/r/20160516230035.1dbae571@gandalf.local.home

Reported-by: Matt Fleming <matt@codeblueprint.co.uk>
Reported-by: Namhyung Kim <namhyung@kernel.org>
Tested-by: Matt Fleming <matt@codeblueprint.co.uk>
Reviewed-by: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Cc: Jiri Slaby <jslaby@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 arch/x86/kernel/mcount_64.S |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

--- a/arch/x86/kernel/mcount_64.S
+++ b/arch/x86/kernel/mcount_64.S
@@ -180,7 +180,8 @@ GLOBAL(ftrace_graph_call)
 	jmp ftrace_stub
 #endif
 
-GLOBAL(ftrace_stub)
+/* This is weak to keep gas from relaxing the jumps */
+WEAK(ftrace_stub)
 	retq
 END(ftrace_caller)
 


Patches currently in stable-queue which might be from rostedt@goodmis.org are

queue-4.4/ftrace-x86-set-ftrace_stub-to-weak-to-prevent-gcc-from-using-short-jumps-to-it.patch

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2017-01-20 15:03 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-20 14:53 Patch "ftrace/x86: Set ftrace_stub to weak to prevent gcc from using short jumps to it" has been added to the 4.4-stable tree gregkh

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).