All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tracing/x86: fix trace event registration for syscalls without arguments
@ 2020-04-08 18:13 Konstantin Khlebnikov
  2020-04-27 13:16 ` Konstantin Khlebnikov
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Konstantin Khlebnikov @ 2020-04-08 18:13 UTC (permalink / raw)
  To: Brian Gerst, linux-kernel
  Cc: Thomas Gleixner, Dominik Brodowski, Andy Lutomirski

Syscalls without arguments now has no ABI subs, instead of that macro
SYSCALL_DEFINE0() defines __abi_sys_name as aliase to __do_sys_name.

As a result in find_syscall_meta() kallsyms_lookup() returns
"__do_sys_name" which does not match with declared trace event.

Also see commit 1c758a2202a6 ("tracing/x86: Update syscall trace events
to handle new prefixed syscall func names")

Fixes: d2b5de495ee9 ("x86/entry: Refactor SYSCALL_DEFINE0 macros")
Signed-off-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
---
 arch/x86/include/asm/ftrace.h |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/x86/include/asm/ftrace.h b/arch/x86/include/asm/ftrace.h
index 85be2f506272..70b96cae5b42 100644
--- a/arch/x86/include/asm/ftrace.h
+++ b/arch/x86/include/asm/ftrace.h
@@ -61,11 +61,12 @@ static inline bool arch_syscall_match_sym_name(const char *sym, const char *name
 {
 	/*
 	 * Compare the symbol name with the system call name. Skip the
-	 * "__x64_sys", "__ia32_sys" or simple "sys" prefix.
+	 * "__x64_sys", "__ia32_sys", "__do_sys" or simple "sys" prefix.
 	 */
 	return !strcmp(sym + 3, name + 3) ||
 		(!strncmp(sym, "__x64_", 6) && !strcmp(sym + 9, name + 3)) ||
-		(!strncmp(sym, "__ia32_", 7) && !strcmp(sym + 10, name + 3));
+		(!strncmp(sym, "__ia32_", 7) && !strcmp(sym + 10, name + 3)) ||
+		(!strncmp(sym, "__do_sys", 8) && !strcmp(sym + 8, name + 3));
 }
 
 #ifndef COMPILE_OFFSETS


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

* Re: [PATCH] tracing/x86: fix trace event registration for syscalls without arguments
  2020-04-08 18:13 [PATCH] tracing/x86: fix trace event registration for syscalls without arguments Konstantin Khlebnikov
@ 2020-04-27 13:16 ` Konstantin Khlebnikov
  2020-04-27 19:13   ` Steven Rostedt
  2020-04-27 14:44 ` Thomas Gleixner
  2020-05-01 18:22 ` [tip: x86/urgent] ftrace/x86: Fix " tip-bot2 for Konstantin Khlebnikov
  2 siblings, 1 reply; 6+ messages in thread
From: Konstantin Khlebnikov @ 2020-04-27 13:16 UTC (permalink / raw)
  To: Brian Gerst, linux-kernel
  Cc: Thomas Gleixner, Dominik Brodowski, Andy Lutomirski,
	Steven Rostedt, Ingo Molnar

Bump, bug still present in 5.7.0-rc3

root@kernel0:~# uname -r
5.7.0-rc3-test

root@kernel0:~# ls -d /sys/kernel/tracing/events/syscalls/sys_enter_{sync,fsync}
ls: cannot access '/sys/kernel/tracing/events/syscalls/sys_enter_sync': No such file or directory
/sys/kernel/tracing/events/syscalls/sys_enter_fsync

On 08/04/2020 21.13, Konstantin Khlebnikov wrote:
> Syscalls without arguments now has no ABI subs, instead of that macro
> SYSCALL_DEFINE0() defines __abi_sys_name as aliase to __do_sys_name.
> 
> As a result in find_syscall_meta() kallsyms_lookup() returns
> "__do_sys_name" which does not match with declared trace event.
> 
> Also see commit 1c758a2202a6 ("tracing/x86: Update syscall trace events
> to handle new prefixed syscall func names")
> 
> Fixes: d2b5de495ee9 ("x86/entry: Refactor SYSCALL_DEFINE0 macros")
> Signed-off-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
> ---
>   arch/x86/include/asm/ftrace.h |    5 +++--
>   1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/x86/include/asm/ftrace.h b/arch/x86/include/asm/ftrace.h
> index 85be2f506272..70b96cae5b42 100644
> --- a/arch/x86/include/asm/ftrace.h
> +++ b/arch/x86/include/asm/ftrace.h
> @@ -61,11 +61,12 @@ static inline bool arch_syscall_match_sym_name(const char *sym, const char *name
>   {
>   	/*
>   	 * Compare the symbol name with the system call name. Skip the
> -	 * "__x64_sys", "__ia32_sys" or simple "sys" prefix.
> +	 * "__x64_sys", "__ia32_sys", "__do_sys" or simple "sys" prefix.
>   	 */
>   	return !strcmp(sym + 3, name + 3) ||
>   		(!strncmp(sym, "__x64_", 6) && !strcmp(sym + 9, name + 3)) ||
> -		(!strncmp(sym, "__ia32_", 7) && !strcmp(sym + 10, name + 3));
> +		(!strncmp(sym, "__ia32_", 7) && !strcmp(sym + 10, name + 3)) ||
> +		(!strncmp(sym, "__do_sys", 8) && !strcmp(sym + 8, name + 3));
>   }
>   
>   #ifndef COMPILE_OFFSETS
> 

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

* Re: [PATCH] tracing/x86: fix trace event registration for syscalls without arguments
  2020-04-08 18:13 [PATCH] tracing/x86: fix trace event registration for syscalls without arguments Konstantin Khlebnikov
  2020-04-27 13:16 ` Konstantin Khlebnikov
@ 2020-04-27 14:44 ` Thomas Gleixner
  2020-04-27 14:55   ` Konstantin Khlebnikov
  2020-05-01 18:22 ` [tip: x86/urgent] ftrace/x86: Fix " tip-bot2 for Konstantin Khlebnikov
  2 siblings, 1 reply; 6+ messages in thread
From: Thomas Gleixner @ 2020-04-27 14:44 UTC (permalink / raw)
  To: Konstantin Khlebnikov, Brian Gerst, linux-kernel
  Cc: Dominik Brodowski, Andy Lutomirski

Konstantin Khlebnikov <khlebnikov@yandex-team.ru> writes:

> Syscalls without arguments now has no ABI subs, instead of that macro

What is 'ABI subs'? 

> SYSCALL_DEFINE0() defines __abi_sys_name as aliase to __do_sys_name.
>
> As a result in find_syscall_meta() kallsyms_lookup() returns
> "__do_sys_name" which does not match with declared trace event.
>
> Also see commit 1c758a2202a6 ("tracing/x86: Update syscall trace events
> to handle new prefixed syscall func names")
>
> Fixes: d2b5de495ee9 ("x86/entry: Refactor SYSCALL_DEFINE0 macros")
> Signed-off-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
> ---
>  arch/x86/include/asm/ftrace.h |    5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/arch/x86/include/asm/ftrace.h b/arch/x86/include/asm/ftrace.h
> index 85be2f506272..70b96cae5b42 100644
> --- a/arch/x86/include/asm/ftrace.h
> +++ b/arch/x86/include/asm/ftrace.h
> @@ -61,11 +61,12 @@ static inline bool arch_syscall_match_sym_name(const char *sym, const char *name
>  {
>  	/*
>  	 * Compare the symbol name with the system call name. Skip the
> -	 * "__x64_sys", "__ia32_sys" or simple "sys" prefix.
> +	 * "__x64_sys", "__ia32_sys", "__do_sys" or simple "sys" prefix.
>  	 */
>  	return !strcmp(sym + 3, name + 3) ||
>  		(!strncmp(sym, "__x64_", 6) && !strcmp(sym + 9, name + 3)) ||
> -		(!strncmp(sym, "__ia32_", 7) && !strcmp(sym + 10, name + 3));
> +		(!strncmp(sym, "__ia32_", 7) && !strcmp(sym + 10, name + 3)) ||
> +		(!strncmp(sym, "__do_sys", 8) && !strcmp(sym + 8, name + 3));
>  }
>  
>  #ifndef COMPILE_OFFSETS

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

* Re: [PATCH] tracing/x86: fix trace event registration for syscalls without arguments
  2020-04-27 14:44 ` Thomas Gleixner
@ 2020-04-27 14:55   ` Konstantin Khlebnikov
  0 siblings, 0 replies; 6+ messages in thread
From: Konstantin Khlebnikov @ 2020-04-27 14:55 UTC (permalink / raw)
  To: Thomas Gleixner, Brian Gerst, linux-kernel
  Cc: Dominik Brodowski, Andy Lutomirski


On 27/04/2020 17.44, Thomas Gleixner wrote:
> Konstantin Khlebnikov <khlebnikov@yandex-team.ru> writes:
> 
>> Syscalls without arguments now has no ABI subs, instead of that macro
> 
> What is 'ABI subs'?

typo. ABI stubs

That commmit d2b5de495ee9 ("x86/entry: Refactor SYSCALL_DEFINE0 macros")

replaced usual wrapper

long __x64_syscall()
{	
	return __do_sys_syscall();
}

with alias

long __x64_syscall() __alias__(__do_sys_syscall);

And now symbol lookup for entry point return "__do_sys_syscall"
rather than "__x64_syscall" and ftrace magic cannot determine
syscall number for entry point and vise versa.

> 
>> SYSCALL_DEFINE0() defines __abi_sys_name as aliase to __do_sys_name.
>>
>> As a result in find_syscall_meta() kallsyms_lookup() returns
>> "__do_sys_name" which does not match with declared trace event.
>>
>> Also see commit 1c758a2202a6 ("tracing/x86: Update syscall trace events
>> to handle new prefixed syscall func names")
>>
>> Fixes: d2b5de495ee9 ("x86/entry: Refactor SYSCALL_DEFINE0 macros")
>> Signed-off-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
>> ---
>>   arch/x86/include/asm/ftrace.h |    5 +++--
>>   1 file changed, 3 insertions(+), 2 deletions(-)
>>
>> diff --git a/arch/x86/include/asm/ftrace.h b/arch/x86/include/asm/ftrace.h
>> index 85be2f506272..70b96cae5b42 100644
>> --- a/arch/x86/include/asm/ftrace.h
>> +++ b/arch/x86/include/asm/ftrace.h
>> @@ -61,11 +61,12 @@ static inline bool arch_syscall_match_sym_name(const char *sym, const char *name
>>   {
>>   	/*
>>   	 * Compare the symbol name with the system call name. Skip the
>> -	 * "__x64_sys", "__ia32_sys" or simple "sys" prefix.
>> +	 * "__x64_sys", "__ia32_sys", "__do_sys" or simple "sys" prefix.
>>   	 */
>>   	return !strcmp(sym + 3, name + 3) ||
>>   		(!strncmp(sym, "__x64_", 6) && !strcmp(sym + 9, name + 3)) ||
>> -		(!strncmp(sym, "__ia32_", 7) && !strcmp(sym + 10, name + 3));
>> +		(!strncmp(sym, "__ia32_", 7) && !strcmp(sym + 10, name + 3)) ||
>> +		(!strncmp(sym, "__do_sys", 8) && !strcmp(sym + 8, name + 3));
>>   }
>>   
>>   #ifndef COMPILE_OFFSETS

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

* Re: [PATCH] tracing/x86: fix trace event registration for syscalls without arguments
  2020-04-27 13:16 ` Konstantin Khlebnikov
@ 2020-04-27 19:13   ` Steven Rostedt
  0 siblings, 0 replies; 6+ messages in thread
From: Steven Rostedt @ 2020-04-27 19:13 UTC (permalink / raw)
  To: Konstantin Khlebnikov
  Cc: Brian Gerst, linux-kernel, Thomas Gleixner, Dominik Brodowski,
	Andy Lutomirski, Ingo Molnar

On Mon, 27 Apr 2020 16:16:20 +0300
Konstantin Khlebnikov <khlebnikov@yandex-team.ru> wrote:

> Bump, bug still present in 5.7.0-rc3
> 
> root@kernel0:~# uname -r
> 5.7.0-rc3-test
> 
> root@kernel0:~# ls -d /sys/kernel/tracing/events/syscalls/sys_enter_{sync,fsync}
> ls: cannot access '/sys/kernel/tracing/events/syscalls/sys_enter_sync': No such file or directory
> /sys/kernel/tracing/events/syscalls/sys_enter_fsync
> 
> On 08/04/2020 21.13, Konstantin Khlebnikov wrote:
> > Syscalls without arguments now has no ABI subs, instead of that macro
> > SYSCALL_DEFINE0() defines __abi_sys_name as aliase to __do_sys_name.
> > 
> > As a result in find_syscall_meta() kallsyms_lookup() returns
> > "__do_sys_name" which does not match with declared trace event.
> > 
> > Also see commit 1c758a2202a6 ("tracing/x86: Update syscall trace events
> > to handle new prefixed syscall func names")

This is the first I've seen of this patch.

> > 
> > Fixes: d2b5de495ee9 ("x86/entry: Refactor SYSCALL_DEFINE0 macros")
> > Signed-off-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
> > ---
> >   arch/x86/include/asm/ftrace.h |    5 +++--
> >   1 file changed, 3 insertions(+), 2 deletions(-)
> > 
> > diff --git a/arch/x86/include/asm/ftrace.h b/arch/x86/include/asm/ftrace.h
> > index 85be2f506272..70b96cae5b42 100644
> > --- a/arch/x86/include/asm/ftrace.h
> > +++ b/arch/x86/include/asm/ftrace.h
> > @@ -61,11 +61,12 @@ static inline bool arch_syscall_match_sym_name(const char *sym, const char *name
> >   {
> >   	/*
> >   	 * Compare the symbol name with the system call name. Skip the
> > -	 * "__x64_sys", "__ia32_sys" or simple "sys" prefix.
> > +	 * "__x64_sys", "__ia32_sys", "__do_sys" or simple "sys" prefix.
> >   	 */
> >   	return !strcmp(sym + 3, name + 3) ||
> >   		(!strncmp(sym, "__x64_", 6) && !strcmp(sym + 9, name + 3)) ||
> > -		(!strncmp(sym, "__ia32_", 7) && !strcmp(sym + 10, name + 3));
> > +		(!strncmp(sym, "__ia32_", 7) && !strcmp(sym + 10, name + 3)) ||
> > +		(!strncmp(sym, "__do_sys", 8) && !strcmp(sym + 8, name + 3));
> >   }

Acked-by: Steven Rostedt (VMware) <rostedt@goodmis.org>

-- Steve

> >   
> >   #ifndef COMPILE_OFFSETS
> >   


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

* [tip: x86/urgent] ftrace/x86: Fix trace event registration for syscalls without arguments
  2020-04-08 18:13 [PATCH] tracing/x86: fix trace event registration for syscalls without arguments Konstantin Khlebnikov
  2020-04-27 13:16 ` Konstantin Khlebnikov
  2020-04-27 14:44 ` Thomas Gleixner
@ 2020-05-01 18:22 ` tip-bot2 for Konstantin Khlebnikov
  2 siblings, 0 replies; 6+ messages in thread
From: tip-bot2 for Konstantin Khlebnikov @ 2020-05-01 18:22 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Konstantin Khlebnikov, Thomas Gleixner, Steven Rostedt (VMware),
	x86, LKML

The following commit has been merged into the x86/urgent branch of tip:

Commit-ID:     fdc63ff0e49c588884992b4b2656345a5e878b32
Gitweb:        https://git.kernel.org/tip/fdc63ff0e49c588884992b4b2656345a5e878b32
Author:        Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
AuthorDate:    Wed, 08 Apr 2020 21:13:10 +03:00
Committer:     Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Fri, 01 May 2020 19:15:40 +02:00

ftrace/x86: Fix trace event registration for syscalls without arguments

The refactoring of SYSCALL_DEFINE0() macros removed the ABI stubs and
simply defines __abi_sys_$NAME as alias of __do_sys_$NAME.

As a result kallsyms_lookup() returns "__do_sys_$NAME" which does not match
with the declared trace event name.

See also commit 1c758a2202a6 ("tracing/x86: Update syscall trace events to
handle new prefixed syscall func names").

Add __do_sys_ to the valid prefixes which are checked in
arch_syscall_match_sym_name().

Fixes: d2b5de495ee9 ("x86/entry: Refactor SYSCALL_DEFINE0 macros")
Signed-off-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Link: https://lkml.kernel.org/r/158636958997.7900.16485049455470033557.stgit@buzz

---
 arch/x86/include/asm/ftrace.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/x86/include/asm/ftrace.h b/arch/x86/include/asm/ftrace.h
index 85be2f5..70b96ca 100644
--- a/arch/x86/include/asm/ftrace.h
+++ b/arch/x86/include/asm/ftrace.h
@@ -61,11 +61,12 @@ static inline bool arch_syscall_match_sym_name(const char *sym, const char *name
 {
 	/*
 	 * Compare the symbol name with the system call name. Skip the
-	 * "__x64_sys", "__ia32_sys" or simple "sys" prefix.
+	 * "__x64_sys", "__ia32_sys", "__do_sys" or simple "sys" prefix.
 	 */
 	return !strcmp(sym + 3, name + 3) ||
 		(!strncmp(sym, "__x64_", 6) && !strcmp(sym + 9, name + 3)) ||
-		(!strncmp(sym, "__ia32_", 7) && !strcmp(sym + 10, name + 3));
+		(!strncmp(sym, "__ia32_", 7) && !strcmp(sym + 10, name + 3)) ||
+		(!strncmp(sym, "__do_sys", 8) && !strcmp(sym + 8, name + 3));
 }
 
 #ifndef COMPILE_OFFSETS

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

end of thread, other threads:[~2020-05-01 18:23 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-08 18:13 [PATCH] tracing/x86: fix trace event registration for syscalls without arguments Konstantin Khlebnikov
2020-04-27 13:16 ` Konstantin Khlebnikov
2020-04-27 19:13   ` Steven Rostedt
2020-04-27 14:44 ` Thomas Gleixner
2020-04-27 14:55   ` Konstantin Khlebnikov
2020-05-01 18:22 ` [tip: x86/urgent] ftrace/x86: Fix " tip-bot2 for Konstantin Khlebnikov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.