tracing/x86: fix trace event registration for syscalls without arguments
PATCH 1/1 tracing/x86: fix trace event registration for syscalls without arguments
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")
--- arch/x86/include/asm/ftrace.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
arch/x86/include/asm/ftrace.h +3 -2
@@ -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
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_fsyncQuoted 35 lines · Konstantin Khlebnikov
Syscalls without arguments now has no ABI subs, instead of that macro
SYSCALL_DEFINE0()defines__abi_sys_nameas 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 <[email protected]>--- arch/x86/include/asm/ftrace.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)arch/x86/include/asm/ftrace.h +3
-2@@ -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
Quoted 18 lines · On Mon, 27 Apr 2020 16:16:20 +0300 Konstantin Khlebnikov…
Bump, bug still present in 5.7.0-rc3
root@kernel0:~# uname -r 5.7.0-rc3-testroot@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_fsyncQuoted 8 lines · Konstantin Khlebnikov
Syscalls without arguments now has no ABI subs, instead of that macro
SYSCALL_DEFINE0()defines__abi_sys_nameas 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.
Quoted 16 lines
Quoted 16 lines
Fixes d2b5de495ee9 ("x86/entry: Refactor SYSCALL_DEFINE0 macros")Signed-off-by Konstantin Khlebnikov <[email protected]>--- arch/x86/include/asm/ftrace.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)arch/x86/include/asm/ftrace.h +0
-1@@ -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.
Quoted 8 lines
arch/x86/include/asm/ftrace.h static inline bool arch_syscall_match_sym_name(const char *sym, const char *name · line 70
Quoted 8 lines
arch/x86/include/asm/ftrace.h +3
-1+* "__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 )); }
-- Steve
Quoted 3 lines
Quoted 3 lines
arch/x86/include/asm/ftrace.h +0
-0#ifndef COMPILE_OFFSETS
Quoted 1 line · Konstantin Khlebnikov
Syscalls without arguments now has no ABI subs, instead of that macro
What is 'ABI subs'?
Quoted 33 lines
SYSCALL_DEFINE0()defines__abi_sys_nameas 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 <[email protected]>--- arch/x86/include/asm/ftrace.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)arch/x86/include/asm/ftrace.h +3
-2@@ -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
Quoted 5 lines · Thomas Gleixner
Quoted 1 line · Konstantin Khlebnikov
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.
Quoted 34 lines
Quoted 34 lines
SYSCALL_DEFINE0()defines__abi_sys_nameas 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 <[email protected]>--- arch/x86/include/asm/ftrace.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)arch/x86/include/asm/ftrace.h +3
-2@@ -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
[tip: x86/urgent] ftrace/x86: Fix trace event registration for syscalls without arguments
In reply to Konstantin KhlebnikovThe following commit has been merged into the x86/urgent branch of tip:
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 <[email protected]> AuthorDate: Wed, 08 Apr 2020 21:13:10 +03:00 Committer: Thomas Gleixner <[email protected]> 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().
--- arch/x86/include/asm/ftrace.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
arch/x86/include/asm/ftrace.h +3 -2
@@ -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