Skip to content

Commit 30f7d1c

Browse files
Zheng Yejianrostedt
authored andcommitted
ftrace: Fix char print issue in print_ip_ins()
When ftrace bug happened, following log shows every hex data in problematic ip address: actual: ffffffe8:6b:ffffffd9:01:21 But so many 'f's seem a little confusing, and that is because format '%x' being used to print signed chars in array 'ins'. As suggested by Joe, change to use format "%*phC" to print array 'ins'. After this patch, the log is like: actual: e8:6b:d9:01:21 Link: https://lkml.kernel.org/r/[email protected] Fixes: 6c14133 ("ftrace: Do not blindly read the ip address in ftrace_bug()") Suggested-by: Joe Perches <[email protected]> Signed-off-by: Zheng Yejian <[email protected]> Signed-off-by: Steven Rostedt (Google) <[email protected]>
1 parent 4f881a6 commit 30f7d1c

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

kernel/trace/ftrace.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2028,17 +2028,14 @@ static int ftrace_hash_ipmodify_update(struct ftrace_ops *ops,
20282028
static void print_ip_ins(const char *fmt, const unsigned char *p)
20292029
{
20302030
char ins[MCOUNT_INSN_SIZE];
2031-
int i;
20322031

20332032
if (copy_from_kernel_nofault(ins, p, MCOUNT_INSN_SIZE)) {
20342033
printk(KERN_CONT "%s[FAULT] %px\n", fmt, p);
20352034
return;
20362035
}
20372036

20382037
printk(KERN_CONT "%s", fmt);
2039-
2040-
for (i = 0; i < MCOUNT_INSN_SIZE; i++)
2041-
printk(KERN_CONT "%s%02x", i ? ":" : "", ins[i]);
2038+
pr_cont("%*phC", MCOUNT_INSN_SIZE, ins);
20422039
}
20432040

20442041
enum ftrace_bug_type ftrace_bug_type;

0 commit comments

Comments
 (0)