All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sudeep Holla <sudeep.holla@arm.com>
To: "Haibo Xu (Arm Technology China)" <Haibo.Xu@arm.com>
Cc: Steve Capper <Steve.Capper@arm.com>,
	Catalin Marinas <Catalin.Marinas@arm.com>,
	"jdike@addtoit.com" <jdike@addtoit.com>,
	"x86@kernel.org" <x86@kernel.org>,
	Will Deacon <Will.Deacon@arm.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Oleg Nesterov <oleg@redhat.com>,
	Richard Weinberger <richard@nod.at>,
	Ingo Molnar <mingo@redhat.com>, Paul Mackerras <paulus@samba.org>,
	Andy Lutomirski <luto@kernel.org>, Borislav Petkov <bp@alien8.de>,
	Thomas Gleixner <tglx@linutronix.de>,
	"Bin Lu \(Arm Technology China\)" <Bin.Lu@arm.com>,
	"linuxppc-dev@lists.ozlabs.org" <linuxppc-dev@lists.ozlabs.org>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH 3/6] x86: clean up _TIF_SYSCALL_EMU handling using ptrace_syscall_enter hook
Date: Tue, 12 Mar 2019 12:05:29 +0000	[thread overview]
Message-ID: <20190312120529.GA13825@e107155-lin> (raw)
In-Reply-To: <65b00ea1-f784-4fb4-2a98-49fa44d9fa8f@arm.com>

On Tue, Mar 12, 2019 at 01:34:44AM +0000, Haibo Xu (Arm Technology China) wrote:
> On 2019/3/12 2:34, Sudeep Holla wrote:
> > (I thought I had sent this email, last Tuesday itself, but saw this in my
> > draft today, something went wrong, sorry for the delay)
> > 
> > On Tue, Mar 05, 2019 at 02:14:47AM +0000, Haibo Xu (Arm Technology China) wrote:
> >> On 2019/3/4 18:12, Sudeep Holla wrote:
> >>> On Mon, Mar 04, 2019 at 08:25:28AM +0000, Haibo Xu (Arm Technology China) wrote:
> >>>> On 2019/3/1 2:32, Sudeep Holla wrote:
> >>>>> Now that we have a new hook ptrace_syscall_enter that can be called from
> >>>>> syscall entry code and it handles PTRACE_SYSEMU in generic code, we
> >>>>> can do some cleanup using the same in syscall_trace_enter.
> >>>>>
> >>>>> Further the extra logic to find single stepping PTRACE_SYSEMU_SINGLESTEP
> >>>>> in syscall_slow_exit_work seems unnecessary. Let's remove the same.
> >>>>
> >>>> I think we should not change the logic here. Is so, it will double the report of syscall
> >>>> when PTRACE_SYSEMU_SINGLESTEP is enabled.
> >>>>
> >>>
> >>> I don't think that should happen, but I may be missing something.
> >>> Can you explain how ?
> >>>
> >>
> >> When PTRACE_SYSEMU_SINGLESTEP is enabled, both the _TIF_SYSCALL_EMU and
> >> _TIF_SINGLESTEP flags are set, but ptrace only need to report(send SIGTRAP)
> >> at the entry of a system call, no need to report at the exit of a system
> >> call.
> >>
> > Sorry, but I still not get it, we have:
> > 
> > 	step = ((flags & (_TIF_SINGLESTEP | _TIF_SYSCALL_EMU)) == _TIF_SINGLESTEP);
> > 
> > For me, this is same as:
> > 	step = ((flags & _TIF_SINGLESTEP) == _TIF_SINGLESTEP)
> > 	or
> > 	if (flags & _TIF_SINGLESTEP)
> > 		step = true;
> > 
> 
> I don't think so! As I mentioned in the last email loop, when
> PTRACE_SYSEMU_SINGLESTE is enabled, both the _TIF_SYSCALL_EMU and
> _TIF_SINGLESTEP flags are set, in which case the step should be "false" for
> the old logic. But with the new logic, the step is "true".
> 

Ah right, sorry I missed that.

> > So when PTRACE_SYSEMU_SINGLESTEP, _TIF_SYSCALL_EMU and _TIF_SINGLESTEP
> > are set and step evaluates to true.
> > 
> > So dropping _TIF_SYSCALL_EMU here should be fine. Am I still missing
> > something ?
> > 
> > --
> > Regards,
> > Sudeep
> > 
> 
> For the PTRACE_SYSEMU_SINGLESTEP request, ptrace only need to report(send
> SIGTRAP) at the entry of a system call, no need to report at the exit of a
> system call.That's why the old logic-{step = ((flags & (_TIF_SINGLESTEP |
> _TIF_SYSCALL_EMU)) == _TIF_SINGLESTEP)} here try to filter out the special
> case(PTRACE_SYSEMU_SINGLESTEP).
> 

Understood

> Another way to make sure the logic is fine, you can run some tests with
> respect to both logic, and to check whether they have the same behavior.
>

I did run selftests after Andy Lutomirski pointed out. Nothing got flagged,
I haven't looked at the tests themselves yet, but it clearly misses this
case.

--
Regards,
Sudeep

WARNING: multiple messages have this Message-ID (diff)
From: Sudeep Holla <sudeep.holla@arm.com>
To: "Haibo Xu (Arm Technology China)" <Haibo.Xu@arm.com>
Cc: Steve Capper <Steve.Capper@arm.com>,
	Catalin Marinas <Catalin.Marinas@arm.com>,
	"jdike@addtoit.com" <jdike@addtoit.com>,
	"x86@kernel.org" <x86@kernel.org>,
	Will Deacon <Will.Deacon@arm.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Oleg Nesterov <oleg@redhat.com>,
	Richard Weinberger <richard@nod.at>,
	Ingo Molnar <mingo@redhat.com>, Paul Mackerras <paulus@samba.org>,
	Andy Lutomirski <luto@kernel.org>,
	Michael Ellerman <mpe@ellerman.id.au>,
	Borislav Petkov <bp@alien8.de>,
	Thomas Gleixner <tglx@linutronix.de>,
	"Bin Lu \(Arm Technology China\)" <Bin.Lu@arm.com>,
	"linuxppc-dev@lists.ozlabs.org" <linuxppc-dev@lists.ozlabs.org>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH 3/6] x86: clean up _TIF_SYSCALL_EMU handling using ptrace_syscall_enter hook
Date: Tue, 12 Mar 2019 12:05:29 +0000	[thread overview]
Message-ID: <20190312120529.GA13825@e107155-lin> (raw)
In-Reply-To: <65b00ea1-f784-4fb4-2a98-49fa44d9fa8f@arm.com>

On Tue, Mar 12, 2019 at 01:34:44AM +0000, Haibo Xu (Arm Technology China) wrote:
> On 2019/3/12 2:34, Sudeep Holla wrote:
> > (I thought I had sent this email, last Tuesday itself, but saw this in my
> > draft today, something went wrong, sorry for the delay)
> > 
> > On Tue, Mar 05, 2019 at 02:14:47AM +0000, Haibo Xu (Arm Technology China) wrote:
> >> On 2019/3/4 18:12, Sudeep Holla wrote:
> >>> On Mon, Mar 04, 2019 at 08:25:28AM +0000, Haibo Xu (Arm Technology China) wrote:
> >>>> On 2019/3/1 2:32, Sudeep Holla wrote:
> >>>>> Now that we have a new hook ptrace_syscall_enter that can be called from
> >>>>> syscall entry code and it handles PTRACE_SYSEMU in generic code, we
> >>>>> can do some cleanup using the same in syscall_trace_enter.
> >>>>>
> >>>>> Further the extra logic to find single stepping PTRACE_SYSEMU_SINGLESTEP
> >>>>> in syscall_slow_exit_work seems unnecessary. Let's remove the same.
> >>>>
> >>>> I think we should not change the logic here. Is so, it will double the report of syscall
> >>>> when PTRACE_SYSEMU_SINGLESTEP is enabled.
> >>>>
> >>>
> >>> I don't think that should happen, but I may be missing something.
> >>> Can you explain how ?
> >>>
> >>
> >> When PTRACE_SYSEMU_SINGLESTEP is enabled, both the _TIF_SYSCALL_EMU and
> >> _TIF_SINGLESTEP flags are set, but ptrace only need to report(send SIGTRAP)
> >> at the entry of a system call, no need to report at the exit of a system
> >> call.
> >>
> > Sorry, but I still not get it, we have:
> > 
> > 	step = ((flags & (_TIF_SINGLESTEP | _TIF_SYSCALL_EMU)) == _TIF_SINGLESTEP);
> > 
> > For me, this is same as:
> > 	step = ((flags & _TIF_SINGLESTEP) == _TIF_SINGLESTEP)
> > 	or
> > 	if (flags & _TIF_SINGLESTEP)
> > 		step = true;
> > 
> 
> I don't think so! As I mentioned in the last email loop, when
> PTRACE_SYSEMU_SINGLESTE is enabled, both the _TIF_SYSCALL_EMU and
> _TIF_SINGLESTEP flags are set, in which case the step should be "false" for
> the old logic. But with the new logic, the step is "true".
> 

Ah right, sorry I missed that.

> > So when PTRACE_SYSEMU_SINGLESTEP, _TIF_SYSCALL_EMU and _TIF_SINGLESTEP
> > are set and step evaluates to true.
> > 
> > So dropping _TIF_SYSCALL_EMU here should be fine. Am I still missing
> > something ?
> > 
> > --
> > Regards,
> > Sudeep
> > 
> 
> For the PTRACE_SYSEMU_SINGLESTEP request, ptrace only need to report(send
> SIGTRAP) at the entry of a system call, no need to report at the exit of a
> system call.That's why the old logic-{step = ((flags & (_TIF_SINGLESTEP |
> _TIF_SYSCALL_EMU)) == _TIF_SINGLESTEP)} here try to filter out the special
> case(PTRACE_SYSEMU_SINGLESTEP).
> 

Understood

> Another way to make sure the logic is fine, you can run some tests with
> respect to both logic, and to check whether they have the same behavior.
>

I did run selftests after Andy Lutomirski pointed out. Nothing got flagged,
I haven't looked at the tests themselves yet, but it clearly misses this
case.

--
Regards,
Sudeep

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

WARNING: multiple messages have this Message-ID (diff)
From: Sudeep Holla <sudeep.holla@arm.com>
To: "Haibo Xu (Arm Technology China)" <Haibo.Xu@arm.com>
Cc: "x86@kernel.org" <x86@kernel.org>,
	"linux-arm-kernel@lists.infradead.org" 
	<linux-arm-kernel@lists.infradead.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linuxppc-dev@lists.ozlabs.org" <linuxppc-dev@lists.ozlabs.org>,
	Catalin Marinas <Catalin.Marinas@arm.com>,
	Will Deacon <Will.Deacon@arm.com>,
	Oleg Nesterov <oleg@redhat.com>,
	Paul Mackerras <paulus@samba.org>,
	Michael Ellerman <mpe@ellerman.id.au>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>,
	Richard Weinberger <richard@nod.at>,
	"jdike@addtoit.com" <jdike@addtoit.com>,
	Steve Capper <Steve.Capper@arm.com>,
	"Bin Lu (Arm Technology China)" <Bin.Lu@arm.com>,
	Andy Lutomirski <luto@kernel.org>, Borislav Petkov <bp@alien8.de>
Subject: Re: [PATCH 3/6] x86: clean up _TIF_SYSCALL_EMU handling using ptrace_syscall_enter hook
Date: Tue, 12 Mar 2019 12:05:29 +0000	[thread overview]
Message-ID: <20190312120529.GA13825@e107155-lin> (raw)
In-Reply-To: <65b00ea1-f784-4fb4-2a98-49fa44d9fa8f@arm.com>

On Tue, Mar 12, 2019 at 01:34:44AM +0000, Haibo Xu (Arm Technology China) wrote:
> On 2019/3/12 2:34, Sudeep Holla wrote:
> > (I thought I had sent this email, last Tuesday itself, but saw this in my
> > draft today, something went wrong, sorry for the delay)
> > 
> > On Tue, Mar 05, 2019 at 02:14:47AM +0000, Haibo Xu (Arm Technology China) wrote:
> >> On 2019/3/4 18:12, Sudeep Holla wrote:
> >>> On Mon, Mar 04, 2019 at 08:25:28AM +0000, Haibo Xu (Arm Technology China) wrote:
> >>>> On 2019/3/1 2:32, Sudeep Holla wrote:
> >>>>> Now that we have a new hook ptrace_syscall_enter that can be called from
> >>>>> syscall entry code and it handles PTRACE_SYSEMU in generic code, we
> >>>>> can do some cleanup using the same in syscall_trace_enter.
> >>>>>
> >>>>> Further the extra logic to find single stepping PTRACE_SYSEMU_SINGLESTEP
> >>>>> in syscall_slow_exit_work seems unnecessary. Let's remove the same.
> >>>>
> >>>> I think we should not change the logic here. Is so, it will double the report of syscall
> >>>> when PTRACE_SYSEMU_SINGLESTEP is enabled.
> >>>>
> >>>
> >>> I don't think that should happen, but I may be missing something.
> >>> Can you explain how ?
> >>>
> >>
> >> When PTRACE_SYSEMU_SINGLESTEP is enabled, both the _TIF_SYSCALL_EMU and
> >> _TIF_SINGLESTEP flags are set, but ptrace only need to report(send SIGTRAP)
> >> at the entry of a system call, no need to report at the exit of a system
> >> call.
> >>
> > Sorry, but I still not get it, we have:
> > 
> > 	step = ((flags & (_TIF_SINGLESTEP | _TIF_SYSCALL_EMU)) == _TIF_SINGLESTEP);
> > 
> > For me, this is same as:
> > 	step = ((flags & _TIF_SINGLESTEP) == _TIF_SINGLESTEP)
> > 	or
> > 	if (flags & _TIF_SINGLESTEP)
> > 		step = true;
> > 
> 
> I don't think so! As I mentioned in the last email loop, when
> PTRACE_SYSEMU_SINGLESTE is enabled, both the _TIF_SYSCALL_EMU and
> _TIF_SINGLESTEP flags are set, in which case the step should be "false" for
> the old logic. But with the new logic, the step is "true".
> 

Ah right, sorry I missed that.

> > So when PTRACE_SYSEMU_SINGLESTEP, _TIF_SYSCALL_EMU and _TIF_SINGLESTEP
> > are set and step evaluates to true.
> > 
> > So dropping _TIF_SYSCALL_EMU here should be fine. Am I still missing
> > something ?
> > 
> > --
> > Regards,
> > Sudeep
> > 
> 
> For the PTRACE_SYSEMU_SINGLESTEP request, ptrace only need to report(send
> SIGTRAP) at the entry of a system call, no need to report at the exit of a
> system call.That's why the old logic-{step = ((flags & (_TIF_SINGLESTEP |
> _TIF_SYSCALL_EMU)) == _TIF_SINGLESTEP)} here try to filter out the special
> case(PTRACE_SYSEMU_SINGLESTEP).
> 

Understood

> Another way to make sure the logic is fine, you can run some tests with
> respect to both logic, and to check whether they have the same behavior.
>

I did run selftests after Andy Lutomirski pointed out. Nothing got flagged,
I haven't looked at the tests themselves yet, but it clearly misses this
case.

--
Regards,
Sudeep

  parent reply	other threads:[~2019-03-12 12:09 UTC|newest]

Thread overview: 78+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-28 18:32 [PATCH 0/6] ptrace: consolidate PTRACE_SYSEMU handling and add support for arm64 Sudeep Holla
2019-02-28 18:32 ` Sudeep Holla
2019-02-28 18:32 ` Sudeep Holla
2019-02-28 18:32 ` [PATCH 1/6] ptrace: move clearing of TIF_SYSCALL_EMU flag to core Sudeep Holla
2019-02-28 18:32   ` Sudeep Holla
2019-02-28 18:32   ` Sudeep Holla
2019-02-28 18:32 ` [PATCH 2/6] ptrace: introduce ptrace_syscall_enter to consolidate PTRACE_SYSEMU handling Sudeep Holla
2019-02-28 18:32   ` Sudeep Holla
2019-02-28 18:32   ` Sudeep Holla
2019-03-04  8:03   ` Haibo Xu (Arm Technology China)
2019-03-04  8:03     ` Haibo Xu (Arm Technology China)
2019-03-04  8:03     ` Haibo Xu (Arm Technology China)
2019-03-04 10:46     ` Sudeep Holla
2019-03-04 10:46       ` Sudeep Holla
2019-03-04 10:46       ` Sudeep Holla
2019-03-04 12:23       ` Segher Boessenkool
2019-03-04 12:23         ` Segher Boessenkool
2019-03-04 12:23         ` Segher Boessenkool
2019-03-04 12:27         ` Sudeep Holla
2019-03-04 12:27           ` Sudeep Holla
2019-03-04 12:27           ` Sudeep Holla
2019-02-28 18:32 ` [PATCH 3/6] x86: clean up _TIF_SYSCALL_EMU handling using ptrace_syscall_enter hook Sudeep Holla
2019-02-28 18:32   ` Sudeep Holla
2019-02-28 18:32   ` Sudeep Holla
2019-03-03  1:11   ` Andy Lutomirski
2019-03-03  1:11     ` Andy Lutomirski
2019-03-03  1:11     ` Andy Lutomirski
2019-03-04 10:07     ` Sudeep Holla
2019-03-04 10:07       ` Sudeep Holla
2019-03-04 10:07       ` Sudeep Holla
2019-03-04  8:25   ` Haibo Xu (Arm Technology China)
2019-03-04  8:25     ` Haibo Xu (Arm Technology China)
2019-03-04  8:25     ` Haibo Xu (Arm Technology China)
2019-03-04 10:12     ` Sudeep Holla
2019-03-04 10:12       ` Sudeep Holla
2019-03-04 10:12       ` Sudeep Holla
2019-03-05  2:14       ` Haibo Xu (Arm Technology China)
2019-03-05  2:14         ` Haibo Xu (Arm Technology China)
2019-03-05  2:14         ` Haibo Xu (Arm Technology China)
2019-03-11 18:34         ` Sudeep Holla
2019-03-11 18:34           ` Sudeep Holla
2019-03-11 18:34           ` Sudeep Holla
2019-03-12  1:34           ` Haibo Xu (Arm Technology China)
2019-03-12  1:34             ` Haibo Xu (Arm Technology China)
2019-03-12  1:34             ` Haibo Xu (Arm Technology China)
2019-03-12  3:04             ` Andy Lutomirski
2019-03-12  3:04               ` Andy Lutomirski
2019-03-12  3:04               ` Andy Lutomirski
2019-03-12 12:09               ` Sudeep Holla
2019-03-12 12:09                 ` Sudeep Holla
2019-03-12 12:09                 ` Sudeep Holla
2019-03-13  1:03                 ` Haibo Xu (Arm Technology China)
2019-03-13  1:03                   ` Haibo Xu (Arm Technology China)
2019-03-13  1:03                   ` Haibo Xu (Arm Technology China)
2019-03-14 10:51                   ` Sudeep Holla
2019-03-14 10:51                     ` Sudeep Holla
2019-03-14 10:51                     ` Sudeep Holla
2019-03-15  5:48                     ` Haibo Xu (Arm Technology China)
2019-03-15  5:48                       ` Haibo Xu (Arm Technology China)
2019-03-15  5:48                       ` Haibo Xu (Arm Technology China)
2019-03-12 12:05             ` Sudeep Holla [this message]
2019-03-12 12:05               ` Sudeep Holla
2019-03-12 12:05               ` Sudeep Holla
2019-02-28 18:32 ` [PATCH 4/6] powerpc: use common ptrace_syscall_enter hook to handle _TIF_SYSCALL_EMU Sudeep Holla
2019-02-28 18:32   ` Sudeep Holla
2019-02-28 18:32   ` Sudeep Holla
2019-03-04  9:36   ` Haibo Xu (Arm Technology China)
2019-03-04  9:36     ` Haibo Xu (Arm Technology China)
2019-03-04  9:36     ` Haibo Xu (Arm Technology China)
2019-03-04 10:42     ` Sudeep Holla
2019-03-04 10:42       ` Sudeep Holla
2019-03-04 10:42       ` Sudeep Holla
2019-02-28 18:32 ` [PATCH 5/6] arm64: add PTRACE_SYSEMU{, SINGLESTEP} definations to uapi headers Sudeep Holla
2019-02-28 18:32   ` [PATCH 5/6] arm64: add PTRACE_SYSEMU{,SINGLESTEP} " Sudeep Holla
2019-02-28 18:32   ` [PATCH 5/6] arm64: add PTRACE_SYSEMU{, SINGLESTEP} " Sudeep Holla
2019-02-28 18:32 ` [PATCH 6/6] arm64: ptrace: add support for syscall emulation Sudeep Holla
2019-02-28 18:32   ` Sudeep Holla
2019-02-28 18:32   ` Sudeep Holla

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=20190312120529.GA13825@e107155-lin \
    --to=sudeep.holla@arm.com \
    --cc=Bin.Lu@arm.com \
    --cc=Catalin.Marinas@arm.com \
    --cc=Haibo.Xu@arm.com \
    --cc=Steve.Capper@arm.com \
    --cc=Will.Deacon@arm.com \
    --cc=bp@alien8.de \
    --cc=jdike@addtoit.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=luto@kernel.org \
    --cc=mingo@redhat.com \
    --cc=oleg@redhat.com \
    --cc=paulus@samba.org \
    --cc=richard@nod.at \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.