[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <VI1PR08MB28629CB1D6C8F9BDFBD101D099B60@VI1PR08MB2862.eurprd08.prod.outlook.com>
Date: Wed, 20 May 2020 10:07:21 +0000
From: Bin Lu <Bin.Lu@....com>
To: Catalin Marinas <Catalin.Marinas@....com>,
Will Deacon <will@...nel.org>
CC: Will Deacon <Will.Deacon@....com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"oleg@...hat.com" <oleg@...hat.com>,
Keno Fischer <keno@...iacomputing.com>,
Sudeep Holla <Sudeep.Holla@....com>,
"linux-arm-kernel@...ts.infradead.org"
<linux-arm-kernel@...ts.infradead.org>
Subject: 回复: [PATCH] arm64: Fix PTRACE_SYSEMU semantics
Tested-by: Bin Lu <bin.lu@....com >
I have just tested all gVisor syscall test cases with ptrace(Regs, FPRegs, TLS) on Arm64 platform.
The test results are the same as before there was no patch.
My idea is that this kernel patch has no bad effects on gVisor.
Linux Kernel version: 5.7.0-rc6+
gVisor version: release-20200511.0
> -----邮件原件-----
> 发件人: linux-arm-kernel <linux-arm-kernel-bounces@...ts.infradead.org> 代
> 表 Catalin Marinas
> 发送时间: 2020年5月19日 20:07
> 收件人: Will Deacon <will@...nel.org>
> 抄送: Will Deacon <Will.Deacon@....com>; linux-kernel@...r.kernel.org;
> oleg@...hat.com; Keno Fischer <keno@...iacomputing.com>; Sudeep Holla
> <Sudeep.Holla@....com>; linux-arm-kernel@...ts.infradead.org
> 主题: Re: [PATCH] arm64: Fix PTRACE_SYSEMU semantics
>
> On Mon, May 18, 2020 at 12:41:20PM +0100, Will Deacon wrote:
> > On Fri, May 15, 2020 at 06:22:53PM -0400, Keno Fischer wrote:
> > > Quoth the man page:
> > > ```
> > > If the tracee was restarted by PTRACE_SYSCALL or PTRACE_SYSEMU,
> the
> > > tracee enters syscall-enter-stop just prior to entering any system
> > > call (which will not be executed if the restart was using
> > > PTRACE_SYSEMU, regardless of any change made to registers at this
> > > point or how the tracee is restarted after this stop).
> > > ```
> > >
> > > The parenthetical comment is currently true on x86 and powerpc, but
> > > not currently true on arm64. arm64 re-checks the _TIF_SYSCALL_EMU
> > > flag after the syscall entry ptrace stop. However, at this point, it
> > > reflects which method was used to re-start the syscall at the entry
> > > stop, rather than the method that was used to reach it.
> > > Fix that by recording the original flag before performing the ptrace
> > > stop, bringing the behavior in line with documentation and x86/powerpc.
> > >
> > > Signed-off-by: Keno Fischer <keno@...iacomputing.com>
> > > ---
> > > arch/arm64/kernel/ptrace.c | 8 +++++---
> > > 1 file changed, 5 insertions(+), 3 deletions(-)
> > >
> > > diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c
> > > index b3d3005d9515..b67b4d14aa17 100644
> > > --- a/arch/arm64/kernel/ptrace.c
> > > +++ b/arch/arm64/kernel/ptrace.c
> > > @@ -1829,10 +1829,12 @@ static void tracehook_report_syscall(struct
> > > pt_regs *regs,
> > >
> > > int syscall_trace_enter(struct pt_regs *regs) {
> > > - if (test_thread_flag(TIF_SYSCALL_TRACE) ||
> > > - test_thread_flag(TIF_SYSCALL_EMU)) {
> > > + u32 flags = READ_ONCE(current_thread_info()->flags) &
> > > + (_TIF_SYSCALL_EMU | _TIF_SYSCALL_TRACE);
> > > +
> > > + if (flags) {
> >
> > nit: but I'd rather the '&' operation was in the conditional so that
> > the 'flags' variable holds all of the flags.
> >
> > With that:
> >
> > Acked-by: Will Deacon <will@...nel.org>
> >
> > Also needs:
> >
> > Cc: <stable@...r.kernel.org>
> > Fixes: f086f67485c5 ("arm64: ptrace: add support for syscall
> > emulation")
> >
> > Catalin -- can you pick this up for 5.7 please, with my 'nit' addressed?
>
> I'll queue it with the above addressed. I think flags also needs to be unsigned
> long rather than u32.
>
> However, before sending the pull request, I'd like Sudeep to confirm that it
> doesn't break his original use-case for this feature.
>
> --
> Catalin
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@...ts.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Powered by blists - more mailing lists