Re: [PATCH v2 1/1] arm64: Do not forget syscall when starting a new thread.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi.

Le mardi 28 juin 2022, 15:58:35 CEST Will Deacon a écrit :
> On Wed, Jun 08, 2022 at 05:24:46PM +0100, Francis Laniel wrote:
> > This patch enables exeve*() to be traced with syscalls:sys_exit_execve
> > tracepoint.
> > Previous to it, by calling forget_syscall(), this tracepoint would not
> > print its information as syscall is -1.
> > So, this patch removes call to forget_syscall() and set regs->syscallno
> > to its previous value.
> > 
> > Signed-off-by: Francis Laniel <flaniel@xxxxxxxxxxxxxxxxxxx>
> > ---
> > 
> >  arch/arm64/include/asm/processor.h | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/arch/arm64/include/asm/processor.h
> > b/arch/arm64/include/asm/processor.h index 9e58749db21d..86eb0bfe3b38
> > 100644
> > --- a/arch/arm64/include/asm/processor.h
> > +++ b/arch/arm64/include/asm/processor.h
> > @@ -272,8 +272,9 @@ void tls_preserve_current_state(void);
> > 
> >  static inline void start_thread_common(struct pt_regs *regs, unsigned
> >  long pc) {
> > 
> > +	s32 previous_syscall = regs->syscallno;
> > 
> >  	memset(regs, 0, sizeof(*regs));
> > 
> > -	forget_syscall(regs);
> > +	regs->syscallno = previous_syscall;
> 
> I'm still unsure about this. Even if we preserve the syscall number here,
> won't all the arguments be reported as 0?

I am not really sure what you meant about arguments, can you please precise 
between command line arguments (ls -al) and syscall arguments (argp, envp, 
etc.)?
Indeed, if my understanding is correct syscall arguments are showed by 
sys_enter_* while sys_exit_* only reports the syscall return code.

Regarding the return code I think the value is correct as it is used in 
syscall_trace_exit() but set in invoke_syscall() after the syscall finishes [1, 
2].
The comparison of arm64 and amd64 output also shows no difference:
# amd64
ls 435739 [002] 24689.292479:  syscalls:sys_exit_execve: 0x0
            7fc43732e100 _start+0x0 (/usr/lib/x86_64-linux-gnu/ld-2.31.so)
# arm64
ls   266 [000]    34.708444:  syscalls:sys_exit_execve: 0x0
                    1140 [unknown] (/usr/lib/aarch64-linux-gnu/ld-2.31.so)
 
> I also looked quickly at the 32-bit arch/arm/ code and it looks like the
> same behaviour exists there (module CONFIG_BINFMT_ELF_FDPIC).

I can try to fix it for this architecture too.
Can you please point me the part of the code which shows the same behavior?
 
> Will


Best regards.
---
[1] https://elixir.bootlin.com/linux/v5.18/source/arch/arm64/kernel/
ptrace.c#L1868
[2] https://elixir.bootlin.com/linux/v5.18/source/arch/arm64/kernel/
syscall.c#L57






[Index of Archives]     [Linux USB Development]     [Linux USB Development]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux