public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tracing: recordmcount.pl: Fix $mcount_regex for MIPS.
@ 2010-07-09 21:52 David Daney
  2010-07-10  0:26 ` Steven Rostedt
  2010-07-23 12:11 ` [tip:perf/core] tracing: Fix $mcount_regex for MIPS in recordmcount.pl tip-bot for David Daney
  0 siblings, 2 replies; 5+ messages in thread
From: David Daney @ 2010-07-09 21:52 UTC (permalink / raw)
  To: rostedt
  Cc: linux-kernel, linux-mips, David Daney, Li Hong, Ingo Molnar,
	Matt Fleming, Ralf Baechle

I found this issue in a locally patched 2.6.32.x, current kernels have
moved the offending code to an __init function which is skipped by
recordmcount.pl, so the bug is not currently being exercised.
However, I think the patch is still a good idea, to avoid future
problems if _mcount were to ever have its address taken in normal
code.

This is what I originally saw:

    Although arch/mips/kernel/ftrace.c is built without -pg, and thus
    contains no calls to _mcount, it does use the address of _mcount
    in ftrace_make_nop().  This was causing relocations to be emitted
    for _mcount which recordmcount.pl erronously took to be _mcount
    call sites.  The result was that the text of ftrace_make_nop()
    would be patched with garbage leading to a system crash.

In non-module code, all _mcount call sites will have R_MIPS_26
relocations, so we restrict $mcount_regex to only match on these.

Signed-off-by: David Daney <ddaney@caviumnetworks.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Li Hong <lihong.hi@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Matt Fleming <matt@console-pimps.org>
Cc: Ralf Baechle <ralf@linux-mips.org>
---
 scripts/recordmcount.pl |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/scripts/recordmcount.pl b/scripts/recordmcount.pl
index f3c9c0a..0171060 100755
--- a/scripts/recordmcount.pl
+++ b/scripts/recordmcount.pl
@@ -326,7 +326,7 @@ if ($arch eq "x86_64") {
     #                    14: R_MIPS_NONE *ABS*
     #	 18:   00020021        nop
     if ($is_module eq "0") {
-	    $mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\s_mcount\$";
+	    $mcount_regex = "^\\s*([0-9a-fA-F]+): R_MIPS_26\\s+_mcount\$";
     } else {
 	    $mcount_regex = "^\\s*([0-9a-fA-F]+): R_MIPS_HI16\\s+_mcount\$";
     }
-- 
1.6.6.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] tracing: recordmcount.pl: Fix $mcount_regex for MIPS.
  2010-07-09 21:52 [PATCH] tracing: recordmcount.pl: Fix $mcount_regex for MIPS David Daney
@ 2010-07-10  0:26 ` Steven Rostedt
  2010-07-10  2:12   ` Ralf Baechle
  2010-07-10  3:32   ` Wu Zhangjin
  2010-07-23 12:11 ` [tip:perf/core] tracing: Fix $mcount_regex for MIPS in recordmcount.pl tip-bot for David Daney
  1 sibling, 2 replies; 5+ messages in thread
From: Steven Rostedt @ 2010-07-10  0:26 UTC (permalink / raw)
  To: David Daney
  Cc: linux-kernel, linux-mips, Li Hong, Ingo Molnar, Matt Fleming,
	Ralf Baechle, Wu Zhangjin

On Fri, 2010-07-09 at 14:52 -0700, David Daney wrote:
> I found this issue in a locally patched 2.6.32.x, current kernels have
> moved the offending code to an __init function which is skipped by
> recordmcount.pl, so the bug is not currently being exercised.
> However, I think the patch is still a good idea, to avoid future
> problems if _mcount were to ever have its address taken in normal
> code.
> 
> This is what I originally saw:
> 
>     Although arch/mips/kernel/ftrace.c is built without -pg, and thus
>     contains no calls to _mcount, it does use the address of _mcount
>     in ftrace_make_nop().  This was causing relocations to be emitted
>     for _mcount which recordmcount.pl erronously took to be _mcount
>     call sites.  The result was that the text of ftrace_make_nop()
>     would be patched with garbage leading to a system crash.
> 
> In non-module code, all _mcount call sites will have R_MIPS_26
> relocations, so we restrict $mcount_regex to only match on these.
> 

I'd like to get an Acked-by from Ralf and Wu before pulling this.

Thanks,

-- Steve

> Signed-off-by: David Daney <ddaney@caviumnetworks.com>
> Cc: Steven Rostedt <rostedt@goodmis.org>
> Cc: Li Hong <lihong.hi@gmail.com>
> Cc: Ingo Molnar <mingo@elte.hu>
> Cc: Matt Fleming <matt@console-pimps.org>
> Cc: Ralf Baechle <ralf@linux-mips.org>
> ---
>  scripts/recordmcount.pl |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/scripts/recordmcount.pl b/scripts/recordmcount.pl
> index f3c9c0a..0171060 100755
> --- a/scripts/recordmcount.pl
> +++ b/scripts/recordmcount.pl
> @@ -326,7 +326,7 @@ if ($arch eq "x86_64") {
>      #                    14: R_MIPS_NONE *ABS*
>      #	 18:   00020021        nop
>      if ($is_module eq "0") {
> -	    $mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\s_mcount\$";
> +	    $mcount_regex = "^\\s*([0-9a-fA-F]+): R_MIPS_26\\s+_mcount\$";
>      } else {
>  	    $mcount_regex = "^\\s*([0-9a-fA-F]+): R_MIPS_HI16\\s+_mcount\$";
>      }



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] tracing: recordmcount.pl: Fix $mcount_regex for MIPS.
  2010-07-10  0:26 ` Steven Rostedt
@ 2010-07-10  2:12   ` Ralf Baechle
  2010-07-10  3:32   ` Wu Zhangjin
  1 sibling, 0 replies; 5+ messages in thread
From: Ralf Baechle @ 2010-07-10  2:12 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: David Daney, linux-kernel, linux-mips, Li Hong, Ingo Molnar,
	Matt Fleming, Wu Zhangjin

On Fri, Jul 09, 2010 at 08:26:02PM -0400, Steven Rostedt wrote:

> I'd like to get an Acked-by from Ralf and Wu before pulling this.

I talked through this on irc with David and it is the right thing to do.

Acked-by: Ralf Baechle <ralf@linux-mips.org>

  Ralf

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] tracing: recordmcount.pl: Fix $mcount_regex for MIPS.
  2010-07-10  0:26 ` Steven Rostedt
  2010-07-10  2:12   ` Ralf Baechle
@ 2010-07-10  3:32   ` Wu Zhangjin
  1 sibling, 0 replies; 5+ messages in thread
From: Wu Zhangjin @ 2010-07-10  3:32 UTC (permalink / raw)
  To: rostedt
  Cc: David Daney, linux-kernel, linux-mips, Li Hong, Ingo Molnar,
	Matt Fleming, Ralf Baechle

On Fri, 2010-07-09 at 20:26 -0400, Steven Rostedt wrote:
> 
> I'd like to get an Acked-by from Ralf and Wu before pulling this.
> 

It is ok for me ;)

Acked-by: Wu Zhangjin <wuzhangjin@gmail.com>

Regards,
	Wu Zhangjin


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [tip:perf/core] tracing: Fix $mcount_regex for MIPS in recordmcount.pl
  2010-07-09 21:52 [PATCH] tracing: recordmcount.pl: Fix $mcount_regex for MIPS David Daney
  2010-07-10  0:26 ` Steven Rostedt
@ 2010-07-23 12:11 ` tip-bot for David Daney
  1 sibling, 0 replies; 5+ messages in thread
From: tip-bot for David Daney @ 2010-07-23 12:11 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: lihong.hi, linux-kernel, hpa, mingo, wuzhangjin, rostedt, ralf,
	matt, ddaney, tglx, mingo

Commit-ID:  a484e54fae891703cbe1c9ec1b536605f11f5482
Gitweb:     http://git.kernel.org/tip/a484e54fae891703cbe1c9ec1b536605f11f5482
Author:     David Daney <ddaney@caviumnetworks.com>
AuthorDate: Fri, 9 Jul 2010 14:52:05 -0700
Committer:  Steven Rostedt <rostedt@goodmis.org>
CommitDate: Thu, 22 Jul 2010 14:55:43 -0400

tracing: Fix $mcount_regex for MIPS in recordmcount.pl

I found this issue in a locally patched 2.6.32.x, current kernels have
moved the offending code to an __init function which is skipped by
recordmcount.pl, so the bug is not currently being exercised.
However, I think the patch is still a good idea, to avoid future
problems if _mcount were to ever have its address taken in normal
code.

This is what I originally saw:

    Although arch/mips/kernel/ftrace.c is built without -pg, and thus
    contains no calls to _mcount, it does use the address of _mcount
    in ftrace_make_nop().  This was causing relocations to be emitted
    for _mcount which recordmcount.pl erronously took to be _mcount
    call sites.  The result was that the text of ftrace_make_nop()
    would be patched with garbage leading to a system crash.

In non-module code, all _mcount call sites will have R_MIPS_26
relocations, so we restrict $mcount_regex to only match on these.

Acked-by: Ralf Baechle <ralf@linux-mips.org>
Acked-by: Wu Zhangjin <wuzhangjin@gmail.com>
Signed-off-by: David Daney <ddaney@caviumnetworks.com>
LKML-Reference: <1278712325-12050-1-git-send-email-ddaney@caviumnetworks.com>
Cc: Li Hong <lihong.hi@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Matt Fleming <matt@console-pimps.org>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 scripts/recordmcount.pl |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/scripts/recordmcount.pl b/scripts/recordmcount.pl
index f3c9c0a..0171060 100755
--- a/scripts/recordmcount.pl
+++ b/scripts/recordmcount.pl
@@ -326,7 +326,7 @@ if ($arch eq "x86_64") {
     #                    14: R_MIPS_NONE *ABS*
     #	 18:   00020021        nop
     if ($is_module eq "0") {
-	    $mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\s_mcount\$";
+	    $mcount_regex = "^\\s*([0-9a-fA-F]+): R_MIPS_26\\s+_mcount\$";
     } else {
 	    $mcount_regex = "^\\s*([0-9a-fA-F]+): R_MIPS_HI16\\s+_mcount\$";
     }

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-07-23 12:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-09 21:52 [PATCH] tracing: recordmcount.pl: Fix $mcount_regex for MIPS David Daney
2010-07-10  0:26 ` Steven Rostedt
2010-07-10  2:12   ` Ralf Baechle
2010-07-10  3:32   ` Wu Zhangjin
2010-07-23 12:11 ` [tip:perf/core] tracing: Fix $mcount_regex for MIPS in recordmcount.pl tip-bot for David Daney

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox