Skip to content

Commit

Permalink
tracing: Fix $mcount_regex for MIPS in recordmcount.pl
Browse files Browse the repository at this point in the history
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 <[email protected]>
Acked-by: Wu Zhangjin <[email protected]>
Signed-off-by: David Daney <[email protected]>
LKML-Reference: <[email protected]>
Cc: Li Hong <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Matt Fleming <[email protected]>
Signed-off-by: Steven Rostedt <[email protected]>
  • Loading branch information
David Daney authored and rostedt committed Jul 22, 2010
1 parent 9849ed4 commit a484e54
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion scripts/recordmcount.pl
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ sub check_objcopy
# 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\$";
}
Expand Down

0 comments on commit a484e54

Please sign in to comment.