linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] tracing/selftests: Ignore __pfx_ symbols in kprobe test
@ 2023-02-07 18:51 Steven Rostedt
  2023-02-07 18:54 ` Steven Rostedt
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: Steven Rostedt @ 2023-02-07 18:51 UTC (permalink / raw)
  To: LKML, Linux Trace Kernel
  Cc: Masami Hiramatsu, Shuah Khan, Shuah Khan, Peter Zijlstra

From: "Steven Rostedt (Google)" <rostedt@goodmis.org>

The kprobe probepoint.tc test started failing because of the added __pfx_
symbols that were added because of -fpatchable-function-entry=X,Y causing
unwinders to see them as part of the previous functions. But kprobes can
not be added on top of them. The selftest looks for tracefs_create_dir and
picks it and the previous and following functions to add at their address.
This caused it to include __pfx_tracefs_create_dir which is invalid to
attach a kprobe to and caused the test to fail.

Fixes: 9f2899fe36a62 ("objtool: Add option to generate prefix symbols")
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 tools/testing/selftests/ftrace/test.d/kprobe/probepoint.tc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/ftrace/test.d/kprobe/probepoint.tc b/tools/testing/selftests/ftrace/test.d/kprobe/probepoint.tc
index 624269c8d534..e1b7506c1b11 100644
--- a/tools/testing/selftests/ftrace/test.d/kprobe/probepoint.tc
+++ b/tools/testing/selftests/ftrace/test.d/kprobe/probepoint.tc
@@ -21,7 +21,7 @@ set_offs() { # prev target next
 
 # We have to decode symbol addresses to get correct offsets.
 # If the offset is not an instruction boundary, it cause -EILSEQ.
-set_offs `grep -A1 -B1 ${TARGET_FUNC} /proc/kallsyms | cut -f 1 -d " " | xargs`
+set_offs `grep -v __pfx_ /proc/kallsyms | grep -A1 -B1 ${TARGET_FUNC} |  cut -f 1 -d " " | xargs`
 
 UINT_TEST=no
 # printf "%x" -1 returns (unsigned long)-1.
-- 
2.39.0


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

* Re: [PATCH] tracing/selftests: Ignore __pfx_ symbols in kprobe test
  2023-02-07 18:51 [PATCH] tracing/selftests: Ignore __pfx_ symbols in kprobe test Steven Rostedt
@ 2023-02-07 18:54 ` Steven Rostedt
  2023-02-08 18:05   ` Peter Zijlstra
  2023-02-09 14:06 ` Masami Hiramatsu
  2023-02-14  1:46 ` Steven Rostedt
  2 siblings, 1 reply; 14+ messages in thread
From: Steven Rostedt @ 2023-02-07 18:54 UTC (permalink / raw)
  To: LKML, Linux Trace Kernel
  Cc: Masami Hiramatsu, Shuah Khan, Shuah Khan, Peter Zijlstra

On Tue, 7 Feb 2023 13:51:47 -0500
Steven Rostedt <rostedt@goodmis.org> wrote:

> From: "Steven Rostedt (Google)" <rostedt@goodmis.org>
> 
> The kprobe probepoint.tc test started failing because of the added __pfx_
> symbols that were added because of -fpatchable-function-entry=X,Y causing
> unwinders to see them as part of the previous functions. But kprobes can
> not be added on top of them. The selftest looks for tracefs_create_dir and
> picks it and the previous and following functions to add at their address.
> This caused it to include __pfx_tracefs_create_dir which is invalid to
> attach a kprobe to and caused the test to fail.
> 
> Fixes: 9f2899fe36a62 ("objtool: Add option to generate prefix symbols")
> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>

This is assuming that kprobes can not be added on top of these. But another
solution could be to have kprobes just pick the function the __pfx_ is for.
Would that be a better solution?

-- Steve

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

* Re: [PATCH] tracing/selftests: Ignore __pfx_ symbols in kprobe test
  2023-02-07 18:54 ` Steven Rostedt
@ 2023-02-08 18:05   ` Peter Zijlstra
  2023-02-08 22:03     ` Steven Rostedt
  2023-02-09 14:23     ` Masami Hiramatsu
  0 siblings, 2 replies; 14+ messages in thread
From: Peter Zijlstra @ 2023-02-08 18:05 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: LKML, Linux Trace Kernel, Masami Hiramatsu, Shuah Khan, Shuah Khan

On Tue, Feb 07, 2023 at 01:54:02PM -0500, Steven Rostedt wrote:
> On Tue, 7 Feb 2023 13:51:47 -0500
> Steven Rostedt <rostedt@goodmis.org> wrote:
> 
> > From: "Steven Rostedt (Google)" <rostedt@goodmis.org>
> > 
> > The kprobe probepoint.tc test started failing because of the added __pfx_
> > symbols that were added because of -fpatchable-function-entry=X,Y causing
> > unwinders to see them as part of the previous functions. But kprobes can
> > not be added on top of them. The selftest looks for tracefs_create_dir and
> > picks it and the previous and following functions to add at their address.
> > This caused it to include __pfx_tracefs_create_dir which is invalid to
> > attach a kprobe to and caused the test to fail.
> > 
> > Fixes: 9f2899fe36a62 ("objtool: Add option to generate prefix symbols")
> > Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
> 
> This is assuming that kprobes can not be added on top of these. But another
> solution could be to have kprobes just pick the function the __pfx_ is for.
> Would that be a better solution?

Simply refusing them is simplest. I don't see a compelling reason to
make this complicated.

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

* Re: [PATCH] tracing/selftests: Ignore __pfx_ symbols in kprobe test
  2023-02-08 18:05   ` Peter Zijlstra
@ 2023-02-08 22:03     ` Steven Rostedt
  2023-02-09 10:45       ` Peter Zijlstra
  2023-02-09 14:23     ` Masami Hiramatsu
  1 sibling, 1 reply; 14+ messages in thread
From: Steven Rostedt @ 2023-02-08 22:03 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: LKML, Linux Trace Kernel, Masami Hiramatsu, Shuah Khan, Shuah Khan

On Wed, 8 Feb 2023 19:05:08 +0100
Peter Zijlstra <peterz@infradead.org> wrote:

> > This is assuming that kprobes can not be added on top of these. But another
> > solution could be to have kprobes just pick the function the __pfx_ is for.
> > Would that be a better solution?  
> 
> Simply refusing them is simplest. I don't see a compelling reason to
> make this complicated.

OK, so you are good with the patch as is then?

-- Steve

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

* Re: [PATCH] tracing/selftests: Ignore __pfx_ symbols in kprobe test
  2023-02-08 22:03     ` Steven Rostedt
@ 2023-02-09 10:45       ` Peter Zijlstra
  0 siblings, 0 replies; 14+ messages in thread
From: Peter Zijlstra @ 2023-02-09 10:45 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: LKML, Linux Trace Kernel, Masami Hiramatsu, Shuah Khan, Shuah Khan

On Wed, Feb 08, 2023 at 05:03:04PM -0500, Steven Rostedt wrote:
> On Wed, 8 Feb 2023 19:05:08 +0100
> Peter Zijlstra <peterz@infradead.org> wrote:
> 
> > > This is assuming that kprobes can not be added on top of these. But another
> > > solution could be to have kprobes just pick the function the __pfx_ is for.
> > > Would that be a better solution?  
> > 
> > Simply refusing them is simplest. I don't see a compelling reason to
> > make this complicated.
> 
> OK, so you are good with the patch as is then?

Yeah, but given I've no idea about the whole test thing or .tc files I
didn't ack.

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

* Re: [PATCH] tracing/selftests: Ignore __pfx_ symbols in kprobe test
  2023-02-07 18:51 [PATCH] tracing/selftests: Ignore __pfx_ symbols in kprobe test Steven Rostedt
  2023-02-07 18:54 ` Steven Rostedt
@ 2023-02-09 14:06 ` Masami Hiramatsu
  2023-02-14  1:46 ` Steven Rostedt
  2 siblings, 0 replies; 14+ messages in thread
From: Masami Hiramatsu @ 2023-02-09 14:06 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: LKML, Linux Trace Kernel, Masami Hiramatsu, Shuah Khan,
	Shuah Khan, Peter Zijlstra

On Tue, 7 Feb 2023 13:51:47 -0500
Steven Rostedt <rostedt@goodmis.org> wrote:

> From: "Steven Rostedt (Google)" <rostedt@goodmis.org>
> 
> The kprobe probepoint.tc test started failing because of the added __pfx_
> symbols that were added because of -fpatchable-function-entry=X,Y causing
> unwinders to see them as part of the previous functions. But kprobes can
> not be added on top of them. The selftest looks for tracefs_create_dir and
> picks it and the previous and following functions to add at their address.
> This caused it to include __pfx_tracefs_create_dir which is invalid to
> attach a kprobe to and caused the test to fail.
> 
> Fixes: 9f2899fe36a62 ("objtool: Add option to generate prefix symbols")
> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>

This looks good to me. 

Acked-by: 

Thanks,

> ---
>  tools/testing/selftests/ftrace/test.d/kprobe/probepoint.tc | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/testing/selftests/ftrace/test.d/kprobe/probepoint.tc b/tools/testing/selftests/ftrace/test.d/kprobe/probepoint.tc
> index 624269c8d534..e1b7506c1b11 100644
> --- a/tools/testing/selftests/ftrace/test.d/kprobe/probepoint.tc
> +++ b/tools/testing/selftests/ftrace/test.d/kprobe/probepoint.tc
> @@ -21,7 +21,7 @@ set_offs() { # prev target next
>  
>  # We have to decode symbol addresses to get correct offsets.
>  # If the offset is not an instruction boundary, it cause -EILSEQ.
> -set_offs `grep -A1 -B1 ${TARGET_FUNC} /proc/kallsyms | cut -f 1 -d " " | xargs`
> +set_offs `grep -v __pfx_ /proc/kallsyms | grep -A1 -B1 ${TARGET_FUNC} |  cut -f 1 -d " " | xargs`
>  
>  UINT_TEST=no
>  # printf "%x" -1 returns (unsigned long)-1.
> -- 
> 2.39.0
> 


-- 
Masami Hiramatsu (Google) <mhiramat@kernel.org>

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

* Re: [PATCH] tracing/selftests: Ignore __pfx_ symbols in kprobe test
  2023-02-08 18:05   ` Peter Zijlstra
  2023-02-08 22:03     ` Steven Rostedt
@ 2023-02-09 14:23     ` Masami Hiramatsu
  2023-02-10  9:51       ` Peter Zijlstra
  1 sibling, 1 reply; 14+ messages in thread
From: Masami Hiramatsu @ 2023-02-09 14:23 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: Steven Rostedt, LKML, Linux Trace Kernel, Masami Hiramatsu,
	Shuah Khan, Shuah Khan

On Wed, 8 Feb 2023 19:05:08 +0100
Peter Zijlstra <peterz@infradead.org> wrote:

> On Tue, Feb 07, 2023 at 01:54:02PM -0500, Steven Rostedt wrote:
> > On Tue, 7 Feb 2023 13:51:47 -0500
> > Steven Rostedt <rostedt@goodmis.org> wrote:
> > 
> > > From: "Steven Rostedt (Google)" <rostedt@goodmis.org>
> > > 
> > > The kprobe probepoint.tc test started failing because of the added __pfx_
> > > symbols that were added because of -fpatchable-function-entry=X,Y causing
> > > unwinders to see them as part of the previous functions. But kprobes can
> > > not be added on top of them. The selftest looks for tracefs_create_dir and
> > > picks it and the previous and following functions to add at their address.
> > > This caused it to include __pfx_tracefs_create_dir which is invalid to
> > > attach a kprobe to and caused the test to fail.
> > > 
> > > Fixes: 9f2899fe36a62 ("objtool: Add option to generate prefix symbols")
> > > Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
> > 
> > This is assuming that kprobes can not be added on top of these. But another
> > solution could be to have kprobes just pick the function the __pfx_ is for.
> > Would that be a better solution?
> 
> Simply refusing them is simplest. I don't see a compelling reason to
> make this complicated.

Yeah, and __pfx_ symbols has some "range", that means it is hard to translate
the probe address if user specify __pfx_*+offset.

BTW, currently kprobe event rejects this __pfx_ symbols because it is notrace
symbols, thus we can trace it if CONFIG_KPROBE_EVENTS_ON_NOTRACE=y.
But I guess it should not probe that place always because it should never
executed right?

Thank you,


-- 
Masami Hiramatsu (Google) <mhiramat@kernel.org>

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

* Re: [PATCH] tracing/selftests: Ignore __pfx_ symbols in kprobe test
  2023-02-09 14:23     ` Masami Hiramatsu
@ 2023-02-10  9:51       ` Peter Zijlstra
  0 siblings, 0 replies; 14+ messages in thread
From: Peter Zijlstra @ 2023-02-10  9:51 UTC (permalink / raw)
  To: Masami Hiramatsu
  Cc: Steven Rostedt, LKML, Linux Trace Kernel, Shuah Khan, Shuah Khan

On Thu, Feb 09, 2023 at 11:23:05PM +0900, Masami Hiramatsu wrote:

> BTW, currently kprobe event rejects this __pfx_ symbols because it is notrace
> symbols, thus we can trace it if CONFIG_KPROBE_EVENTS_ON_NOTRACE=y.
> But I guess it should not probe that place always because it should never
> executed right?

Execution can take place in those ranges when X86_FEATURE_CALL_DEPTH is
enabled or when CONFIG_KCFI && X86_FEATURE_IBT.

In the first of those cases the prefix bytes are filled with call
accounting instructions and every direct call to $sym is patched to
point to __pfx_$sym+6 (aka $sym-10).

  https://lore.kernel.org/all/20220915111039.092790446@infradead.org/

In the second case (FineIBT) it is probably easiest if you look at the
comment in arch/x86/kernel/alternative.c near CONFIG_FINEIBT.

  https://lore.kernel.org/all/20221027092812.185993858@infradead.org/

The __pfx_ and __cfi_ symbols are the same (in fact, when
CONFIG_CFI_CLANG=y the compiler generates them and objtool no longer
emits the __pfx_ symbols).

  https://lore.kernel.org/all/20221028194453.592512209@infradead.org/

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

* Re: [PATCH] tracing/selftests: Ignore __pfx_ symbols in kprobe test
  2023-02-07 18:51 [PATCH] tracing/selftests: Ignore __pfx_ symbols in kprobe test Steven Rostedt
  2023-02-07 18:54 ` Steven Rostedt
  2023-02-09 14:06 ` Masami Hiramatsu
@ 2023-02-14  1:46 ` Steven Rostedt
  2023-03-18 18:42   ` Steven Rostedt
  2 siblings, 1 reply; 14+ messages in thread
From: Steven Rostedt @ 2023-02-14  1:46 UTC (permalink / raw)
  To: LKML, Linux Trace Kernel
  Cc: Masami Hiramatsu, Shuah Khan, Shuah Khan, Peter Zijlstra

On Tue, 7 Feb 2023 13:51:47 -0500
Steven Rostedt <rostedt@goodmis.org> wrote:

> From: "Steven Rostedt (Google)" <rostedt@goodmis.org>
> 
> The kprobe probepoint.tc test started failing because of the added __pfx_
> symbols that were added because of -fpatchable-function-entry=X,Y causing
> unwinders to see them as part of the previous functions. But kprobes can
> not be added on top of them. The selftest looks for tracefs_create_dir and
> picks it and the previous and following functions to add at their address.
> This caused it to include __pfx_tracefs_create_dir which is invalid to
> attach a kprobe to and caused the test to fail.
> 
> Fixes: 9f2899fe36a62 ("objtool: Add option to generate prefix symbols")
> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>

Shuah,

Can you pick this patch up?

Thanks,

-- Steve

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

* Re: [PATCH] tracing/selftests: Ignore __pfx_ symbols in kprobe test
  2023-02-14  1:46 ` Steven Rostedt
@ 2023-03-18 18:42   ` Steven Rostedt
  2023-03-20 12:56     ` Shuah Khan
  0 siblings, 1 reply; 14+ messages in thread
From: Steven Rostedt @ 2023-03-18 18:42 UTC (permalink / raw)
  To: LKML, Linux Trace Kernel
  Cc: Masami Hiramatsu, Shuah Khan, Shuah Khan, Peter Zijlstra

On Mon, 13 Feb 2023 20:46:43 -0500
Steven Rostedt <rostedt@goodmis.org> wrote:

> Shuah,
> 
> Can you pick this patch up?

ping?

-- Steve

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

* Re: [PATCH] tracing/selftests: Ignore __pfx_ symbols in kprobe test
  2023-03-18 18:42   ` Steven Rostedt
@ 2023-03-20 12:56     ` Shuah Khan
  2023-03-20 16:30       ` Shuah Khan
  0 siblings, 1 reply; 14+ messages in thread
From: Shuah Khan @ 2023-03-20 12:56 UTC (permalink / raw)
  To: Steven Rostedt, LKML, Linux Trace Kernel
  Cc: Masami Hiramatsu, Shuah Khan, Peter Zijlstra, Shuah Khan

On 3/18/23 12:42, Steven Rostedt wrote:
> On Mon, 13 Feb 2023 20:46:43 -0500
> Steven Rostedt <rostedt@goodmis.org> wrote:
> 
>> Shuah,
>>
>> Can you pick this patch up?
> 
> ping?
> 
> -- Steve

l I will queue this up. Sorry for the delay.

thanks,
-- Shuah

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

* Re: [PATCH] tracing/selftests: Ignore __pfx_ symbols in kprobe test
  2023-03-20 12:56     ` Shuah Khan
@ 2023-03-20 16:30       ` Shuah Khan
  2023-03-20 16:32         ` Steven Rostedt
  2023-03-20 16:40         ` Steven Rostedt
  0 siblings, 2 replies; 14+ messages in thread
From: Shuah Khan @ 2023-03-20 16:30 UTC (permalink / raw)
  To: Steven Rostedt, LKML, Linux Trace Kernel
  Cc: Masami Hiramatsu, Shuah Khan, Peter Zijlstra, Shuah Khan

On 3/20/23 06:56, Shuah Khan wrote:
> On 3/18/23 12:42, Steven Rostedt wrote:
>> On Mon, 13 Feb 2023 20:46:43 -0500
>> Steven Rostedt <rostedt@goodmis.org> wrote:
>>
>>> Shuah,
>>>
>>> Can you pick this patch up?
>>
>> ping?
>>
>> -- Steve
> 
> l I will queue this up. Sorry for the delay.
> 

Steve,

The patch doesn't apply to linux-kselftest fixes branch.
Please rebase and resend with cc to linux-kselftest.
Makes sense why it got buried in my regular Inbox.

This one didn't show up in kselftest list. Fixes tag SHA
is 13 char long. I fixed it and tried to apply. When you
resend, please fix the Fixes tag as well.

thanks,
-- Shuah


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

* Re: [PATCH] tracing/selftests: Ignore __pfx_ symbols in kprobe test
  2023-03-20 16:30       ` Shuah Khan
@ 2023-03-20 16:32         ` Steven Rostedt
  2023-03-20 16:40         ` Steven Rostedt
  1 sibling, 0 replies; 14+ messages in thread
From: Steven Rostedt @ 2023-03-20 16:32 UTC (permalink / raw)
  To: Shuah Khan
  Cc: LKML, Linux Trace Kernel, Masami Hiramatsu, Shuah Khan, Peter Zijlstra

On Mon, 20 Mar 2023 10:30:44 -0600
Shuah Khan <skhan@linuxfoundation.org> wrote:
> 
> Steve,
> 
> The patch doesn't apply to linux-kselftest fixes branch.
> Please rebase and resend with cc to linux-kselftest.
> Makes sense why it got buried in my regular Inbox.
> 
> This one didn't show up in kselftest list. Fixes tag SHA
> is 13 char long. I fixed it and tried to apply. When you
> resend, please fix the Fixes tag as well.

Will do. Thanks Shuah!

-- Steve

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

* Re: [PATCH] tracing/selftests: Ignore __pfx_ symbols in kprobe test
  2023-03-20 16:30       ` Shuah Khan
  2023-03-20 16:32         ` Steven Rostedt
@ 2023-03-20 16:40         ` Steven Rostedt
  1 sibling, 0 replies; 14+ messages in thread
From: Steven Rostedt @ 2023-03-20 16:40 UTC (permalink / raw)
  To: Shuah Khan
  Cc: LKML, Linux Trace Kernel, Masami Hiramatsu, Shuah Khan, Peter Zijlstra

On Mon, 20 Mar 2023 10:30:44 -0600
Shuah Khan <skhan@linuxfoundation.org> wrote:

> The patch doesn't apply to linux-kselftest fixes branch.
> Please rebase and resend with cc to linux-kselftest.
> Makes sense why it got buried in my regular Inbox.

And it doesn't apply because Masami fixed it already.

I'll just drop it. Thanks!

-- Steve

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

end of thread, other threads:[~2023-03-20 16:48 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-07 18:51 [PATCH] tracing/selftests: Ignore __pfx_ symbols in kprobe test Steven Rostedt
2023-02-07 18:54 ` Steven Rostedt
2023-02-08 18:05   ` Peter Zijlstra
2023-02-08 22:03     ` Steven Rostedt
2023-02-09 10:45       ` Peter Zijlstra
2023-02-09 14:23     ` Masami Hiramatsu
2023-02-10  9:51       ` Peter Zijlstra
2023-02-09 14:06 ` Masami Hiramatsu
2023-02-14  1:46 ` Steven Rostedt
2023-03-18 18:42   ` Steven Rostedt
2023-03-20 12:56     ` Shuah Khan
2023-03-20 16:30       ` Shuah Khan
2023-03-20 16:32         ` Steven Rostedt
2023-03-20 16:40         ` Steven Rostedt

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