* [PATCH v2 0/1] Remove forget_syscall() from start_thread_common()
@ 2022-06-08 16:24 Francis Laniel
2022-06-23 14:09 ` Francis Laniel
2022-07-01 15:41 ` Will Deacon
0 siblings, 2 replies; 4+ messages in thread
From: Francis Laniel @ 2022-06-08 16:24 UTC (permalink / raw)
To: linux-trace-devel
Cc: James Morse, Daniel Kiss, Francis Laniel, Catalin Marinas,
Will Deacon, Paul Walmsley, Palmer Dabbelt, Albert Ou, Mark Brown,
Peter Collingbourne, Kees Cook, Mark Rutland, Christophe Leroy,
linux-arm-kernel, linux-kernel, linux-riscv
Hi.
First, I hope you are fine and the same for your relatives.
With this contribution, I enabled using syscalls:sys_exit_execve and
syscalls:sys_exit_execveat as tracepoints on arm64.
Indeed, before this contribution, the above tracepoint would not print their
information as syscall number was set to -1 by calling forget_syscall().
I tested it by compiling a kernel for arm64 and running it within a VM:
# Perf was compiled with linux kernel source.
root@vm-arm64:~# perf record -ag -e 'syscalls:sys_exit_execve' -e 'syscalls:sys_enter_execve' &
[1] 263
root@vm-arm64:~# ls
perf.data share
root@vm-arm64:~# fg
perf record -ag -e 'syscalls:sys_exit_execve' -e 'syscalls:sys_enter_execve'
^C[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.061 MB perf.data (2 samples) ]
root@vm-arm64:~# perf script
bash 264 [000] 66.220187: syscalls:sys_enter_execve: filename: 0xaaab05d9d
...
# Below line does not appear without this patch.
ls 264 [000] 66.226848: syscalls:sys_exit_execve: 0x0
...
Forgetting the syscall number before starting a new thread was confirmed to be
a bug [1].
Particularly, the following architectures do not forget the syscall number
before starting a new thread:
* arm (32 bits) EABI: start_thread() sets r7 to previous r7 for ELF FDPIC and
to 0 for other binfmts [2].
* arm (32 bits) OABI: syscall number is set to -1 if
ptrace_report_syscall_entry() failed [3].
* mips: start_thread() does not modify current_thread_info->syscall which is
taken directly from v0 [4, 5].
* riscv: start_thread() does not modify a7 [6].
* x86_64: start_thread_common() does not touch orig_ax which seems to contain
the syscall number [7].
If you see any way to improve this contribution, feel free to share!
Change since:
v1:
* Remove call to forget_syscall() and store previous syscall number in
regs->syscallno unconditionnaly.
Francis Laniel (1):
arm64: Do not forget syscall when starting a new thread.
arch/arm64/include/asm/processor.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
Best regards and thank you in advance.
---
[1] https://lore.kernel.org/linux-arm-kernel/YoT1iLPEbteRTQGZ@arm.com/
[2] https://elixir.bootlin.com/linux/v5.18-rc6/source/arch/arm/include/asm/
processor.h#L52
[3] https://elixir.bootlin.com/linux/v5.18-rc6/source/arch/arm/kernel/
ptrace.c#L847
[4] https://elixir.bootlin.com/linux/v5.18-rc6/source/arch/mips/kernel/
process.c#L52
[5] https://elixir.bootlin.com/linux/v5.18-rc6/source/arch/mips/kernel/
scall64-n64.S#L85
[6] https://elixir.bootlin.com/linux/v5.18-rc6/source/arch/riscv/kernel/
process.c#L87
[7] https://elixir.bootlin.com/linux/v5.18-rc6/source/arch/x86/kernel/
process_64.c#L505
--
2.25.1
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2 0/1] Remove forget_syscall() from start_thread_common()
2022-06-08 16:24 [PATCH v2 0/1] Remove forget_syscall() from start_thread_common() Francis Laniel
@ 2022-06-23 14:09 ` Francis Laniel
2022-07-01 15:41 ` Will Deacon
1 sibling, 0 replies; 4+ messages in thread
From: Francis Laniel @ 2022-06-23 14:09 UTC (permalink / raw)
To: linux-trace-devel
Cc: James Morse, Daniel Kiss, Catalin Marinas, Will Deacon,
Paul Walmsley, Palmer Dabbelt, Albert Ou, Mark Brown,
Peter Collingbourne, Kees Cook, Mark Rutland, Christophe Leroy,
linux-arm-kernel, linux-kernel, linux-riscv
Hi.
Le mercredi 8 juin 2022, 18:24:45 CEST Francis Laniel a écrit :
> Hi.
>
>
> First, I hope you are fine and the same for your relatives.
>
> With this contribution, I enabled using syscalls:sys_exit_execve and
> syscalls:sys_exit_execveat as tracepoints on arm64.
> Indeed, before this contribution, the above tracepoint would not print their
> information as syscall number was set to -1 by calling forget_syscall().
>
> I tested it by compiling a kernel for arm64 and running it within a VM:
> # Perf was compiled with linux kernel source.
> root@vm-arm64:~# perf record -ag -e 'syscalls:sys_exit_execve' -e
> 'syscalls:sys_enter_execve' & [1] 263
> root@vm-arm64:~# ls
> perf.data share
> root@vm-arm64:~# fg
> perf record -ag -e 'syscalls:sys_exit_execve' -e 'syscalls:sys_enter_execve'
> ^C[ perf record: Woken up 1 times to write data ]
> [ perf record: Captured and wrote 0.061 MB perf.data (2 samples) ]
> root@vm-arm64:~# perf script
> bash 264 [000] 66.220187: syscalls:sys_enter_execve: filename:
> 0xaaab05d9d ...
> # Below line does not appear without this patch.
> ls 264 [000] 66.226848: syscalls:sys_exit_execve: 0x0
> ...
>
> Forgetting the syscall number before starting a new thread was confirmed to
> be a bug [1].
> Particularly, the following architectures do not forget the syscall number
> before starting a new thread:
> * arm (32 bits) EABI: start_thread() sets r7 to previous r7 for ELF FDPIC
> and to 0 for other binfmts [2].
> * arm (32 bits) OABI: syscall number is set to -1 if
> ptrace_report_syscall_entry() failed [3].
> * mips: start_thread() does not modify current_thread_info->syscall which is
> taken directly from v0 [4, 5].
> * riscv: start_thread() does not modify a7 [6].
> * x86_64: start_thread_common() does not touch orig_ax which seems to
> contain the syscall number [7].
>
> If you see any way to improve this contribution, feel free to share!
>
> Change since:
> v1:
> * Remove call to forget_syscall() and store previous syscall number in
> regs->syscallno unconditionnaly.
>
> Francis Laniel (1):
> arm64: Do not forget syscall when starting a new thread.
>
> arch/arm64/include/asm/processor.h | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
>
> Best regards and thank you in advance.
> ---
> [1] https://lore.kernel.org/linux-arm-kernel/YoT1iLPEbteRTQGZ@arm.com/
> [2] https://elixir.bootlin.com/linux/v5.18-rc6/source/arch/arm/include/asm/
> processor.h#L52
> [3] https://elixir.bootlin.com/linux/v5.18-rc6/source/arch/arm/kernel/
> ptrace.c#L847
> [4] https://elixir.bootlin.com/linux/v5.18-rc6/source/arch/mips/kernel/
> process.c#L52
> [5] https://elixir.bootlin.com/linux/v5.18-rc6/source/arch/mips/kernel/
> scall64-n64.S#L85
> [6] https://elixir.bootlin.com/linux/v5.18-rc6/source/arch/riscv/kernel/
> process.c#L87
> [7] https://elixir.bootlin.com/linux/v5.18-rc6/source/arch/x86/kernel/
> process_64.c#L505
Can someone please take a quick look at this patch?
Best regards and thank you in advance.
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2 0/1] Remove forget_syscall() from start_thread_common()
2022-06-08 16:24 [PATCH v2 0/1] Remove forget_syscall() from start_thread_common() Francis Laniel
2022-06-23 14:09 ` Francis Laniel
@ 2022-07-01 15:41 ` Will Deacon
2022-07-04 8:55 ` Francis Laniel
1 sibling, 1 reply; 4+ messages in thread
From: Will Deacon @ 2022-07-01 15:41 UTC (permalink / raw)
To: linux-trace-devel, Francis Laniel
Cc: catalin.marinas, kernel-team, Will Deacon, Palmer Dabbelt,
Peter Collingbourne, Mark Brown, Paul Walmsley, Christophe Leroy,
linux-arm-kernel, Mark Rutland, Kees Cook, Daniel Kiss,
linux-riscv, linux-kernel, James Morse, Albert Ou
On Wed, 8 Jun 2022 17:24:45 +0100, Francis Laniel wrote:
> First, I hope you are fine and the same for your relatives.
>
> With this contribution, I enabled using syscalls:sys_exit_execve and
> syscalls:sys_exit_execveat as tracepoints on arm64.
> Indeed, before this contribution, the above tracepoint would not print their
> information as syscall number was set to -1 by calling forget_syscall().
>
> [...]
Applied to arm64 (for-next/misc), thanks!
[1/1] arm64: Do not forget syscall when starting a new thread.
https://git.kernel.org/arm64/c/de6921856f99
Cheers,
--
Will
https://fixes.arm64.dev
https://next.arm64.dev
https://will.arm64.dev
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2 0/1] Remove forget_syscall() from start_thread_common()
2022-07-01 15:41 ` Will Deacon
@ 2022-07-04 8:55 ` Francis Laniel
0 siblings, 0 replies; 4+ messages in thread
From: Francis Laniel @ 2022-07-04 8:55 UTC (permalink / raw)
To: linux-trace-devel, Will Deacon
Cc: catalin.marinas, kernel-team, Will Deacon, Palmer Dabbelt,
Peter Collingbourne, Mark Brown, Paul Walmsley, Christophe Leroy,
linux-arm-kernel, Mark Rutland, Kees Cook, Daniel Kiss,
linux-riscv, linux-kernel, James Morse, Albert Ou
Hi.
Le vendredi 1 juillet 2022, 17:41:28 CEST Will Deacon a écrit :
> On Wed, 8 Jun 2022 17:24:45 +0100, Francis Laniel wrote:
> > First, I hope you are fine and the same for your relatives.
> >
> > With this contribution, I enabled using syscalls:sys_exit_execve and
> > syscalls:sys_exit_execveat as tracepoints on arm64.
> > Indeed, before this contribution, the above tracepoint would not print
> > their information as syscall number was set to -1 by calling
> > forget_syscall().
> >
> > [...]
>
> Applied to arm64 (for-next/misc), thanks!
Thank you for the merge!
> [1/1] arm64: Do not forget syscall when starting a new thread.
> https://git.kernel.org/arm64/c/de6921856f99
>
> Cheers,
Best regards.
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-07-04 8:56 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-08 16:24 [PATCH v2 0/1] Remove forget_syscall() from start_thread_common() Francis Laniel
2022-06-23 14:09 ` Francis Laniel
2022-07-01 15:41 ` Will Deacon
2022-07-04 8:55 ` Francis Laniel
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).