From: Will Deacon <will@kernel.org>
To: Francis Laniel <flaniel@linux.microsoft.com>
Cc: linux-trace-devel@vger.kernel.org,
James Morse <james.morse@arm.com>,
Daniel Kiss <daniel.kiss@arm.com>,
Catalin Marinas <catalin.marinas@arm.com>,
Mark Brown <broonie@kernel.org>,
Peter Collingbourne <pcc@google.com>,
Kees Cook <keescook@chromium.org>,
Mark Rutland <mark.rutland@arm.com>,
Christophe Leroy <christophe.leroy@csgroup.eu>,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/1] arm64: Do not forget syscall when starting a new thread.
Date: Fri, 1 Jul 2022 12:36:32 +0100 [thread overview]
Message-ID: <20220701113631.GC28070@willie-the-truck> (raw)
In-Reply-To: <4722000.GXAFRqVoOG@pwmachine>
On Thu, Jun 30, 2022 at 07:16:44PM +0200, Francis Laniel wrote:
> Hi.
>
> Le mardi 28 juin 2022, 21:26:32 CEST Francis Laniel a écrit :
> > 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@linux.microsoft.com>
> > > > ---
> > > >
> > > > 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 tested arm32 and it is not affected (even though I did not have
> CONFIG_BINFMT_ELF_FDPIC set).
> Here is ftrace output for arm64 without this patch:
> bash-316 [000] ..... 72.167342: sys_execve(filename:
> aaaaf9bbcd30, argv: aaaaf9bb54f0, envp: aaaaf9a7d9b0)
> Here is the output for arm64 with this patch:
> cat-313 [000] ..... 417.926073: sys_execve(filename:
> aaaaee7ce9f0, argv: aaaaee7833a0, envp: aaaaee6a69b0)
> cat-313 [000] ..... 417.939619: sys_execve -> 0x0
> And here is output for arm32:
> cat-254 [000] ..... 127.804128: sys_execve(filename: 5bff18,
> argv: 53bb00, envp: 5543a8)
> cat-254 [000] ..... 127.809142: sys_execve -> 0x0
> From the above, the arm32 output seems correct even though:
> # CONFIG_BINFMT_ELF_FDPIC is not set
>
> After some debugging, I realized that arm32 syscall_get_nr() uses abi_syscall
> to get the syscall number and not a register (I guess abi_syscall was set to
> value of R7 before) [1].
> So the fact that regs->uregs are memset'ed to 0 is not a problem.
Thanks for confirming this, I'll go ahead and queue your patch and let's
hope nothing breaks :)
Will
next prev parent reply other threads:[~2022-07-01 11:36 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-08 16:24 [PATCH v2 0/1] Remove forget_syscall() from start_thread_common() Francis Laniel
2022-06-08 16:24 ` [PATCH v2 1/1] arm64: Do not forget syscall when starting a new thread Francis Laniel
2022-06-28 13:58 ` Will Deacon
2022-06-28 19:26 ` Francis Laniel
2022-06-30 17:16 ` Francis Laniel
2022-07-01 11:36 ` Will Deacon [this message]
2022-07-01 12:10 ` Francis Laniel
2022-06-23 14:09 ` [PATCH v2 0/1] Remove forget_syscall() from start_thread_common() Francis Laniel
2022-07-01 15:41 ` Will Deacon
2022-07-04 8:55 ` Francis Laniel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220701113631.GC28070@willie-the-truck \
--to=will@kernel.org \
--cc=broonie@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=christophe.leroy@csgroup.eu \
--cc=daniel.kiss@arm.com \
--cc=flaniel@linux.microsoft.com \
--cc=james.morse@arm.com \
--cc=keescook@chromium.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-devel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=pcc@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).