* [PATCH] ftrace: Fix char print issue in print_ip_ins()
@ 2022-10-10 19:15 Zheng Yejian
2022-10-11 2:35 ` Joe Perches
0 siblings, 1 reply; 3+ messages in thread
From: Zheng Yejian @ 2022-10-10 19:15 UTC (permalink / raw)
To: rostedt, mingo, linux-kernel; +Cc: zhengyejian1
When ftrace bug happened, following log shows every byte data in
problem ip address:
actual: ffffffe8:6b:ffffffd9:01:21
However that seems a little confusing, and it is because format
'%x' being used to print signed chars in print_ip_ins().
After this patch, the log is like:
actual: e8:6b:d9:01:21
Fixes: 6c14133d2d3f ("ftrace: Do not blindly read the ip address in ftrace_bug()")
Signed-off-by: Zheng Yejian <zhengyejian1@huawei.com>
---
kernel/trace/ftrace.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 439e2ab6905e..251ba30c871d 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -2015,7 +2015,7 @@ static int ftrace_hash_ipmodify_update(struct ftrace_ops *ops,
static void print_ip_ins(const char *fmt, const unsigned char *p)
{
- char ins[MCOUNT_INSN_SIZE];
+ unsigned char ins[MCOUNT_INSN_SIZE];
int i;
if (copy_from_kernel_nofault(ins, p, MCOUNT_INSN_SIZE)) {
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] ftrace: Fix char print issue in print_ip_ins()
2022-10-10 19:15 [PATCH] ftrace: Fix char print issue in print_ip_ins() Zheng Yejian
@ 2022-10-11 2:35 ` Joe Perches
2022-10-11 11:22 ` Zheng Yejian
0 siblings, 1 reply; 3+ messages in thread
From: Joe Perches @ 2022-10-11 2:35 UTC (permalink / raw)
To: Zheng Yejian, rostedt, mingo, linux-kernel
On Mon, 2022-10-10 at 19:15 +0000, Zheng Yejian wrote:
> When ftrace bug happened, following log shows every byte data in
> problem ip address:
> actual: ffffffe8:6b:ffffffd9:01:21
>
> However that seems a little confusing, and it is because format
> '%x' being used to print signed chars in print_ip_ins().
>
> After this patch, the log is like:
> actual: e8:6b:d9:01:21
>
> Fixes: 6c14133d2d3f ("ftrace: Do not blindly read the ip address in ftrace_bug()")
> Signed-off-by: Zheng Yejian <zhengyejian1@huawei.com>
> ---
> kernel/trace/ftrace.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
[]
> @@ -2015,7 +2015,7 @@ static int ftrace_hash_ipmodify_update(struct ftrace_ops *ops,
>
> static void print_ip_ins(const char *fmt, const unsigned char *p)
> {
> - char ins[MCOUNT_INSN_SIZE];
> + unsigned char ins[MCOUNT_INSN_SIZE];
> int i;
>
> if (copy_from_kernel_nofault(ins, p, MCOUNT_INSN_SIZE)) {
Perhaps nicer would be to change the for loop below this from
for (i = 0; i < MCOUNT_INSN_SIZE; i++)
printk(KERN_CONT "%s%02x", i ? ":" : "", ins[i]);
to
pr_cont("%*phC", MCOUNT_INSN_SIZE, ins);
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ftrace: Fix char print issue in print_ip_ins()
2022-10-11 2:35 ` Joe Perches
@ 2022-10-11 11:22 ` Zheng Yejian
0 siblings, 0 replies; 3+ messages in thread
From: Zheng Yejian @ 2022-10-11 11:22 UTC (permalink / raw)
To: joe; +Cc: linux-kernel, mingo, rostedt, zhengyejian1
On Mon, 10 Oct 2022 19:35:38 -0700, Joe Perches <joe@perches.com> wrote:
> On Mon, 2022-10-10 at 19:15 +0000, Zheng Yejian wrote:
> > When ftrace bug happened, following log shows every byte data in
> > problem ip address:
> > actual: ffffffe8:6b:ffffffd9:01:21
> >
> > However that seems a little confusing, and it is because format
> > '%x' being used to print signed chars in print_ip_ins().
> >
> > After this patch, the log is like:
> > actual: e8:6b:d9:01:21
> >
> > Fixes: 6c14133d2d3f ("ftrace: Do not blindly read the ip address in ftrace_bug()")
> > Signed-off-by: Zheng Yejian <zhengyejian1@huawei.com>
> > ---
> > kernel/trace/ftrace.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
> []
> > @@ -2015,7 +2015,7 @@ static int ftrace_hash_ipmodify_update(struct ftrace_ops *ops,
> >
> > static void print_ip_ins(const char *fmt, const unsigned char *p)
> > {
> > - char ins[MCOUNT_INSN_SIZE];
> > + unsigned char ins[MCOUNT_INSN_SIZE];
> > int i;
> >
> > if (copy_from_kernel_nofault(ins, p, MCOUNT_INSN_SIZE)) {
>
> Perhaps nicer would be to change the for loop below this from
>
> for (i = 0; i < MCOUNT_INSN_SIZE; i++)
> printk(KERN_CONT "%s%02x", i ? ":" : "", ins[i]);
>
> to
>
> pr_cont("%*phC", MCOUNT_INSN_SIZE, ins);
It works, thanks for your suggestion. I'll send a new version patch.
-- Zheng Yejian
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-10-11 3:23 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-10 19:15 [PATCH] ftrace: Fix char print issue in print_ip_ins() Zheng Yejian
2022-10-11 2:35 ` Joe Perches
2022-10-11 11:22 ` Zheng Yejian
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).