diff mbox series

[v3,1/4] ptrace: move clearing of TIF_SYSCALL_EMU flag to core

Message ID 20190430170520.29470-2-sudeep.holla@arm.com
State Superseded
Headers show
Series ptrace: cleanup PTRACE_SYSEMU handling and add support for arm64 | expand

Commit Message

Sudeep Holla April 30, 2019, 5:05 p.m. UTC
While the TIF_SYSCALL_EMU is set in ptrace_resume independent of any
architecture, currently only powerpc and x86 unset the TIF_SYSCALL_EMU
flag in ptrace_disable which gets called from ptrace_detach.

Let's move the clearing of TIF_SYSCALL_EMU flag to __ptrace_unlink
which gets executed from ptrace_detach and also keep it along with
or close to clearing of TIF_SYSCALL_TRACE.

Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>

---
 arch/powerpc/kernel/ptrace.c | 1 -
 arch/x86/kernel/ptrace.c     | 3 ---
 kernel/ptrace.c              | 3 +++
 3 files changed, 3 insertions(+), 4 deletions(-)

-- 
2.17.1

Comments

Oleg Nesterov May 1, 2019, 4:13 p.m. UTC | #1
On 04/30, Sudeep Holla wrote:
>

> While the TIF_SYSCALL_EMU is set in ptrace_resume independent of any

> architecture, currently only powerpc and x86 unset the TIF_SYSCALL_EMU

> flag in ptrace_disable which gets called from ptrace_detach.

>

> Let's move the clearing of TIF_SYSCALL_EMU flag to __ptrace_unlink

> which gets executed from ptrace_detach and also keep it along with

> or close to clearing of TIF_SYSCALL_TRACE.

>

> Cc: Oleg Nesterov <oleg@redhat.com>

> Cc: Paul Mackerras <paulus@samba.org>

> Cc: Michael Ellerman <mpe@ellerman.id.au>

> Cc: Thomas Gleixner <tglx@linutronix.de>

> Cc: Ingo Molnar <mingo@redhat.com>

> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>


Acked-by: Oleg Nesterov <oleg@redhat.com>
Sudeep Holla May 1, 2019, 4:17 p.m. UTC | #2
On Wed, May 01, 2019 at 06:13:30PM +0200, Oleg Nesterov wrote:
> On 04/30, Sudeep Holla wrote:

> >

> > While the TIF_SYSCALL_EMU is set in ptrace_resume independent of any

> > architecture, currently only powerpc and x86 unset the TIF_SYSCALL_EMU

> > flag in ptrace_disable which gets called from ptrace_detach.

> >

> > Let's move the clearing of TIF_SYSCALL_EMU flag to __ptrace_unlink

> > which gets executed from ptrace_detach and also keep it along with

> > or close to clearing of TIF_SYSCALL_TRACE.

> >

> > Cc: Oleg Nesterov <oleg@redhat.com>

> > Cc: Paul Mackerras <paulus@samba.org>

> > Cc: Michael Ellerman <mpe@ellerman.id.au>

> > Cc: Thomas Gleixner <tglx@linutronix.de>

> > Cc: Ingo Molnar <mingo@redhat.com>

> > Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>

> 

> Acked-by: Oleg Nesterov <oleg@redhat.com>

>


Since 1/4 and 2/4 are completely independent of arm64 changes in 3&4/4,
I prefer you take these via your tree.

--
Regards,
Sudeep
Oleg Nesterov May 2, 2019, 4:13 p.m. UTC | #3
On 05/01, Sudeep Holla wrote:
>

> On Wed, May 01, 2019 at 06:13:30PM +0200, Oleg Nesterov wrote:

> > On 04/30, Sudeep Holla wrote:

> > >

> > > While the TIF_SYSCALL_EMU is set in ptrace_resume independent of any

> > > architecture, currently only powerpc and x86 unset the TIF_SYSCALL_EMU

> > > flag in ptrace_disable which gets called from ptrace_detach.

> > >

> > > Let's move the clearing of TIF_SYSCALL_EMU flag to __ptrace_unlink

> > > which gets executed from ptrace_detach and also keep it along with

> > > or close to clearing of TIF_SYSCALL_TRACE.

> > >

> > > Cc: Oleg Nesterov <oleg@redhat.com>

> > > Cc: Paul Mackerras <paulus@samba.org>

> > > Cc: Michael Ellerman <mpe@ellerman.id.au>

> > > Cc: Thomas Gleixner <tglx@linutronix.de>

> > > Cc: Ingo Molnar <mingo@redhat.com>

> > > Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>

> >

> > Acked-by: Oleg Nesterov <oleg@redhat.com>

> >

>

> Since 1/4 and 2/4 are completely independent of arm64 changes in 3&4/4,

> I prefer you take these via your tree.


Sorry Sudeep, I can't do this, I need to reanimate my account on kernel.org.

Oleg.
Will Deacon May 2, 2019, 4:45 p.m. UTC | #4
On Thu, May 02, 2019 at 06:13:30PM +0200, Oleg Nesterov wrote:
> On 05/01, Sudeep Holla wrote:

> >

> > On Wed, May 01, 2019 at 06:13:30PM +0200, Oleg Nesterov wrote:

> > > On 04/30, Sudeep Holla wrote:

> > > >

> > > > While the TIF_SYSCALL_EMU is set in ptrace_resume independent of any

> > > > architecture, currently only powerpc and x86 unset the TIF_SYSCALL_EMU

> > > > flag in ptrace_disable which gets called from ptrace_detach.

> > > >

> > > > Let's move the clearing of TIF_SYSCALL_EMU flag to __ptrace_unlink

> > > > which gets executed from ptrace_detach and also keep it along with

> > > > or close to clearing of TIF_SYSCALL_TRACE.

> > > >

> > > > Cc: Oleg Nesterov <oleg@redhat.com>

> > > > Cc: Paul Mackerras <paulus@samba.org>

> > > > Cc: Michael Ellerman <mpe@ellerman.id.au>

> > > > Cc: Thomas Gleixner <tglx@linutronix.de>

> > > > Cc: Ingo Molnar <mingo@redhat.com>

> > > > Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>

> > >

> > > Acked-by: Oleg Nesterov <oleg@redhat.com>

> > >

> >

> > Since 1/4 and 2/4 are completely independent of arm64 changes in 3&4/4,

> > I prefer you take these via your tree.

> 

> Sorry Sudeep, I can't do this, I need to reanimate my account on kernel.org.


Ok, if you're happy for us to take them via arm64 with your ack, then we can
do that as well. Just don't want to step on anybody's toes!

Will
Oleg Nesterov May 3, 2019, 2:14 p.m. UTC | #5
On 05/02, Will Deacon wrote:
>

> Ok, if you're happy for us to take them via arm64 with your ack, then we can

> do that as well.


Yes, yes, please!

Oleg.
diff mbox series

Patch

diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
index d9ac7d94656e..2e2183b800a8 100644
--- a/arch/powerpc/kernel/ptrace.c
+++ b/arch/powerpc/kernel/ptrace.c
@@ -2520,7 +2520,6 @@  void ptrace_disable(struct task_struct *child)
 {
 	/* make sure the single step bit is not set. */
 	user_disable_single_step(child);
-	clear_tsk_thread_flag(child, TIF_SYSCALL_EMU);
 }
 
 #ifdef CONFIG_PPC_ADV_DEBUG_REGS
diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
index 4b8ee05dd6ad..45792dbd2443 100644
--- a/arch/x86/kernel/ptrace.c
+++ b/arch/x86/kernel/ptrace.c
@@ -746,9 +746,6 @@  static int ioperm_get(struct task_struct *target,
 void ptrace_disable(struct task_struct *child)
 {
 	user_disable_single_step(child);
-#ifdef TIF_SYSCALL_EMU
-	clear_tsk_thread_flag(child, TIF_SYSCALL_EMU);
-#endif
 }
 
 #if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION
diff --git a/kernel/ptrace.c b/kernel/ptrace.c
index 6f357f4fc859..16c7fc1eabcf 100644
--- a/kernel/ptrace.c
+++ b/kernel/ptrace.c
@@ -117,6 +117,9 @@  void __ptrace_unlink(struct task_struct *child)
 	BUG_ON(!child->ptrace);
 
 	clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
+#ifdef TIF_SYSCALL_EMU
+	clear_tsk_thread_flag(child, TIF_SYSCALL_EMU);
+#endif
 
 	child->parent = child->real_parent;
 	list_del_init(&child->ptrace_entry);