LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH v4 0/4] ptrace: cleanup PTRACE_SYSEMU handling and add support for arm64
@ 2019-05-23  9:06 Sudeep Holla
  2019-05-23  9:06 ` [PATCH v4 1/4] ptrace: move clearing of TIF_SYSCALL_EMU flag to core Sudeep Holla
                   ` (4 more replies)
  0 siblings, 5 replies; 12+ messages in thread
From: Sudeep Holla @ 2019-05-23  9:06 UTC (permalink / raw)
  To: x86, linux-arm-kernel, linux-kernel
  Cc: Sudeep Holla, Catalin Marinas, Will Deacon, Oleg Nesterov,
	Richard Weinberger, jdike, Steve Capper, Haibo Xu, Bin Lu

Hi,

This patchset evolved from the discussion in the thread[0][1]. When we
wanted to add PTRACE_SYSEMU support to ARM64, we thought instead of
duplicating what other architectures like x86 and powerpc have done,
let consolidate the existing support and move it to the core as there's
nothing arch specific in it.

v3->v4:
	- Rebased on v5.2-rc1
	- Added Oleg's acks for generic and x86 parts

v2->v3:
	- moved clearing of TIF_SYSCALL_EMU to __ptrace_unlink as Oleg
	  suggested
	- x86 cleanup as per Oleg's suggestion and dropped adding new
	  ptrace_syscall_enter for SYSEMU handling
	  (tested using tools/testing/selftests/x86/ptrace_syscall.c)
	- Updated arm64 handling accordingly

v1->v2:
	- added comment for empty statement after tracehook_report_syscall_entry
	- dropped x86 change in syscall_slow_exit_work as I had ended
	  up changing logic unintentionally
	- removed spurious change in powerpc moving user_exit()

Regards,
Sudeep

[0] https://patchwork.kernel.org/patch/10585505/
[1] https://patchwork.kernel.org/patch/10675237/

Sudeep Holla (4):
  ptrace: move clearing of TIF_SYSCALL_EMU flag to core
  x86: simplify _TIF_SYSCALL_EMU handling
  arm64: add PTRACE_SYSEMU{,SINGLESTEP} definations to uapi headers
  arm64: ptrace: add support for syscall emulation

 arch/arm64/include/asm/thread_info.h |  5 ++++-
 arch/arm64/include/uapi/asm/ptrace.h |  3 +++
 arch/arm64/kernel/ptrace.c           |  6 +++++-
 arch/powerpc/kernel/ptrace.c         |  1 -
 arch/x86/entry/common.c              | 17 ++++++-----------
 arch/x86/kernel/ptrace.c             |  3 ---
 kernel/ptrace.c                      |  3 +++
 7 files changed, 21 insertions(+), 17 deletions(-)

--
2.17.1


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH v4 1/4] ptrace: move clearing of TIF_SYSCALL_EMU flag to core
  2019-05-23  9:06 [PATCH v4 0/4] ptrace: cleanup PTRACE_SYSEMU handling and add support for arm64 Sudeep Holla
@ 2019-05-23  9:06 ` Sudeep Holla
  2019-05-23  9:06 ` [PATCH v4 2/4] x86: simplify _TIF_SYSCALL_EMU handling Sudeep Holla
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 12+ messages in thread
From: Sudeep Holla @ 2019-05-23  9:06 UTC (permalink / raw)
  To: x86, linux-arm-kernel, linux-kernel
  Cc: Sudeep Holla, Catalin Marinas, Will Deacon, Oleg Nesterov,
	Richard Weinberger, jdike, Steve Capper, Haibo Xu, Bin Lu,
	Paul Mackerras, Michael Ellerman, Thomas Gleixner, Ingo Molnar

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: Paul Mackerras <paulus@samba.org>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Acked-by: Oleg Nesterov <oleg@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(-)

diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
index 684b0b315c32..8c92febf5f44 100644
--- a/arch/powerpc/kernel/ptrace.c
+++ b/arch/powerpc/kernel/ptrace.c
@@ -2521,7 +2521,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);
-- 
2.17.1


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH v4 2/4] x86: simplify _TIF_SYSCALL_EMU handling
  2019-05-23  9:06 [PATCH v4 0/4] ptrace: cleanup PTRACE_SYSEMU handling and add support for arm64 Sudeep Holla
  2019-05-23  9:06 ` [PATCH v4 1/4] ptrace: move clearing of TIF_SYSCALL_EMU flag to core Sudeep Holla
@ 2019-05-23  9:06 ` Sudeep Holla
  2019-06-03 17:22   ` Catalin Marinas
                     ` (2 more replies)
  2019-05-23  9:06 ` [PATCH v4 3/4] arm64: add PTRACE_SYSEMU{,SINGLESTEP} definations to uapi headers Sudeep Holla
                   ` (2 subsequent siblings)
  4 siblings, 3 replies; 12+ messages in thread
From: Sudeep Holla @ 2019-05-23  9:06 UTC (permalink / raw)
  To: x86, linux-arm-kernel, linux-kernel
  Cc: Sudeep Holla, Catalin Marinas, Will Deacon, Oleg Nesterov,
	Richard Weinberger, jdike, Steve Capper, Haibo Xu, Bin Lu,
	Andy Lutomirski, Thomas Gleixner, Ingo Molnar, Borislav Petkov

The usage of emulated/_TIF_SYSCALL_EMU flags in syscall_trace_enter
seems to be bit overcomplicated than required. Let's simplify it.

Cc: Andy Lutomirski <luto@kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Borislav Petkov <bp@alien8.de>
Acked-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
---
 arch/x86/entry/common.c | 17 ++++++-----------
 1 file changed, 6 insertions(+), 11 deletions(-)

diff --git a/arch/x86/entry/common.c b/arch/x86/entry/common.c
index a986b3c8294c..0a61705d62ec 100644
--- a/arch/x86/entry/common.c
+++ b/arch/x86/entry/common.c
@@ -72,23 +72,18 @@ static long syscall_trace_enter(struct pt_regs *regs)
 
 	struct thread_info *ti = current_thread_info();
 	unsigned long ret = 0;
-	bool emulated = false;
 	u32 work;
 
 	if (IS_ENABLED(CONFIG_DEBUG_ENTRY))
 		BUG_ON(regs != task_pt_regs(current));
 
-	work = READ_ONCE(ti->flags) & _TIF_WORK_SYSCALL_ENTRY;
+	work = READ_ONCE(ti->flags);
 
-	if (unlikely(work & _TIF_SYSCALL_EMU))
-		emulated = true;
-
-	if ((emulated || (work & _TIF_SYSCALL_TRACE)) &&
-	    tracehook_report_syscall_entry(regs))
-		return -1L;
-
-	if (emulated)
-		return -1L;
+	if (work & (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_EMU)) {
+		ret = tracehook_report_syscall_entry(regs);
+		if (ret || (work & _TIF_SYSCALL_EMU))
+			return -1L;
+	}
 
 #ifdef CONFIG_SECCOMP
 	/*
-- 
2.17.1


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH v4 3/4] arm64: add PTRACE_SYSEMU{,SINGLESTEP} definations to uapi headers
  2019-05-23  9:06 [PATCH v4 0/4] ptrace: cleanup PTRACE_SYSEMU handling and add support for arm64 Sudeep Holla
  2019-05-23  9:06 ` [PATCH v4 1/4] ptrace: move clearing of TIF_SYSCALL_EMU flag to core Sudeep Holla
  2019-05-23  9:06 ` [PATCH v4 2/4] x86: simplify _TIF_SYSCALL_EMU handling Sudeep Holla
@ 2019-05-23  9:06 ` Sudeep Holla
  2019-05-23  9:06 ` [PATCH v4 4/4] arm64: ptrace: add support for syscall emulation Sudeep Holla
  2019-06-05 16:54 ` [PATCH v4 0/4] ptrace: cleanup PTRACE_SYSEMU handling and add support for arm64 Catalin Marinas
  4 siblings, 0 replies; 12+ messages in thread
From: Sudeep Holla @ 2019-05-23  9:06 UTC (permalink / raw)
  To: x86, linux-arm-kernel, linux-kernel
  Cc: Sudeep Holla, Catalin Marinas, Will Deacon, Oleg Nesterov,
	Richard Weinberger, jdike, Steve Capper, Haibo Xu, Bin Lu

x86 and um use 31 and 32 for PTRACE_SYSEMU and PTRACE_SYSEMU_SINGLESTEP
while powerpc uses different value maybe for legacy reasons.

Though handling of PTRACE_SYSEMU can be made architecture independent,
it's hard to make these definations generic. To add to this existing
mess few architectures like arm, c6x and sh use 31 for PTRACE_GETFDPIC
(get the ELF fdpic loadmap address). It's not possible to move the
definations to generic headers.

So we unfortunately have to duplicate the same defination to ARM64 if
we need to support PTRACE_SYSEMU and PTRACE_SYSEMU_SINGLESTEP.

Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
---
 arch/arm64/include/uapi/asm/ptrace.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/arm64/include/uapi/asm/ptrace.h b/arch/arm64/include/uapi/asm/ptrace.h
index d78623acb649..627ac57c1581 100644
--- a/arch/arm64/include/uapi/asm/ptrace.h
+++ b/arch/arm64/include/uapi/asm/ptrace.h
@@ -62,6 +62,9 @@
 #define PSR_x		0x0000ff00	/* Extension		*/
 #define PSR_c		0x000000ff	/* Control		*/
 
+/* syscall emulation path in ptrace */
+#define PTRACE_SYSEMU		  31
+#define PTRACE_SYSEMU_SINGLESTEP  32
 
 #ifndef __ASSEMBLY__
 
-- 
2.17.1


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH v4 4/4] arm64: ptrace: add support for syscall emulation
  2019-05-23  9:06 [PATCH v4 0/4] ptrace: cleanup PTRACE_SYSEMU handling and add support for arm64 Sudeep Holla
                   ` (2 preceding siblings ...)
  2019-05-23  9:06 ` [PATCH v4 3/4] arm64: add PTRACE_SYSEMU{,SINGLESTEP} definations to uapi headers Sudeep Holla
@ 2019-05-23  9:06 ` Sudeep Holla
  2019-06-05 16:54 ` [PATCH v4 0/4] ptrace: cleanup PTRACE_SYSEMU handling and add support for arm64 Catalin Marinas
  4 siblings, 0 replies; 12+ messages in thread
From: Sudeep Holla @ 2019-05-23  9:06 UTC (permalink / raw)
  To: x86, linux-arm-kernel, linux-kernel
  Cc: Sudeep Holla, Catalin Marinas, Will Deacon, Oleg Nesterov,
	Richard Weinberger, jdike, Steve Capper, Haibo Xu, Bin Lu

Add PTRACE_SYSEMU and PTRACE_SYSEMU_SINGLESTEP support on arm64.
We don't need any special handling for PTRACE_SYSEMU_SINGLESTEP.

It's quite difficult to generalize handling PTRACE_SYSEMU cross
architectures and avoid calls to tracehook_report_syscall_entry twice.
Different architecture have different mechanism to indicate NO_SYSCALL
and trying to generalise adds more code for no gain.

Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
---
 arch/arm64/include/asm/thread_info.h | 5 ++++-
 arch/arm64/kernel/ptrace.c           | 6 +++++-
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/include/asm/thread_info.h b/arch/arm64/include/asm/thread_info.h
index eb3ef73e07cf..c285d1ce7186 100644
--- a/arch/arm64/include/asm/thread_info.h
+++ b/arch/arm64/include/asm/thread_info.h
@@ -75,6 +75,7 @@ void arch_release_task_struct(struct task_struct *tsk);
  *  TIF_SYSCALL_TRACE	- syscall trace active
  *  TIF_SYSCALL_TRACEPOINT - syscall tracepoint for ftrace
  *  TIF_SYSCALL_AUDIT	- syscall auditing
+ *  TIF_SYSCALL_EMU     - syscall emulation active
  *  TIF_SECOMP		- syscall secure computing
  *  TIF_SIGPENDING	- signal pending
  *  TIF_NEED_RESCHED	- rescheduling necessary
@@ -91,6 +92,7 @@ void arch_release_task_struct(struct task_struct *tsk);
 #define TIF_SYSCALL_AUDIT	9
 #define TIF_SYSCALL_TRACEPOINT	10
 #define TIF_SECCOMP		11
+#define TIF_SYSCALL_EMU		12
 #define TIF_MEMDIE		18	/* is terminating due to OOM killer */
 #define TIF_FREEZE		19
 #define TIF_RESTORE_SIGMASK	20
@@ -109,6 +111,7 @@ void arch_release_task_struct(struct task_struct *tsk);
 #define _TIF_SYSCALL_AUDIT	(1 << TIF_SYSCALL_AUDIT)
 #define _TIF_SYSCALL_TRACEPOINT	(1 << TIF_SYSCALL_TRACEPOINT)
 #define _TIF_SECCOMP		(1 << TIF_SECCOMP)
+#define _TIF_SYSCALL_EMU	(1 << TIF_SYSCALL_EMU)
 #define _TIF_UPROBE		(1 << TIF_UPROBE)
 #define _TIF_FSCHECK		(1 << TIF_FSCHECK)
 #define _TIF_32BIT		(1 << TIF_32BIT)
@@ -120,7 +123,7 @@ void arch_release_task_struct(struct task_struct *tsk);
 
 #define _TIF_SYSCALL_WORK	(_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
 				 _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP | \
-				 _TIF_NOHZ)
+				 _TIF_NOHZ | _TIF_SYSCALL_EMU)
 
 #define INIT_THREAD_INFO(tsk)						\
 {									\
diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c
index b82e0a9b3da3..9353355cb91a 100644
--- a/arch/arm64/kernel/ptrace.c
+++ b/arch/arm64/kernel/ptrace.c
@@ -1819,8 +1819,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))
+	if (test_thread_flag(TIF_SYSCALL_TRACE) ||
+		test_thread_flag(TIF_SYSCALL_EMU)) {
 		tracehook_report_syscall(regs, PTRACE_SYSCALL_ENTER);
+		if (!in_syscall(regs) || test_thread_flag(TIF_SYSCALL_EMU))
+			return -1;
+	}
 
 	/* Do the secure computing after ptrace; failures should be fast. */
 	if (secure_computing(NULL) == -1)
-- 
2.17.1


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v4 2/4] x86: simplify _TIF_SYSCALL_EMU handling
  2019-05-23  9:06 ` [PATCH v4 2/4] x86: simplify _TIF_SYSCALL_EMU handling Sudeep Holla
@ 2019-06-03 17:22   ` Catalin Marinas
  2019-06-11 14:38   ` Thomas Gleixner
  2019-06-11 14:56   ` [PATCH v5 2/4] x86/entry: Simplify " Sudeep Holla
  2 siblings, 0 replies; 12+ messages in thread
From: Catalin Marinas @ 2019-06-03 17:22 UTC (permalink / raw)
  To: Sudeep Holla, Andy Lutomirski
  Cc: x86, linux-arm-kernel, linux-kernel, Will Deacon, Oleg Nesterov,
	Richard Weinberger, jdike, Steve Capper, Haibo Xu, Bin Lu,
	Thomas Gleixner, Ingo Molnar, Borislav Petkov

On Thu, May 23, 2019 at 10:06:16AM +0100, Sudeep Holla wrote:
> The usage of emulated/_TIF_SYSCALL_EMU flags in syscall_trace_enter
> seems to be bit overcomplicated than required. Let's simplify it.
> 
> Cc: Andy Lutomirski <luto@kernel.org>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: Borislav Petkov <bp@alien8.de>
> Acked-by: Oleg Nesterov <oleg@redhat.com>
> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
> ---
>  arch/x86/entry/common.c | 17 ++++++-----------
>  1 file changed, 6 insertions(+), 11 deletions(-)
> 
> diff --git a/arch/x86/entry/common.c b/arch/x86/entry/common.c
> index a986b3c8294c..0a61705d62ec 100644
> --- a/arch/x86/entry/common.c
> +++ b/arch/x86/entry/common.c
> @@ -72,23 +72,18 @@ static long syscall_trace_enter(struct pt_regs *regs)
>  
>  	struct thread_info *ti = current_thread_info();
>  	unsigned long ret = 0;
> -	bool emulated = false;
>  	u32 work;
>  
>  	if (IS_ENABLED(CONFIG_DEBUG_ENTRY))
>  		BUG_ON(regs != task_pt_regs(current));
>  
> -	work = READ_ONCE(ti->flags) & _TIF_WORK_SYSCALL_ENTRY;
> +	work = READ_ONCE(ti->flags);
>  
> -	if (unlikely(work & _TIF_SYSCALL_EMU))
> -		emulated = true;
> -
> -	if ((emulated || (work & _TIF_SYSCALL_TRACE)) &&
> -	    tracehook_report_syscall_entry(regs))
> -		return -1L;
> -
> -	if (emulated)
> -		return -1L;
> +	if (work & (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_EMU)) {
> +		ret = tracehook_report_syscall_entry(regs);
> +		if (ret || (work & _TIF_SYSCALL_EMU))
> +			return -1L;
> +	}

Andy (or the other x86 folk), could I please get an ack on this patch? I
plan to queue this series through the arm64 tree (though if you want to
merge it separately, it looks like an independent clean-up with no
dependencies on the other patches).

Thanks.

-- 
Catalin

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v4 0/4] ptrace: cleanup PTRACE_SYSEMU handling and add support for arm64
  2019-05-23  9:06 [PATCH v4 0/4] ptrace: cleanup PTRACE_SYSEMU handling and add support for arm64 Sudeep Holla
                   ` (3 preceding siblings ...)
  2019-05-23  9:06 ` [PATCH v4 4/4] arm64: ptrace: add support for syscall emulation Sudeep Holla
@ 2019-06-05 16:54 ` Catalin Marinas
  4 siblings, 0 replies; 12+ messages in thread
From: Catalin Marinas @ 2019-06-05 16:54 UTC (permalink / raw)
  To: Sudeep Holla
  Cc: x86, linux-arm-kernel, linux-kernel, Will Deacon, Oleg Nesterov,
	Richard Weinberger, jdike, Steve Capper, Haibo Xu, Bin Lu

On Thu, May 23, 2019 at 10:06:14AM +0100, Sudeep Holla wrote:
> Sudeep Holla (4):
>   ptrace: move clearing of TIF_SYSCALL_EMU flag to core
>   x86: simplify _TIF_SYSCALL_EMU handling
>   arm64: add PTRACE_SYSEMU{,SINGLESTEP} definations to uapi headers
>   arm64: ptrace: add support for syscall emulation

I queued patches 1, 3 and 4 through the arm64 tree. There is no
dependency on patch 2 (just general clean-)up; happy to take it as well
or it can go in via the x86 tree.

Thanks.

-- 
Catalin

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v4 2/4] x86: simplify _TIF_SYSCALL_EMU handling
  2019-05-23  9:06 ` [PATCH v4 2/4] x86: simplify _TIF_SYSCALL_EMU handling Sudeep Holla
  2019-06-03 17:22   ` Catalin Marinas
@ 2019-06-11 14:38   ` Thomas Gleixner
  2019-06-11 14:56   ` [PATCH v5 2/4] x86/entry: Simplify " Sudeep Holla
  2 siblings, 0 replies; 12+ messages in thread
From: Thomas Gleixner @ 2019-06-11 14:38 UTC (permalink / raw)
  To: Sudeep Holla
  Cc: x86, linux-arm-kernel, linux-kernel, Catalin Marinas,
	Will Deacon, Oleg Nesterov, Richard Weinberger, jdike,
	Steve Capper, Haibo Xu, Bin Lu, Andy Lutomirski, Ingo Molnar,
	Borislav Petkov

On Thu, 23 May 2019, Sudeep Holla wrote:

$Subject: Please use the proper prefix and start the sentence with an upper
case letter.

  x86/entry: Simplify _TIF_SYSCALL_EMU handling

> The usage of emulated/_TIF_SYSCALL_EMU flags in syscall_trace_enter
> seems to be bit overcomplicated than required. Let's simplify it.

s/seems to be bit overcomplicated/is more complicated/

 Either you are sure that it is overengineered, then say so. If not, then
 you should not touch the code at all.

s/Let's simplify it.//

 'Let's do X.' is a popular, but technically useless phrase.

> Cc: Andy Lutomirski <luto@kernel.org>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: Borislav Petkov <bp@alien8.de>
> Acked-by: Oleg Nesterov <oleg@redhat.com>
> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>

This is a nice simplification indeed! With the changelog fixed:

     Reviewed-by: Thomas Gleixner <tglx@linutronix.de>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH v5 2/4] x86/entry: Simplify _TIF_SYSCALL_EMU handling
  2019-05-23  9:06 ` [PATCH v4 2/4] x86: simplify _TIF_SYSCALL_EMU handling Sudeep Holla
  2019-06-03 17:22   ` Catalin Marinas
  2019-06-11 14:38   ` Thomas Gleixner
@ 2019-06-11 14:56   ` Sudeep Holla
  2019-06-24 17:30     ` Catalin Marinas
  2 siblings, 1 reply; 12+ messages in thread
From: Sudeep Holla @ 2019-06-11 14:56 UTC (permalink / raw)
  To: x86, linux-arm-kernel, linux-kernel, Catalin Marinas
  Cc: Sudeep Holla, Will Deacon, Oleg Nesterov, Thomas Gleixner,
	Richard Weinberger, jdike, Steve Capper, Haibo Xu,
	Andy Lutomirski, Ingo Molnar, Borislav Petkov

The usage of emulated and _TIF_SYSCALL_EMU flags in syscall_trace_enter
is more complicated than required.

Cc: Andy Lutomirski <luto@kernel.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Borislav Petkov <bp@alien8.de>
Acked-by: Oleg Nesterov <oleg@redhat.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
---
 arch/x86/entry/common.c | 17 ++++++-----------
 1 file changed, 6 insertions(+), 11 deletions(-)

Hi Catalin,

I assume you can now pick up this patch.

Regards,
Sudeep

v4->v5: Updated changelog as suggested by tglx and added his Reviewed-by

diff --git a/arch/x86/entry/common.c b/arch/x86/entry/common.c
index a986b3c8294c..0a61705d62ec 100644
--- a/arch/x86/entry/common.c
+++ b/arch/x86/entry/common.c
@@ -72,23 +72,18 @@ static long syscall_trace_enter(struct pt_regs *regs)

 	struct thread_info *ti = current_thread_info();
 	unsigned long ret = 0;
-	bool emulated = false;
 	u32 work;

 	if (IS_ENABLED(CONFIG_DEBUG_ENTRY))
 		BUG_ON(regs != task_pt_regs(current));

-	work = READ_ONCE(ti->flags) & _TIF_WORK_SYSCALL_ENTRY;
+	work = READ_ONCE(ti->flags);

-	if (unlikely(work & _TIF_SYSCALL_EMU))
-		emulated = true;
-
-	if ((emulated || (work & _TIF_SYSCALL_TRACE)) &&
-	    tracehook_report_syscall_entry(regs))
-		return -1L;
-
-	if (emulated)
-		return -1L;
+	if (work & (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_EMU)) {
+		ret = tracehook_report_syscall_entry(regs);
+		if (ret || (work & _TIF_SYSCALL_EMU))
+			return -1L;
+	}

 #ifdef CONFIG_SECCOMP
 	/*
--
2.17.1


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v5 2/4] x86/entry: Simplify _TIF_SYSCALL_EMU handling
  2019-06-11 14:56   ` [PATCH v5 2/4] x86/entry: Simplify " Sudeep Holla
@ 2019-06-24 17:30     ` Catalin Marinas
  2019-06-24 17:37       ` Thomas Gleixner
  0 siblings, 1 reply; 12+ messages in thread
From: Catalin Marinas @ 2019-06-24 17:30 UTC (permalink / raw)
  To: Sudeep Holla
  Cc: x86, linux-arm-kernel, linux-kernel, Will Deacon, Oleg Nesterov,
	Thomas Gleixner, Richard Weinberger, jdike, Steve Capper,
	Haibo Xu, Andy Lutomirski, Ingo Molnar, Borislav Petkov

On Tue, Jun 11, 2019 at 03:56:27PM +0100, Sudeep Holla wrote:
> The usage of emulated and _TIF_SYSCALL_EMU flags in syscall_trace_enter
> is more complicated than required.
> 
> Cc: Andy Lutomirski <luto@kernel.org>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: Borislav Petkov <bp@alien8.de>
> Acked-by: Oleg Nesterov <oleg@redhat.com>
> Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
> ---
>  arch/x86/entry/common.c | 17 ++++++-----------
>  1 file changed, 6 insertions(+), 11 deletions(-)
> 
> Hi Catalin,
> 
> I assume you can now pick up this patch.

I can, unless Thomas picks it up through the tip tree (there is no
dependency on the other patches in this series, which I already queued
via arm64).

-- 
Catalin

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v5 2/4] x86/entry: Simplify _TIF_SYSCALL_EMU handling
  2019-06-24 17:30     ` Catalin Marinas
@ 2019-06-24 17:37       ` Thomas Gleixner
  2019-06-26 18:45         ` Thomas Gleixner
  0 siblings, 1 reply; 12+ messages in thread
From: Thomas Gleixner @ 2019-06-24 17:37 UTC (permalink / raw)
  To: Catalin Marinas
  Cc: Sudeep Holla, x86, linux-arm-kernel, linux-kernel, Will Deacon,
	Oleg Nesterov, Richard Weinberger, jdike, Steve Capper, Haibo Xu,
	Andy Lutomirski, Ingo Molnar, Borislav Petkov

On Mon, 24 Jun 2019, Catalin Marinas wrote:
> On Tue, Jun 11, 2019 at 03:56:27PM +0100, Sudeep Holla wrote:
> > The usage of emulated and _TIF_SYSCALL_EMU flags in syscall_trace_enter
> > is more complicated than required.
> > 
> > Cc: Andy Lutomirski <luto@kernel.org>
> > Cc: Ingo Molnar <mingo@redhat.com>
> > Cc: Borislav Petkov <bp@alien8.de>
> > Acked-by: Oleg Nesterov <oleg@redhat.com>
> > Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
> > Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
> > ---
> >  arch/x86/entry/common.c | 17 ++++++-----------
> >  1 file changed, 6 insertions(+), 11 deletions(-)
> > 
> > Hi Catalin,
> > 
> > I assume you can now pick up this patch.
> 
> I can, unless Thomas picks it up through the tip tree (there is no
> dependency on the other patches in this series, which I already queued
> via arm64).

Last time I checked I had no dependencies either. I'll recheck later
tonight.

Thanks,

	tglx

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v5 2/4] x86/entry: Simplify _TIF_SYSCALL_EMU handling
  2019-06-24 17:37       ` Thomas Gleixner
@ 2019-06-26 18:45         ` Thomas Gleixner
  0 siblings, 0 replies; 12+ messages in thread
From: Thomas Gleixner @ 2019-06-26 18:45 UTC (permalink / raw)
  To: Catalin Marinas
  Cc: Sudeep Holla, x86, linux-arm-kernel, linux-kernel, Will Deacon,
	Oleg Nesterov, Richard Weinberger, jdike, Steve Capper, Haibo Xu,
	Andy Lutomirski, Ingo Molnar, Borislav Petkov

On Mon, 24 Jun 2019, Thomas Gleixner wrote:
> On Mon, 24 Jun 2019, Catalin Marinas wrote:
> > On Tue, Jun 11, 2019 at 03:56:27PM +0100, Sudeep Holla wrote:
> > > The usage of emulated and _TIF_SYSCALL_EMU flags in syscall_trace_enter
> > > is more complicated than required.
> > > 
> > > Cc: Andy Lutomirski <luto@kernel.org>
> > > Cc: Ingo Molnar <mingo@redhat.com>
> > > Cc: Borislav Petkov <bp@alien8.de>
> > > Acked-by: Oleg Nesterov <oleg@redhat.com>
> > > Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
> > > Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
> > > ---
> > >  arch/x86/entry/common.c | 17 ++++++-----------
> > >  1 file changed, 6 insertions(+), 11 deletions(-)
> > > 
> > > Hi Catalin,
> > > 
> > > I assume you can now pick up this patch.
> > 
> > I can, unless Thomas picks it up through the tip tree (there is no
> > dependency on the other patches in this series, which I already queued
> > via arm64).
> 
> Last time I checked I had no dependencies either. I'll recheck later
> tonight.

Forgot of course. But go ahead and route it with the others.

Thanks,

	tglx

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2019-06-26 18:45 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-23  9:06 [PATCH v4 0/4] ptrace: cleanup PTRACE_SYSEMU handling and add support for arm64 Sudeep Holla
2019-05-23  9:06 ` [PATCH v4 1/4] ptrace: move clearing of TIF_SYSCALL_EMU flag to core Sudeep Holla
2019-05-23  9:06 ` [PATCH v4 2/4] x86: simplify _TIF_SYSCALL_EMU handling Sudeep Holla
2019-06-03 17:22   ` Catalin Marinas
2019-06-11 14:38   ` Thomas Gleixner
2019-06-11 14:56   ` [PATCH v5 2/4] x86/entry: Simplify " Sudeep Holla
2019-06-24 17:30     ` Catalin Marinas
2019-06-24 17:37       ` Thomas Gleixner
2019-06-26 18:45         ` Thomas Gleixner
2019-05-23  9:06 ` [PATCH v4 3/4] arm64: add PTRACE_SYSEMU{,SINGLESTEP} definations to uapi headers Sudeep Holla
2019-05-23  9:06 ` [PATCH v4 4/4] arm64: ptrace: add support for syscall emulation Sudeep Holla
2019-06-05 16:54 ` [PATCH v4 0/4] ptrace: cleanup PTRACE_SYSEMU handling and add support for arm64 Catalin Marinas

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).