linux-trace-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ftrace: fix address for jmp mode in t_show
@ 2025-12-16  3:45 Menglong Dong
  2025-12-16 16:28 ` Steven Rostedt
  0 siblings, 1 reply; 3+ messages in thread
From: Menglong Dong @ 2025-12-16  3:45 UTC (permalink / raw)
  To: rostedt
  Cc: mhiramat, mark.rutland, mathieu.desnoyers, menglong8.dong, ast,
	jiang.biao, linux-kernel, linux-trace-kernel

The address from ftrace_find_rec_direct() is printed directly in t_show().
This can mislead symbol offsets if it has the "jmp" bit in the last bit.

Fix this by printing the address that returned by ftrace_jmp_get().

Fixes: 25e4e3565d45 ("ftrace: Introduce FTRACE_OPS_FL_JMP")
Signed-off-by: Menglong Dong <dongml2@chinatelecom.cn>
---
 kernel/trace/ftrace.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index bbb37c0f8c6c..d4c41fb76a25 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -4492,8 +4492,12 @@ static int t_show(struct seq_file *m, void *v)
 			unsigned long direct;
 
 			direct = ftrace_find_rec_direct(rec->ip);
-			if (direct)
-				seq_printf(m, "\n\tdirect-->%pS", (void *)direct);
+			if (direct) {
+				seq_printf(m, ftrace_is_jmp(direct) ?
+					      "\n\tdirect(jmp)-->%pS" :
+					      "\n\tdirect-->%pS",
+					   (void *)ftrace_jmp_get(direct));
+			}
 		}
 	}
 
-- 
2.52.0


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

* Re: [PATCH] ftrace: fix address for jmp mode in t_show
  2025-12-16  3:45 [PATCH] ftrace: fix address for jmp mode in t_show Menglong Dong
@ 2025-12-16 16:28 ` Steven Rostedt
  2025-12-17  1:32   ` Menglong Dong
  0 siblings, 1 reply; 3+ messages in thread
From: Steven Rostedt @ 2025-12-16 16:28 UTC (permalink / raw)
  To: Menglong Dong
  Cc: mhiramat, mark.rutland, mathieu.desnoyers, ast, jiang.biao,
	linux-kernel, linux-trace-kernel

On Tue, 16 Dec 2025 11:45:33 +0800
Menglong Dong <menglong8.dong@gmail.com> wrote:

> diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
> index bbb37c0f8c6c..d4c41fb76a25 100644
> --- a/kernel/trace/ftrace.c
> +++ b/kernel/trace/ftrace.c
> @@ -4492,8 +4492,12 @@ static int t_show(struct seq_file *m, void *v)
>  			unsigned long direct;
>  
>  			direct = ftrace_find_rec_direct(rec->ip);
> -			if (direct)
> -				seq_printf(m, "\n\tdirect-->%pS", (void *)direct);
> +			if (direct) {
> +				seq_printf(m, ftrace_is_jmp(direct) ?
> +					      "\n\tdirect(jmp)-->%pS" :
> +					      "\n\tdirect-->%pS",
> +					   (void *)ftrace_jmp_get(direct));

A little cleaner way to do the above:

				seq_printf(m, "\n\tdirect%s-->%pS",
					   ftrace_is_jmp(direct) ? "(jmp)" : "",
					   (void *)ftrace_jmp_get(direct));


-- Steve

> +			}
>  		}
>  	}

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

* Re: [PATCH] ftrace: fix address for jmp mode in t_show
  2025-12-16 16:28 ` Steven Rostedt
@ 2025-12-17  1:32   ` Menglong Dong
  0 siblings, 0 replies; 3+ messages in thread
From: Menglong Dong @ 2025-12-17  1:32 UTC (permalink / raw)
  To: Menglong Dong, Steven Rostedt
  Cc: mhiramat, mark.rutland, mathieu.desnoyers, ast, jiang.biao,
	linux-kernel, linux-trace-kernel

On 2025/12/17 00:28 Steven Rostedt <rostedt@goodmis.org> write:
> On Tue, 16 Dec 2025 11:45:33 +0800
> Menglong Dong <menglong8.dong@gmail.com> wrote:
> 
> > diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
> > index bbb37c0f8c6c..d4c41fb76a25 100644
> > --- a/kernel/trace/ftrace.c
> > +++ b/kernel/trace/ftrace.c
> > @@ -4492,8 +4492,12 @@ static int t_show(struct seq_file *m, void *v)
> >  			unsigned long direct;
> >  
> >  			direct = ftrace_find_rec_direct(rec->ip);
> > -			if (direct)
> > -				seq_printf(m, "\n\tdirect-->%pS", (void *)direct);
> > +			if (direct) {
> > +				seq_printf(m, ftrace_is_jmp(direct) ?
> > +					      "\n\tdirect(jmp)-->%pS" :
> > +					      "\n\tdirect-->%pS",
> > +					   (void *)ftrace_jmp_get(direct));
> 
> A little cleaner way to do the above:
> 
> 				seq_printf(m, "\n\tdirect%s-->%pS",
> 					   ftrace_is_jmp(direct) ? "(jmp)" : "",
> 					   (void *)ftrace_jmp_get(direct));

Yeah, looks better. I'll send a V2 later.

Thanks!
Menglong Dong

> 
> 
> -- Steve
> 
> > +			}
> >  		}
> >  	}
> 
> 





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

end of thread, other threads:[~2025-12-17  1:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-16  3:45 [PATCH] ftrace: fix address for jmp mode in t_show Menglong Dong
2025-12-16 16:28 ` Steven Rostedt
2025-12-17  1:32   ` Menglong Dong

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