linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH] ptrace: add PTRACE_GET_SYSCALL_INFO request
@ 2018-11-07  3:27 Elvira Khabirova
  2018-11-07 11:21 ` Oleg Nesterov
                   ` (2 more replies)
  0 siblings, 3 replies; 84+ messages in thread
From: Elvira Khabirova @ 2018-11-07  3:27 UTC (permalink / raw)
  To: oleg, rostedt, mingo; +Cc: linux-kernel, ldv, esyr, luto, strace-devel

PTRACE_GET_SYSCALL_INFO lets ptracer obtain details of the syscall
the tracee is blocked in. The request returns meaningful data only
when the tracee is in a syscall-enter-stop or a syscall-exit-stop.

There are two reasons for a special syscall-related ptrace request.

Firstly, with the current ptrace API there are cases when ptracer cannot
retrieve necessary information about syscalls. Some examples include:
* The notorious int-0x80-from-64-bit-task issue. See [1] for details.
In short, if a 64-bit task performs a syscall through int 0x80, its tracer
has no reliable means to find out that the syscall was, in fact,
a compat syscall, and misidentifies it.
* Syscall-enter-stop and syscall-exit-stop look the same for the tracer.
Common practice is to keep track of the sequence of ptrace-stops in order
not to mix the two syscall-stops up. But it is not as simple as it looks;
for example, strace had a (just recently fixed) long-standing bug where
attaching strace to a tracee that is performing the execve system call
led to the tracer identifying the following syscall-exit-stop as
syscall-enter-stop, which messed up all the state tracking.
* Since the introduction of commit 84d77d3f06e7e8dea057d10e8ec77ad71f721be3
("ptrace: Don't allow accessing an undumpable mm"), both PTRACE_PEEKDATA
and process_vm_readv become unavailable when the process dumpable flag
is cleared. On ia64 this results in all syscall arguments being unavailable.

Secondly, ptracers also have to support a lot of arch-specific code for
obtaining information about the tracee. For some architectures, this
requires a ptrace(PTRACE_PEEKUSER, ...) invocation for every syscall
argument and return value.

PTRACE_GET_SYSCALL_INFO returns the following structure:

struct ptrace_syscall_info {
	__u8 op; /* 0 for entry, 1 for exit */
	__u8 __pad0[7];
	union {
		struct {
			__u64 nr;
			__u64 ip;
			__u64 args[6];
			__u8 is_compat;
			__u8 __pad1[7];
		} entry_info;
		struct {
			__s64 rval;
			__u8 is_error;
			__u8 __pad2[7];
		} exit_info;
	};
};

The structure was chosen according to [2], except for two changes.
First: instead of an arch field with a value of AUDIT_ARCH_*, a boolean
is_compat value is returned, because a) not all arches have an AUDIT_ARCH_*
defined for them, b) the tracer already knows what *arch* it is running on,
but it does not know whether the tracee/syscall is in compat mode or not.
Second: a boolean is_error value is added to rval. This way the tracer can
more reliably distinguish a return value from an error value.

[1] https://lkml.kernel.org/r/CA+55aFzcSVmdDj9Lh_gdbz1OzHyEm6ZrGPBDAJnywm2LF_eVyg@mail.gmail.com
[2] http://lkml.kernel.org/r/CAObL_7GM0n80N7J_DFw_eQyfLyzq+sf4y2AvsCCV88Tb3AwEHA@mail.gmail.com

Signed-off-by: Elvira Khabirova <lineprinter@altlinux.org>
---
 arch/alpha/kernel/ptrace.c      |  2 +-
 arch/arc/kernel/ptrace.c        |  2 +-
 arch/arm/kernel/ptrace.c        |  2 +-
 arch/arm64/kernel/ptrace.c      |  2 +-
 arch/c6x/kernel/ptrace.c        |  2 +-
 arch/h8300/kernel/ptrace.c      |  2 +-
 arch/hexagon/kernel/traps.c     |  2 +-
 arch/ia64/kernel/ptrace.c       |  2 +-
 arch/m68k/kernel/ptrace.c       |  3 ++-
 arch/microblaze/kernel/ptrace.c |  2 +-
 arch/mips/kernel/ptrace.c       |  2 +-
 arch/nds32/kernel/ptrace.c      |  2 +-
 arch/nios2/kernel/ptrace.c      |  3 ++-
 arch/openrisc/kernel/ptrace.c   |  2 +-
 arch/parisc/kernel/ptrace.c     |  2 +-
 arch/powerpc/kernel/ptrace.c    |  2 +-
 arch/riscv/kernel/ptrace.c      |  2 +-
 arch/s390/kernel/ptrace.c       |  2 +-
 arch/sh/kernel/ptrace_32.c      |  2 +-
 arch/sh/kernel/ptrace_64.c      |  2 +-
 arch/sparc/kernel/ptrace_32.c   |  2 +-
 arch/sparc/kernel/ptrace_64.c   |  2 +-
 arch/um/kernel/ptrace.c         |  2 +-
 arch/x86/entry/common.c         |  2 +-
 arch/xtensa/kernel/ptrace.c     |  2 +-
 include/linux/ptrace.h          | 16 ++++++++++---
 include/linux/tracehook.h       | 13 ++++++----
 include/uapi/linux/ptrace.h     | 22 +++++++++++++++++
 kernel/ptrace.c                 | 42 +++++++++++++++++++++++++++++++++
 29 files changed, 113 insertions(+), 32 deletions(-)

diff --git a/arch/alpha/kernel/ptrace.c b/arch/alpha/kernel/ptrace.c
index cb8d599e72d6..970c0719b4d1 100644
--- a/arch/alpha/kernel/ptrace.c
+++ b/arch/alpha/kernel/ptrace.c
@@ -324,7 +324,7 @@ asmlinkage unsigned long syscall_trace_enter(void)
 	unsigned long ret = 0;
 	struct pt_regs *regs = current_pt_regs();
 	if (test_thread_flag(TIF_SYSCALL_TRACE) &&
-	    tracehook_report_syscall_entry(current_pt_regs()))
+	    tracehook_report_syscall_entry(current_pt_regs(), false))
 		ret = -1UL;
 	audit_syscall_entry(regs->r0, regs->r16, regs->r17, regs->r18, regs->r19);
 	return ret ?: current_pt_regs()->r0;
diff --git a/arch/arc/kernel/ptrace.c b/arch/arc/kernel/ptrace.c
index 5ee4676f135d..d12c37c3da80 100644
--- a/arch/arc/kernel/ptrace.c
+++ b/arch/arc/kernel/ptrace.c
@@ -293,7 +293,7 @@ long arch_ptrace(struct task_struct *child, long request,
 
 asmlinkage int syscall_trace_entry(struct pt_regs *regs)
 {
-	if (tracehook_report_syscall_entry(regs))
+	if (tracehook_report_syscall_entry(regs, false))
 		return ULONG_MAX;
 
 	return regs->r8;
diff --git a/arch/arm/kernel/ptrace.c b/arch/arm/kernel/ptrace.c
index 6fa5b6387556..686513749ac5 100644
--- a/arch/arm/kernel/ptrace.c
+++ b/arch/arm/kernel/ptrace.c
@@ -911,7 +911,7 @@ static void tracehook_report_syscall(struct pt_regs *regs,
 
 	if (dir == PTRACE_SYSCALL_EXIT)
 		tracehook_report_syscall_exit(regs, 0);
-	else if (tracehook_report_syscall_entry(regs))
+	else if (tracehook_report_syscall_entry(regs, false))
 		current_thread_info()->syscall = -1;
 
 	regs->ARM_ip = ip;
diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c
index 1710a2d01669..667d7d96ae0a 100644
--- a/arch/arm64/kernel/ptrace.c
+++ b/arch/arm64/kernel/ptrace.c
@@ -1626,7 +1626,7 @@ static void tracehook_report_syscall(struct pt_regs *regs,
 
 	if (dir == PTRACE_SYSCALL_EXIT)
 		tracehook_report_syscall_exit(regs, 0);
-	else if (tracehook_report_syscall_entry(regs))
+	else if (tracehook_report_syscall_entry(regs, is_compat_task()))
 		forget_syscall(regs);
 
 	regs->regs[regno] = saved_reg;
diff --git a/arch/c6x/kernel/ptrace.c b/arch/c6x/kernel/ptrace.c
index 8801dc98fd44..169b2bf4176d 100644
--- a/arch/c6x/kernel/ptrace.c
+++ b/arch/c6x/kernel/ptrace.c
@@ -127,7 +127,7 @@ long arch_ptrace(struct task_struct *child, long request,
  */
 asmlinkage unsigned long syscall_trace_entry(struct pt_regs *regs)
 {
-	if (tracehook_report_syscall_entry(regs))
+	if (tracehook_report_syscall_entry(regs, false))
 		/* tracing decided this syscall should not happen, so
 		 * We'll return a bogus call number to get an ENOSYS
 		 * error, but leave the original number in
diff --git a/arch/h8300/kernel/ptrace.c b/arch/h8300/kernel/ptrace.c
index 0dc1c8f622bc..238918546603 100644
--- a/arch/h8300/kernel/ptrace.c
+++ b/arch/h8300/kernel/ptrace.c
@@ -179,7 +179,7 @@ asmlinkage long do_syscall_trace_enter(struct pt_regs *regs)
 	long ret = 0;
 
 	if (test_thread_flag(TIF_SYSCALL_TRACE) &&
-	    tracehook_report_syscall_entry(regs))
+	    tracehook_report_syscall_entry(regs, false))
 		/*
 		 * Tracing decided this syscall should not happen.
 		 * We'll return a bogus call number to get an ENOSYS
diff --git a/arch/hexagon/kernel/traps.c b/arch/hexagon/kernel/traps.c
index 91ee04842c22..840f880760b7 100644
--- a/arch/hexagon/kernel/traps.c
+++ b/arch/hexagon/kernel/traps.c
@@ -368,7 +368,7 @@ void do_trap0(struct pt_regs *regs)
 
 		/* allow strace to catch syscall args  */
 		if (unlikely(test_thread_flag(TIF_SYSCALL_TRACE) &&
-			tracehook_report_syscall_entry(regs)))
+			tracehook_report_syscall_entry(regs, false)))
 			return;  /*  return -ENOSYS somewhere?  */
 
 		/* Interrupts should be re-enabled for syscall processing */
diff --git a/arch/ia64/kernel/ptrace.c b/arch/ia64/kernel/ptrace.c
index 427cd565fd61..6c12265aed65 100644
--- a/arch/ia64/kernel/ptrace.c
+++ b/arch/ia64/kernel/ptrace.c
@@ -1218,7 +1218,7 @@ syscall_trace_enter (long arg0, long arg1, long arg2, long arg3,
 		     struct pt_regs regs)
 {
 	if (test_thread_flag(TIF_SYSCALL_TRACE))
-		if (tracehook_report_syscall_entry(&regs))
+		if (tracehook_report_syscall_entry(&regs, false))
 			return -ENOSYS;
 
 	/* copy user rbs to kernel rbs */
diff --git a/arch/m68k/kernel/ptrace.c b/arch/m68k/kernel/ptrace.c
index 748c63bd0081..cdfd21325a62 100644
--- a/arch/m68k/kernel/ptrace.c
+++ b/arch/m68k/kernel/ptrace.c
@@ -293,7 +293,8 @@ asmlinkage int syscall_trace_enter(void)
 	int ret = 0;
 
 	if (test_thread_flag(TIF_SYSCALL_TRACE))
-		ret = tracehook_report_syscall_entry(task_pt_regs(current));
+		ret = tracehook_report_syscall_entry(task_pt_regs(current),
+						     false);
 	return ret;
 }
 
diff --git a/arch/microblaze/kernel/ptrace.c b/arch/microblaze/kernel/ptrace.c
index badd286882ae..50b6bd6e2222 100644
--- a/arch/microblaze/kernel/ptrace.c
+++ b/arch/microblaze/kernel/ptrace.c
@@ -140,7 +140,7 @@ asmlinkage unsigned long do_syscall_trace_enter(struct pt_regs *regs)
 	secure_computing_strict(regs->r12);
 
 	if (test_thread_flag(TIF_SYSCALL_TRACE) &&
-	    tracehook_report_syscall_entry(regs))
+	    tracehook_report_syscall_entry(regs, false))
 		/*
 		 * Tracing decided this syscall should not happen.
 		 * We'll return a bogus call number to get an ENOSYS
diff --git a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c
index e5ba56c01ee0..633390fcca6a 100644
--- a/arch/mips/kernel/ptrace.c
+++ b/arch/mips/kernel/ptrace.c
@@ -1260,7 +1260,7 @@ asmlinkage long syscall_trace_enter(struct pt_regs *regs, long syscall)
 	current_thread_info()->syscall = syscall;
 
 	if (test_thread_flag(TIF_SYSCALL_TRACE)) {
-		if (tracehook_report_syscall_entry(regs))
+		if (tracehook_report_syscall_entry(regs, is_compat_task()))
 			return -1;
 		syscall = current_thread_info()->syscall;
 	}
diff --git a/arch/nds32/kernel/ptrace.c b/arch/nds32/kernel/ptrace.c
index eaaf7a999b20..fe5870aa88ba 100644
--- a/arch/nds32/kernel/ptrace.c
+++ b/arch/nds32/kernel/ptrace.c
@@ -104,7 +104,7 @@ void user_disable_single_step(struct task_struct *child)
 asmlinkage int syscall_trace_enter(struct pt_regs *regs)
 {
 	if (test_thread_flag(TIF_SYSCALL_TRACE)) {
-		if (tracehook_report_syscall_entry(regs))
+		if (tracehook_report_syscall_entry(regs, false))
 			forget_syscall(regs);
 	}
 	return regs->syscallno;
diff --git a/arch/nios2/kernel/ptrace.c b/arch/nios2/kernel/ptrace.c
index de97bcb7dd44..900daf87c771 100644
--- a/arch/nios2/kernel/ptrace.c
+++ b/arch/nios2/kernel/ptrace.c
@@ -155,7 +155,8 @@ asmlinkage int do_syscall_trace_enter(void)
 	int ret = 0;
 
 	if (test_thread_flag(TIF_SYSCALL_TRACE))
-		ret = tracehook_report_syscall_entry(task_pt_regs(current));
+		ret = tracehook_report_syscall_entry(task_pt_regs(current),
+						     false);
 
 	return ret;
 }
diff --git a/arch/openrisc/kernel/ptrace.c b/arch/openrisc/kernel/ptrace.c
index eb97a8e7c8aa..2c6bdff65fdb 100644
--- a/arch/openrisc/kernel/ptrace.c
+++ b/arch/openrisc/kernel/ptrace.c
@@ -179,7 +179,7 @@ asmlinkage long do_syscall_trace_enter(struct pt_regs *regs)
 	long ret = 0;
 
 	if (test_thread_flag(TIF_SYSCALL_TRACE) &&
-	    tracehook_report_syscall_entry(regs))
+	    tracehook_report_syscall_entry(regs, false))
 		/*
 		 * Tracing decided this syscall should not happen.
 		 * We'll return a bogus call number to get an ENOSYS
diff --git a/arch/parisc/kernel/ptrace.c b/arch/parisc/kernel/ptrace.c
index 2582df1c529b..a074efef61f2 100644
--- a/arch/parisc/kernel/ptrace.c
+++ b/arch/parisc/kernel/ptrace.c
@@ -309,7 +309,7 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
 long do_syscall_trace_enter(struct pt_regs *regs)
 {
 	if (test_thread_flag(TIF_SYSCALL_TRACE) &&
-	    tracehook_report_syscall_entry(regs)) {
+	    tracehook_report_syscall_entry(regs, is_compat_task())) {
 		/*
 		 * Tracing decided this syscall should not happen or the
 		 * debugger stored an invalid system call number. Skip
diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
index afb819f4ca68..e38374716866 100644
--- a/arch/powerpc/kernel/ptrace.c
+++ b/arch/powerpc/kernel/ptrace.c
@@ -3282,7 +3282,7 @@ long do_syscall_trace_enter(struct pt_regs *regs)
 	 * below on the exit path.
 	 */
 	if (test_thread_flag(TIF_SYSCALL_TRACE) &&
-	    tracehook_report_syscall_entry(regs))
+	    tracehook_report_syscall_entry(regs, is_compat_task()))
 		goto skip;
 
 	/* Run seccomp after ptrace; allow it to set gpr[3]. */
diff --git a/arch/riscv/kernel/ptrace.c b/arch/riscv/kernel/ptrace.c
index 60f1e02eed36..51fc4ba43e90 100644
--- a/arch/riscv/kernel/ptrace.c
+++ b/arch/riscv/kernel/ptrace.c
@@ -156,7 +156,7 @@ long arch_ptrace(struct task_struct *child, long request,
 void do_syscall_trace_enter(struct pt_regs *regs)
 {
 	if (test_thread_flag(TIF_SYSCALL_TRACE))
-		if (tracehook_report_syscall_entry(regs))
+		if (tracehook_report_syscall_entry(regs, false))
 			syscall_set_nr(current, regs, -1);
 
 #ifdef CONFIG_HAVE_SYSCALL_TRACEPOINTS
diff --git a/arch/s390/kernel/ptrace.c b/arch/s390/kernel/ptrace.c
index cd3df5514552..567b6fdb389f 100644
--- a/arch/s390/kernel/ptrace.c
+++ b/arch/s390/kernel/ptrace.c
@@ -845,7 +845,7 @@ asmlinkage long do_syscall_trace_enter(struct pt_regs *regs)
 	 * call number to gprs[2].
 	 */
 	if (test_thread_flag(TIF_SYSCALL_TRACE) &&
-	    (tracehook_report_syscall_entry(regs) ||
+	    (tracehook_report_syscall_entry(regs, is_compat_task()) ||
 	     regs->gprs[2] >= NR_syscalls)) {
 		/*
 		 * Tracing decided this syscall should not happen or the
diff --git a/arch/sh/kernel/ptrace_32.c b/arch/sh/kernel/ptrace_32.c
index 5fc3ff606210..d521976a0817 100644
--- a/arch/sh/kernel/ptrace_32.c
+++ b/arch/sh/kernel/ptrace_32.c
@@ -492,7 +492,7 @@ asmlinkage long do_syscall_trace_enter(struct pt_regs *regs)
 	secure_computing_strict(regs->regs[0]);
 
 	if (test_thread_flag(TIF_SYSCALL_TRACE) &&
-	    tracehook_report_syscall_entry(regs))
+	    tracehook_report_syscall_entry(regs, false))
 		/*
 		 * Tracing decided this syscall should not happen.
 		 * We'll return a bogus call number to get an ENOSYS
diff --git a/arch/sh/kernel/ptrace_64.c b/arch/sh/kernel/ptrace_64.c
index 1e0656d9e7af..11f3e22f13df 100644
--- a/arch/sh/kernel/ptrace_64.c
+++ b/arch/sh/kernel/ptrace_64.c
@@ -512,7 +512,7 @@ asmlinkage long long do_syscall_trace_enter(struct pt_regs *regs)
 	secure_computing_strict(regs->regs[9]);
 
 	if (test_thread_flag(TIF_SYSCALL_TRACE) &&
-	    tracehook_report_syscall_entry(regs))
+	    tracehook_report_syscall_entry(regs, false))
 		/*
 		 * Tracing decided this syscall should not happen.
 		 * We'll return a bogus call number to get an ENOSYS
diff --git a/arch/sparc/kernel/ptrace_32.c b/arch/sparc/kernel/ptrace_32.c
index 16b50afe7b52..5ab2b55b3db6 100644
--- a/arch/sparc/kernel/ptrace_32.c
+++ b/arch/sparc/kernel/ptrace_32.c
@@ -452,7 +452,7 @@ asmlinkage int syscall_trace(struct pt_regs *regs, int syscall_exit_p)
 		if (syscall_exit_p)
 			tracehook_report_syscall_exit(regs, 0);
 		else
-			ret = tracehook_report_syscall_entry(regs);
+			ret = tracehook_report_syscall_entry(regs, false);
 	}
 
 	return ret;
diff --git a/arch/sparc/kernel/ptrace_64.c b/arch/sparc/kernel/ptrace_64.c
index e1d965e90e16..8ad2b7183b88 100644
--- a/arch/sparc/kernel/ptrace_64.c
+++ b/arch/sparc/kernel/ptrace_64.c
@@ -1117,7 +1117,7 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
 		user_exit();
 
 	if (test_thread_flag(TIF_SYSCALL_TRACE))
-		ret = tracehook_report_syscall_entry(regs);
+		ret = tracehook_report_syscall_entry(regs, is_compat_task());
 
 	if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
 		trace_sys_enter(regs, regs->u_regs[UREG_G1]);
diff --git a/arch/um/kernel/ptrace.c b/arch/um/kernel/ptrace.c
index 1a1d88a4d940..36b847b10814 100644
--- a/arch/um/kernel/ptrace.c
+++ b/arch/um/kernel/ptrace.c
@@ -136,7 +136,7 @@ int syscall_trace_enter(struct pt_regs *regs)
 	if (!test_thread_flag(TIF_SYSCALL_TRACE))
 		return 0;
 
-	return tracehook_report_syscall_entry(regs);
+	return tracehook_report_syscall_entry(regs, false);
 }
 
 void syscall_trace_leave(struct pt_regs *regs)
diff --git a/arch/x86/entry/common.c b/arch/x86/entry/common.c
index 3b2490b81918..f4593e17cc6f 100644
--- a/arch/x86/entry/common.c
+++ b/arch/x86/entry/common.c
@@ -82,7 +82,7 @@ static long syscall_trace_enter(struct pt_regs *regs)
 		emulated = true;
 
 	if ((emulated || (work & _TIF_SYSCALL_TRACE)) &&
-	    tracehook_report_syscall_entry(regs))
+	    tracehook_report_syscall_entry(regs, in_ia32_syscall()))
 		return -1L;
 
 	if (emulated)
diff --git a/arch/xtensa/kernel/ptrace.c b/arch/xtensa/kernel/ptrace.c
index c0845cb1cbb9..4bd0babe5536 100644
--- a/arch/xtensa/kernel/ptrace.c
+++ b/arch/xtensa/kernel/ptrace.c
@@ -466,7 +466,7 @@ long arch_ptrace(struct task_struct *child, long request,
 unsigned long do_syscall_trace_enter(struct pt_regs *regs)
 {
 	if (test_thread_flag(TIF_SYSCALL_TRACE) &&
-	    tracehook_report_syscall_entry(regs))
+	    tracehook_report_syscall_entry(regs, false))
 		return -1;
 
 	return regs->areg[2];
diff --git a/include/linux/ptrace.h b/include/linux/ptrace.h
index 6c2ffed907f5..8c95adccb64e 100644
--- a/include/linux/ptrace.h
+++ b/include/linux/ptrace.h
@@ -21,9 +21,10 @@ extern int ptrace_access_vm(struct task_struct *tsk, unsigned long addr,
  * flags.  When the a task is stopped the ptracer owns task->ptrace.
  */
 
-#define PT_SEIZED	0x00010000	/* SEIZE used, enable new behavior */
-#define PT_PTRACED	0x00000001
-#define PT_DTRACE	0x00000002	/* delayed trace (used on m68k, i386) */
+#define PT_SEIZED		0x00010000	/* SEIZE used, enable new behavior */
+#define PT_PTRACED		0x00000001
+#define PT_DTRACE		0x00000002	/* delayed trace (used on m68k, i386) */
+#define PT_IN_SYSCALL_STOP	0x00000004	/* task is in a syscall-stop */
 
 #define PT_OPT_FLAG_SHIFT	3
 /* PT_TRACE_* event enable flags */
@@ -46,6 +47,15 @@ extern int ptrace_access_vm(struct task_struct *tsk, unsigned long addr,
 #define PT_BLOCKSTEP_BIT	30
 #define PT_BLOCKSTEP		(1<<PT_BLOCKSTEP_BIT)
 
+/*
+ * These flags are used in tracehook_report_syscall_* to store
+ * some information about current syscall-stop in task->ptrace_message.
+ * We can use ptrace_message because ptrace_message doesn't have to contain
+ * any specific value during syscall-stops.
+ */
+#define PT_SYSCALL_ISCOMPAT	0x00000001
+#define PT_SYSCALL_ISENTERING	0x00000002
+
 extern long arch_ptrace(struct task_struct *child, long request,
 			unsigned long addr, unsigned long data);
 extern int ptrace_readdata(struct task_struct *tsk, unsigned long src, char __user *dst, int len);
diff --git a/include/linux/tracehook.h b/include/linux/tracehook.h
index 40b0b4c1bf7b..e02ca656d2c9 100644
--- a/include/linux/tracehook.h
+++ b/include/linux/tracehook.h
@@ -57,13 +57,16 @@ struct linux_binprm;
 /*
  * ptrace report for syscall entry and exit looks identical.
  */
-static inline int ptrace_report_syscall(struct pt_regs *regs)
+static inline int ptrace_report_syscall(struct pt_regs *regs,
+					unsigned long message)
 {
 	int ptrace = current->ptrace;
 
 	if (!(ptrace & PT_PTRACED))
 		return 0;
+	current->ptrace |= PT_IN_SYSCALL_STOP;
 
+	current->ptrace_message = message;
 	ptrace_notify(SIGTRAP | ((ptrace & PT_TRACESYSGOOD) ? 0x80 : 0));
 
 	/*
@@ -76,6 +79,7 @@ static inline int ptrace_report_syscall(struct pt_regs *regs)
 		current->exit_code = 0;
 	}
 
+	current->ptrace &= ~PT_IN_SYSCALL_STOP;
 	return fatal_signal_pending(current);
 }
 
@@ -99,9 +103,10 @@ static inline int ptrace_report_syscall(struct pt_regs *regs)
  * Called without locks, just after entering kernel mode.
  */
 static inline __must_check int tracehook_report_syscall_entry(
-	struct pt_regs *regs)
+	struct pt_regs *regs, bool is_compat)
 {
-	return ptrace_report_syscall(regs);
+	return ptrace_report_syscall(regs, PT_SYSCALL_ISENTERING |
+		(is_compat ? PT_SYSCALL_ISCOMPAT : 0));
 }
 
 /**
@@ -126,7 +131,7 @@ static inline void tracehook_report_syscall_exit(struct pt_regs *regs, int step)
 	if (step)
 		user_single_step_report(regs);
 	else
-		ptrace_report_syscall(regs);
+		ptrace_report_syscall(regs, 0);
 }
 
 /**
diff --git a/include/uapi/linux/ptrace.h b/include/uapi/linux/ptrace.h
index d5a1b8a492b9..c2d30ae74de6 100644
--- a/include/uapi/linux/ptrace.h
+++ b/include/uapi/linux/ptrace.h
@@ -73,6 +73,28 @@ struct seccomp_metadata {
 	__u64 flags;		/* Output: filter's flags */
 };
 
+#define PTRACE_GET_SYSCALL_INFO 0x420f
+
+struct ptrace_syscall_info {
+	__u8 op; /* 0 for entry, 1 for exit */
+	__u8 __pad0[7];
+	union {
+		struct {
+			__u64 nr;
+			__u64 ip;
+			__u64 args[6];
+			__u8 is_compat;
+			__u8 __pad1[7];
+		} entry_info;
+		struct {
+			__s64 rval;
+			__u8 is_error;
+			__u8 __pad2[7];
+		} exit_info;
+	};
+};
+
+
 /* Read signals from a shared (process wide) queue */
 #define PTRACE_PEEKSIGINFO_SHARED	(1 << 0)
 
diff --git a/kernel/ptrace.c b/kernel/ptrace.c
index 80b34dffdfb9..05fa5977bed3 100644
--- a/kernel/ptrace.c
+++ b/kernel/ptrace.c
@@ -30,6 +30,10 @@
 #include <linux/cn_proc.h>
 #include <linux/compat.h>
 
+#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
+#include <asm/syscall.h> /* For syscall_get_* */
+#endif
+
 /*
  * Access another process' address space via ptrace.
  * Source/target buffer must be kernel space,
@@ -890,6 +894,37 @@ static int ptrace_regset(struct task_struct *task, int req, unsigned int type,
 EXPORT_SYMBOL_GPL(task_user_regset_view);
 #endif
 
+#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
+static int ptrace_get_syscall(struct task_struct *child, void __user *datavp)
+{
+	struct ptrace_syscall_info info;
+	struct pt_regs *regs = task_pt_regs(child);
+	unsigned long args[ARRAY_SIZE(info.entry_info.args)];
+	int i;
+
+	if (child->ptrace_message & PT_SYSCALL_ISENTERING) {
+		info.op = 0;
+		info.entry_info.nr = syscall_get_nr(child, regs);
+		info.entry_info.ip = instruction_pointer(task_pt_regs(child));
+		syscall_get_arguments(child, regs, 0, ARRAY_SIZE(args), args);
+		for (i = 0; i < ARRAY_SIZE(args); i++)
+			info.entry_info.args[i] = args[i];
+		info.entry_info.is_compat =
+			!!(child->ptrace_message & PT_SYSCALL_ISCOMPAT);
+	} else {
+		info.op = 1;
+		info.exit_info.rval = syscall_get_error(child, regs);
+		info.exit_info.is_error = !!info.exit_info.rval;
+		if (!info.exit_info.is_error) {
+			info.exit_info.rval =
+				syscall_get_return_value(child, regs);
+		}
+	}
+
+	return copy_to_user(datavp, &info, sizeof(info)) ? -EFAULT : 0;
+}
+#endif
+
 int ptrace_request(struct task_struct *child, long request,
 		   unsigned long addr, unsigned long data)
 {
@@ -1105,6 +1140,13 @@ int ptrace_request(struct task_struct *child, long request,
 		ret = seccomp_get_metadata(child, addr, datavp);
 		break;
 
+#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
+	case PTRACE_GET_SYSCALL_INFO:
+		if (child->ptrace & PT_IN_SYSCALL_STOP)
+			ret = ptrace_get_syscall(child, datavp);
+		break;
+#endif
+
 	default:
 		break;
 	}
-- 
2.19.1


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

* Re: [RFC PATCH] ptrace: add PTRACE_GET_SYSCALL_INFO request
  2018-11-07  3:27 [RFC PATCH] ptrace: add PTRACE_GET_SYSCALL_INFO request Elvira Khabirova
@ 2018-11-07 11:21 ` Oleg Nesterov
  2018-11-07 14:06   ` Andy Lutomirski
  2018-11-07 16:12   ` Dmitry V. Levin
  2018-11-07 15:50 ` Dmitry V. Levin
  2018-11-07 20:44 ` Andy Lutomirski
  2 siblings, 2 replies; 84+ messages in thread
From: Oleg Nesterov @ 2018-11-07 11:21 UTC (permalink / raw)
  To: Elvira Khabirova
  Cc: rostedt, mingo, linux-kernel, ldv, esyr, luto, strace-devel

On 11/07, Elvira Khabirova wrote:
>
> In short, if a 64-bit task performs a syscall through int 0x80, its tracer
> has no reliable means to find out that the syscall was, in fact,
> a compat syscall, and misidentifies it.
> * Syscall-enter-stop and syscall-exit-stop look the same for the tracer.

Yes, this was discussed many times...

So perhaps it makes sense to encode compat/is_enter in ->ptrace_message,
debugger can use PTRACE_GETEVENTMSG to get this info.

> Secondly, ptracers also have to support a lot of arch-specific code for
> obtaining information about the tracee. For some architectures, this
> requires a ptrace(PTRACE_PEEKUSER, ...) invocation for every syscall
> argument and return value.

I am not sure about this change... I won't really argue, but imo this
needs a separate patch.

> +#define PT_IN_SYSCALL_STOP	0x00000004	/* task is in a syscall-stop */
...
> -static inline int ptrace_report_syscall(struct pt_regs *regs)
> +static inline int ptrace_report_syscall(struct pt_regs *regs,
> +					unsigned long message)
>  {
>  	int ptrace = current->ptrace;
>  
>  	if (!(ptrace & PT_PTRACED))
>  		return 0;
> +	current->ptrace |= PT_IN_SYSCALL_STOP;
>  
> +	current->ptrace_message = message;
>  	ptrace_notify(SIGTRAP | ((ptrace & PT_TRACESYSGOOD) ? 0x80 : 0));
>  
>  	/*
> @@ -76,6 +79,7 @@ static inline int ptrace_report_syscall(struct pt_regs *regs)
>  		current->exit_code = 0;
>  	}
>  
> +	current->ptrace &= ~PT_IN_SYSCALL_STOP;
>  	return fatal_signal_pending(current);
...

> +	case PTRACE_GET_SYSCALL_INFO:
> +		if (child->ptrace & PT_IN_SYSCALL_STOP)
> +			ret = ptrace_get_syscall(child, datavp);
> +		break;

Why? If debugger uses PTRACE_O_TRACESYSGOOD it can know if the tracee reported
syscall entry/exit or not. PTRACE_GET_SYSCALL_INFO is pointless if not, but
nothing bad can happen.

Oleg.


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

* Re: [RFC PATCH] ptrace: add PTRACE_GET_SYSCALL_INFO request
  2018-11-07 11:21 ` Oleg Nesterov
@ 2018-11-07 14:06   ` Andy Lutomirski
  2018-11-07 16:44     ` Oleg Nesterov
  2018-11-07 16:12   ` Dmitry V. Levin
  1 sibling, 1 reply; 84+ messages in thread
From: Andy Lutomirski @ 2018-11-07 14:06 UTC (permalink / raw)
  To: Oleg Nesterov
  Cc: Elvira Khabirova, rostedt, mingo, linux-kernel, ldv, esyr, luto,
	strace-devel



> On Nov 7, 2018, at 3:21 AM, Oleg Nesterov <oleg@redhat.com> wrote:
> 
>> On 11/07, Elvira Khabirova wrote:
>> 
>> In short, if a 64-bit task performs a syscall through int 0x80, its tracer
>> has no reliable means to find out that the syscall was, in fact,
>> a compat syscall, and misidentifies it.
>> * Syscall-enter-stop and syscall-exit-stop look the same for the tracer.
> 
> Yes, this was discussed many times...
> 
> So perhaps it makes sense to encode compat/is_enter in ->ptrace_message,
> debugger can use PTRACE_GETEVENTMSG to get this info.

As I said before, I strongly object to the use of “compat” here.  Compat meant “not the kernel’s native syscall API — uses the 32-bit structure format instead”.  This does not have a sensible meaning to user code, especially in the case where the tracer is 32-bit.

> 
>> Secondly, ptracers also have to support a lot of arch-specific code for
>> obtaining information about the tracee. For some architectures, this
>> requires a ptrace(PTRACE_PEEKUSER, ...) invocation for every syscall
>> argument and return value.
> 
> I am not sure about this change... I won't really argue, but imo this
> needs a separate patch.

Why?  Having a single struct that the tracer can read to get the full state is extremely helpful.

Also, we really want it to work for seccomp events as well as PTRACE_SYSCALL, and the event info trick doesn’t make sense for seccomp events.

> 
>> +#define PT_IN_SYSCALL_STOP    0x00000004    /* task is in a syscall-stop */
> ...
>> -static inline int ptrace_report_syscall(struct pt_regs *regs)
>> +static inline int ptrace_report_syscall(struct pt_regs *regs,
>> +                    unsigned long message)
>> {
>>    int ptrace = current->ptrace;
>> 
>>    if (!(ptrace & PT_PTRACED))
>>        return 0;
>> +    current->ptrace |= PT_IN_SYSCALL_STOP;
>> 
>> +    current->ptrace_message = message;
>>    ptrace_notify(SIGTRAP | ((ptrace & PT_TRACESYSGOOD) ? 0x80 : 0));
>> 
>>    /*
>> @@ -76,6 +79,7 @@ static inline int ptrace_report_syscall(struct pt_regs *regs)
>>        current->exit_code = 0;
>>    }
>> 
>> +    current->ptrace &= ~PT_IN_SYSCALL_STOP;
>>    return fatal_signal_pending(current);
> ...
> 
>> +    case PTRACE_GET_SYSCALL_INFO:
>> +        if (child->ptrace & PT_IN_SYSCALL_STOP)
>> +            ret = ptrace_get_syscall(child, datavp);
>> +        break;
> 
> Why? If debugger uses PTRACE_O_TRACESYSGOOD it can know if the tracee reported
> syscall entry/exit or not. PTRACE_GET_SYSCALL_INFO is pointless if not, but
> nothing bad can happen.
> 
> 

I think it’s considerably nicer to the user to avoid reporting garbage if the user misused the API.  (And Elvira got this right in the patch — I just missed it.)

> 

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

* Re: [RFC PATCH] ptrace: add PTRACE_GET_SYSCALL_INFO request
  2018-11-07  3:27 [RFC PATCH] ptrace: add PTRACE_GET_SYSCALL_INFO request Elvira Khabirova
  2018-11-07 11:21 ` Oleg Nesterov
@ 2018-11-07 15:50 ` Dmitry V. Levin
  2018-11-07 20:44 ` Andy Lutomirski
  2 siblings, 0 replies; 84+ messages in thread
From: Dmitry V. Levin @ 2018-11-07 15:50 UTC (permalink / raw)
  To: Andy Lutomirski
  Cc: Elvira Khabirova, Oleg Nesterov, Steven Rostedt, Ingo Molnar,
	Andy Lutomirski, Eugene Syromyatnikov, linux-kernel,
	strace-devel

On Wed, Nov 07, 2018 at 04:27:51AM +0100, Elvira Khabirova wrote:
[...]
> The structure was chosen according to [2], except for two changes.
> First: instead of an arch field with a value of AUDIT_ARCH_*, a boolean
> is_compat value is returned, because a) not all arches have an AUDIT_ARCH_*
> defined for them,

To be more specific, here is the list of arch subtrees in v4.20-rc1 that
invoke tracehook_report_syscall_entry() but do not provide syscall_get_arch():

arch/arc
arch/c6x
arch/h8300
arch/hexagon
arch/m68k
arch/nds32
arch/nios2
arch/riscv
arch/um
arch/xtensa

Among these trees only m68k has its AUDIT_ARCH_M68K constant defined.


-- 
ldv

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

* Re: [RFC PATCH] ptrace: add PTRACE_GET_SYSCALL_INFO request
  2018-11-07 11:21 ` Oleg Nesterov
  2018-11-07 14:06   ` Andy Lutomirski
@ 2018-11-07 16:12   ` Dmitry V. Levin
  1 sibling, 0 replies; 84+ messages in thread
From: Dmitry V. Levin @ 2018-11-07 16:12 UTC (permalink / raw)
  To: Oleg Nesterov
  Cc: Elvira Khabirova, Steven Rostedt, Ingo Molnar, Andy Lutomirski,
	Eugene Syromyatnikov, linux-kernel, strace-devel

On Wed, Nov 07, 2018 at 12:21:01PM +0100, Oleg Nesterov wrote:
> On 11/07, Elvira Khabirova wrote:
> >
> > In short, if a 64-bit task performs a syscall through int 0x80, its tracer
> > has no reliable means to find out that the syscall was, in fact,
> > a compat syscall, and misidentifies it.
> > * Syscall-enter-stop and syscall-exit-stop look the same for the tracer.
> 
> Yes, this was discussed many times...
> 
> So perhaps it makes sense to encode compat/is_enter in ->ptrace_message,
> debugger can use PTRACE_GETEVENTMSG to get this info.

This would mean for the debugger an extra syscall invocation for each
syscall stop.  When strace doesn't have to fetch memory, it invokes three
syscalls per syscall stop (wait4, PTRACE_GETREGSET, and PTRACE_SYSCALL).
We definitely want to avoid adding PTRACE_GETEVENTMSG on top of that.


-- 
ldv

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

* Re: [RFC PATCH] ptrace: add PTRACE_GET_SYSCALL_INFO request
  2018-11-07 14:06   ` Andy Lutomirski
@ 2018-11-07 16:44     ` Oleg Nesterov
  2018-11-07 20:02       ` Elvira Khabirova
  2018-11-07 20:20       ` Andy Lutomirski
  0 siblings, 2 replies; 84+ messages in thread
From: Oleg Nesterov @ 2018-11-07 16:44 UTC (permalink / raw)
  To: Andy Lutomirski
  Cc: Elvira Khabirova, rostedt, mingo, linux-kernel, ldv, esyr, luto,
	strace-devel

On 11/07, Andy Lutomirski wrote:
>
>
> > On Nov 7, 2018, at 3:21 AM, Oleg Nesterov <oleg@redhat.com> wrote:
> >
> >> On 11/07, Elvira Khabirova wrote:
> >>
> >> In short, if a 64-bit task performs a syscall through int 0x80, its tracer
> >> has no reliable means to find out that the syscall was, in fact,
> >> a compat syscall, and misidentifies it.
> >> * Syscall-enter-stop and syscall-exit-stop look the same for the tracer.
> >
> > Yes, this was discussed many times...
> >
> > So perhaps it makes sense to encode compat/is_enter in ->ptrace_message,
> > debugger can use PTRACE_GETEVENTMSG to get this info.
>
> As I said before, I strongly object to the use of “compat” here.

Not sure I understand you... I do not like "compat" too, but this patch uses
is_compat/etc and I agree with any naming.

> >> Secondly, ptracers also have to support a lot of arch-specific code for
> >> obtaining information about the tracee. For some architectures, this
> >> requires a ptrace(PTRACE_PEEKUSER, ...) invocation for every syscall
> >> argument and return value.
> >
> > I am not sure about this change... I won't really argue, but imo this
> > needs a separate patch.
>
> Why?  Having a single struct that the tracer can read to get the full state is extremely helpful.

As I said, I won't argue, but why can't it come as a separate change?

More info in ->ptrace_message looks usable even without PTRACE_GET_SYSCALL_INFO,
while ptrace_syscall_info layout/API may need more discussion.

> Also, we really want it to work for seccomp events as well as PTRACE_SYSCALL, and the event info trick doesn’t make sense for seccomp events.

I too thought about PTRACE_EVENT_SECCOMP (or I misunderstoo you?), looks like
another reason to make a separate patch.

> >> +#define PT_IN_SYSCALL_STOP    0x00000004    /* task is in a syscall-stop */
> > ...
> >> -static inline int ptrace_report_syscall(struct pt_regs *regs)
> >> +static inline int ptrace_report_syscall(struct pt_regs *regs,
> >> +                    unsigned long message)
> >> {
> >>    int ptrace = current->ptrace;
> >>
> >>    if (!(ptrace & PT_PTRACED))
> >>        return 0;
> >> +    current->ptrace |= PT_IN_SYSCALL_STOP;
> >>
> >> +    current->ptrace_message = message;
> >>    ptrace_notify(SIGTRAP | ((ptrace & PT_TRACESYSGOOD) ? 0x80 : 0));
> >>
> >>    /*
> >> @@ -76,6 +79,7 @@ static inline int ptrace_report_syscall(struct pt_regs *regs)
> >>        current->exit_code = 0;
> >>    }
> >>
> >> +    current->ptrace &= ~PT_IN_SYSCALL_STOP;
> >>    return fatal_signal_pending(current);
> > ...
> >
> >> +    case PTRACE_GET_SYSCALL_INFO:
> >> +        if (child->ptrace & PT_IN_SYSCALL_STOP)
> >> +            ret = ptrace_get_syscall(child, datavp);
> >> +        break;
> >
> > Why? If debugger uses PTRACE_O_TRACESYSGOOD it can know if the tracee reported
> > syscall entry/exit or not. PTRACE_GET_SYSCALL_INFO is pointless if not, but
> > nothing bad can happen.
>
> I think it’s considerably nicer to the user to avoid reporting garbage if the user misused the API.  (And Elvira got this right in the patch — I just missed it.)

To me PT_IN_SYSCALL_STOP makes no real sense, but I won't argue.

At least I'd ask to not abuse task->ptrace. ptrace_report_syscall() can clear
->ptrace_message on exit if we really want PTRACE_GET_SYSCALL_INFO to fail after
that.

Oleg.


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

* Re: [RFC PATCH] ptrace: add PTRACE_GET_SYSCALL_INFO request
  2018-11-07 16:44     ` Oleg Nesterov
@ 2018-11-07 20:02       ` Elvira Khabirova
  2018-11-08  9:16         ` Oleg Nesterov
  2018-11-07 20:20       ` Andy Lutomirski
  1 sibling, 1 reply; 84+ messages in thread
From: Elvira Khabirova @ 2018-11-07 20:02 UTC (permalink / raw)
  To: Oleg Nesterov
  Cc: Andy Lutomirski, rostedt, mingo, linux-kernel, ldv, esyr, luto,
	strace-devel

On Wed, 7 Nov 2018 17:44:44 +0100
Oleg Nesterov <oleg@redhat.com> wrote:

> To me PT_IN_SYSCALL_STOP makes no real sense, but I won't argue.
> 
> At least I'd ask to not abuse task->ptrace. ptrace_report_syscall() can clear
> ->ptrace_message on exit if we really want PTRACE_GET_SYSCALL_INFO to fail after  
> that.

I really would not like to rely on ->ptrace_message remaining empty;
this looks too fragile.

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

* Re: [RFC PATCH] ptrace: add PTRACE_GET_SYSCALL_INFO request
  2018-11-07 16:44     ` Oleg Nesterov
  2018-11-07 20:02       ` Elvira Khabirova
@ 2018-11-07 20:20       ` Andy Lutomirski
  2018-11-08 14:33         ` Oleg Nesterov
  1 sibling, 1 reply; 84+ messages in thread
From: Andy Lutomirski @ 2018-11-07 20:20 UTC (permalink / raw)
  To: Oleg Nesterov
  Cc: Elvira Khabirova, rostedt, mingo, linux-kernel, ldv, esyr, luto,
	strace-devel



> On Nov 7, 2018, at 8:44 AM, Oleg Nesterov <oleg@redhat.com> wrote:
> 
>> On 11/07, Andy Lutomirski wrote:
>> 
>> 
>>>> On Nov 7, 2018, at 3:21 AM, Oleg Nesterov <oleg@redhat.com> wrote:
>>>> 
>>>> On 11/07, Elvira Khabirova wrote:
>>>> 
>>>> In short, if a 64-bit task performs a syscall through int 0x80, its tracer
>>>> has no reliable means to find out that the syscall was, in fact,
>>>> a compat syscall, and misidentifies it.
>>>> * Syscall-enter-stop and syscall-exit-stop look the same for the tracer.
>>> 
>>> Yes, this was discussed many times...
>>> 
>>> So perhaps it makes sense to encode compat/is_enter in ->ptrace_message,
>>> debugger can use PTRACE_GETEVENTMSG to get this info.
>> 
>> As I said before, I strongly object to the use of “compat” here.
> 
> Not sure I understand you... I do not like "compat" too, but this patch uses
> is_compat/etc and I agree with any naming.

My point is: returning a value to user code that is:

0 if the kernel and tracee are 32-bit
0 if the kernel and tracer are 64-but
1 if the kernel is 64-bit and the tracer is 32-bit
? If the tracer is arm64 ILP32

Is not a good design.  And 32-bit builds of strace will not appreciate it.

The API should return a value that, at least on a given overall architecture and preferably globally, indicates the syscall arch.  While oddly named, audit_arch fits the bill nicely, and we already require it to have the right semantics for seccomp support.


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

* Re: [RFC PATCH] ptrace: add PTRACE_GET_SYSCALL_INFO request
  2018-11-07  3:27 [RFC PATCH] ptrace: add PTRACE_GET_SYSCALL_INFO request Elvira Khabirova
  2018-11-07 11:21 ` Oleg Nesterov
  2018-11-07 15:50 ` Dmitry V. Levin
@ 2018-11-07 20:44 ` Andy Lutomirski
  2018-11-09  3:13   ` [PATCH 00/13] Prepare for PTRACE_GET_SYSCALL_INFO Dmitry V. Levin
                     ` (2 more replies)
  2 siblings, 3 replies; 84+ messages in thread
From: Andy Lutomirski @ 2018-11-07 20:44 UTC (permalink / raw)
  To: lineprinter
  Cc: Oleg Nesterov, Steven Rostedt, Ingo Molnar, LKML,
	Dmitry V. Levin, Eugene Syromiatnikov, Andrew Lutomirski,
	strace-devel

> On Nov 6, 2018, at 7:27 PM, Elvira Khabirova <lineprinter@altlinux.org> wrote:
>
> PTRACE_GET_SYSCALL_INFO lets ptracer obtain details of the syscall
> the tracee is blocked in. The request returns meaningful data only
> when the tracee is in a syscall-enter-stop or a syscall-exit-stop.
>
> There are two reasons for a special syscall-related ptrace request.
>
> Firstly, with the current ptrace API there are cases when ptracer cannot
> retrieve necessary information about syscalls. Some examples include:
> * The notorious int-0x80-from-64-bit-task issue. See [1] for details.
> In short, if a 64-bit task performs a syscall through int 0x80, its tracer
> has no reliable means to find out that the syscall was, in fact,
> a compat syscall, and misidentifies it.
> * Syscall-enter-stop and syscall-exit-stop look the same for the tracer.
> Common practice is to keep track of the sequence of ptrace-stops in order
> not to mix the two syscall-stops up. But it is not as simple as it looks;
> for example, strace had a (just recently fixed) long-standing bug where
> attaching strace to a tracee that is performing the execve system call
> led to the tracer identifying the following syscall-exit-stop as
> syscall-enter-stop, which messed up all the state tracking.
> * Since the introduction of commit 84d77d3f06e7e8dea057d10e8ec77ad71f721be3
> ("ptrace: Don't allow accessing an undumpable mm"), both PTRACE_PEEKDATA
> and process_vm_readv become unavailable when the process dumpable flag
> is cleared. On ia64 this results in all syscall arguments being unavailable.
>
> Secondly, ptracers also have to support a lot of arch-specific code for
> obtaining information about the tracee. For some architectures, this
> requires a ptrace(PTRACE_PEEKUSER, ...) invocation for every syscall
> argument and return value.
>
> PTRACE_GET_SYSCALL_INFO returns the following structure:
>
> struct ptrace_syscall_info {
>    __u8 op; /* 0 for entry, 1 for exit */

Please consider adding another op for a seccomp stop.

>    __u8 __pad0[7];
>    union {
>        struct {
>            __u64 nr;
>            __u64 ip;
>            __u64 args[6];
>            __u8 is_compat;
>            __u8 __pad1[7];
>        } entry_info;
>        struct {
>            __s64 rval;
>            __u8 is_error;
>            __u8 __pad2[7];
>        } exit_info;
>    };
> };
>
> The structure was chosen according to [2], except for two changes.
> First: instead of an arch field with a value of AUDIT_ARCH_*, a boolean
> is_compat value is returned, because a) not all arches have an AUDIT_ARCH_*
> defined for them, b) the tracer already knows what *arch* it is running on,
> but it does not know whether the tracee/syscall is in compat mode or not.

I don’t like this for a few reasons:

1. A 32-bit tracer can’t readily tell what is_compat == 0 means.

2. There is no actual guarantee that there are only two syscall
architectures available.  In fact, I think that arm64 is seriously
considering adding a third.  x86 ought to have three, but, for
arguably dubious historical reasons, it only has two, and x32 is
distinguished only by nr.

3. Your patch will be a whole lot shorter if you use
syscall_get_arch().  You'd have to add syscall_get_arch()
implementations for the remaining architectures, but that's still less
code.

> Second: a boolean is_error value is added to rval. This way the tracer can
> more reliably distinguish a return value from an error value.

Sounds reasonable to me.

Also, maybe use the extra parameter to ptrace to have userspace pass
in the size of the structure so that more fields can be added later if
needed.

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

* Re: [RFC PATCH] ptrace: add PTRACE_GET_SYSCALL_INFO request
  2018-11-07 20:02       ` Elvira Khabirova
@ 2018-11-08  9:16         ` Oleg Nesterov
  0 siblings, 0 replies; 84+ messages in thread
From: Oleg Nesterov @ 2018-11-08  9:16 UTC (permalink / raw)
  To: Elvira Khabirova
  Cc: Andy Lutomirski, rostedt, mingo, linux-kernel, ldv, esyr, luto,
	strace-devel

On 11/07, Elvira Khabirova wrote:
>
> On Wed, 7 Nov 2018 17:44:44 +0100
> Oleg Nesterov <oleg@redhat.com> wrote:
>
> > To me PT_IN_SYSCALL_STOP makes no real sense, but I won't argue.
> >
> > At least I'd ask to not abuse task->ptrace. ptrace_report_syscall() can clear
> > ->ptrace_message on exit if we really want PTRACE_GET_SYSCALL_INFO to fail after
> > that.
>
> I really would not like to rely on ->ptrace_message remaining empty;
> this looks too fragile.

Well. I do not understand why this is fragile. And certainly this is not more
fragile than

	current->ptrace |= PT_IN_SYSCALL_STOP;
	trace_notify();
	current->ptrace &= ~PT_IN_SYSCALL_STOP;

simply because both ->ptrace updates are technically wrong. The tracee can race
with the exiting tracer which clears ->ptrace.

But even if this was correct. This patch manipulates ->ptrace_message anyway,
I do not understand why should we abuse ->ptrace too just to for the sanity
check in PTRACE_GET_SYSCALL_INFO.

Oleg.


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

* Re: [RFC PATCH] ptrace: add PTRACE_GET_SYSCALL_INFO request
  2018-11-07 20:20       ` Andy Lutomirski
@ 2018-11-08 14:33         ` Oleg Nesterov
  0 siblings, 0 replies; 84+ messages in thread
From: Oleg Nesterov @ 2018-11-08 14:33 UTC (permalink / raw)
  To: Andy Lutomirski
  Cc: Elvira Khabirova, rostedt, mingo, linux-kernel, ldv, esyr, luto,
	strace-devel

On 11/07, Andy Lutomirski wrote:
>
> > On Nov 7, 2018, at 8:44 AM, Oleg Nesterov <oleg@redhat.com> wrote:
> >
> > Not sure I understand you... I do not like "compat" too, but this patch uses
> > is_compat/etc and I agree with any naming.
>
> My point is: returning a value to user code that is:
>
> 0 if the kernel and tracee are 32-bit
> 0 if the kernel and tracer are 64-but
> 1 if the kernel is 64-bit and the tracer is 32-bit
> ? If the tracer is arm64 ILP32
>
> Is not a good design.  And 32-bit builds of strace will not appreciate it.

Sure, I agree.

> While oddly named, audit_arch fits the bill nicely, and we already
> require it to have the right semantics for seccomp support.

Again, I agree, and I even mentioned PTRACE_EVENT_SECCOMP.


This reminds me about in_ia32_syscall/TS_COMPAT problems... The 1st one is
get_nr_restart_syscall, I'll try to re-send the fix tomorrow.

Another problem is in_compat_syscall() in get_unmapped_area() paths, it can
return the addr > TASK_SIZE for uprobed 32-bit task.

There was something else but I forgot...

Oleg.


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

* [PATCH 00/13] Prepare for PTRACE_GET_SYSCALL_INFO
  2018-11-07 20:44 ` Andy Lutomirski
@ 2018-11-09  3:13   ` Dmitry V. Levin
  2018-11-09  3:15     ` [PATCH 01/13] Move EM_HEXAGON to uapi/linux/elf-em.h Dmitry V. Levin
                       ` (15 more replies)
  2018-11-13  3:38   ` [RFC PATCH] ptrace: add PTRACE_GET_SYSCALL_INFO request Dmitry V. Levin
  2018-11-20  0:11   ` [PATCH v2 00/15] Prepare for PTRACE_GET_SYSCALL_INFO Dmitry V. Levin
  2 siblings, 16 replies; 84+ messages in thread
From: Dmitry V. Levin @ 2018-11-09  3:13 UTC (permalink / raw)
  To: Andy Lutomirski
  Cc: Elvira Khabirova, Albert Ou, Aurelien Jacquiot, Chris Zankel,
	Eric Paris, Geert Uytterhoeven, Greentime Hu, Ley Foon Tan,
	Mark Salter, Max Filippov, Palmer Dabbelt, Paul Moore,
	Richard Kuo, Vincent Chen, Vineet Gupta, Yoshinori Sato,
	linux-audit, linux-c6x-dev, linux-hexagon, linux-m68k,
	linux-riscv, linux-snps-arc, linux-xtensa, nios2-dev,
	uclinux-h8-devel, linux-kernel

syscall_get_arch() is required to be implemented on all architectures
that use tracehook_report_syscall_entry() in order to extend
the generic ptrace API with PTRACE_GET_SYSCALL_INFO request.

Dmitry V. Levin (13):
  Move EM_HEXAGON to uapi/linux/elf-em.h
  elf-em.h: add EM_ARC
  elf-em.h: add EM_NDS32
  elf-em.h: add EM_XTENSA
  m68k: define syscall_get_arch()
  arc: define syscall_get_arch()
  c6x: define syscall_get_arch()
  h8300: define syscall_get_arch()
  hexagon: define syscall_get_arch()
  nds32: define syscall_get_arch()
  nios2: define syscall_get_arch()
  riscv: define syscall_get_arch()
  xtensa: define syscall_get_arch()

 arch/arc/include/asm/syscall.h     |  6 ++++++
 arch/c6x/include/asm/syscall.h     |  6 ++++++
 arch/h8300/include/asm/syscall.h   |  5 +++++
 arch/hexagon/include/asm/elf.h     |  6 +-----
 arch/hexagon/include/asm/syscall.h |  8 ++++++++
 arch/m68k/include/asm/syscall.h    | 12 ++++++++++++
 arch/nds32/include/asm/syscall.h   |  7 +++++++
 arch/nios2/include/asm/syscall.h   |  6 ++++++
 arch/riscv/include/asm/syscall.h   |  6 ++++++
 arch/xtensa/include/asm/syscall.h  |  7 +++++++
 include/uapi/linux/audit.h         |  8 ++++++++
 include/uapi/linux/elf-em.h        |  5 +++++
 12 files changed, 77 insertions(+), 5 deletions(-)
 create mode 100644 arch/m68k/include/asm/syscall.h

-- 
ldv

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

* [PATCH 01/13] Move EM_HEXAGON to uapi/linux/elf-em.h
  2018-11-09  3:13   ` [PATCH 00/13] Prepare for PTRACE_GET_SYSCALL_INFO Dmitry V. Levin
@ 2018-11-09  3:15     ` Dmitry V. Levin
  2018-11-09  3:15     ` [PATCH 02/13] elf-em.h: add EM_ARC Dmitry V. Levin
                       ` (14 subsequent siblings)
  15 siblings, 0 replies; 84+ messages in thread
From: Dmitry V. Levin @ 2018-11-09  3:15 UTC (permalink / raw)
  To: Andy Lutomirski, Richard Kuo
  Cc: Elvira Khabirova, linux-hexagon, linux-kernel

This should never have been defined in the arch tree to begin with,
and now uapi/linux/audit.h header is going to use EM_HEXAGON
in order to define AUDIT_ARCH_HEXAGON which is needed to implement
syscall_get_arch() which in turn is required to extend
the generic ptrace API with PTRACE_GET_SYSCALL_INFO request.

Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
---
 arch/hexagon/include/asm/elf.h | 6 +-----
 include/uapi/linux/elf-em.h    | 1 +
 2 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/arch/hexagon/include/asm/elf.h b/arch/hexagon/include/asm/elf.h
index 80311e7b8ca6..d10fbd54ae51 100644
--- a/arch/hexagon/include/asm/elf.h
+++ b/arch/hexagon/include/asm/elf.h
@@ -23,11 +23,7 @@
 
 #include <asm/ptrace.h>
 #include <asm/user.h>
-
-/*
- * This should really be in linux/elf-em.h.
- */
-#define EM_HEXAGON	164   /* QUALCOMM Hexagon */
+#include <linux/elf-em.h>
 
 struct elf32_hdr;
 
diff --git a/include/uapi/linux/elf-em.h b/include/uapi/linux/elf-em.h
index 93722e60204c..ba3696e3d694 100644
--- a/include/uapi/linux/elf-em.h
+++ b/include/uapi/linux/elf-em.h
@@ -37,6 +37,7 @@
 #define EM_BLACKFIN     106     /* ADI Blackfin Processor */
 #define EM_ALTERA_NIOS2	113	/* Altera Nios II soft-core processor */
 #define EM_TI_C6000	140	/* TI C6X DSPs */
+#define EM_HEXAGON	164	/* QUALCOMM Hexagon */
 #define EM_AARCH64	183	/* ARM 64 bit */
 #define EM_TILEPRO	188	/* Tilera TILEPro */
 #define EM_MICROBLAZE	189	/* Xilinx MicroBlaze */
-- 
ldv

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

* [PATCH 02/13] elf-em.h: add EM_ARC
  2018-11-09  3:13   ` [PATCH 00/13] Prepare for PTRACE_GET_SYSCALL_INFO Dmitry V. Levin
  2018-11-09  3:15     ` [PATCH 01/13] Move EM_HEXAGON to uapi/linux/elf-em.h Dmitry V. Levin
@ 2018-11-09  3:15     ` Dmitry V. Levin
  2018-11-09 14:20       ` Alexey Brodkin
  2018-11-09 16:41       ` Vineet Gupta
  2018-11-09  3:15     ` [PATCH 03/13] elf-em.h: add EM_NDS32 Dmitry V. Levin
                       ` (13 subsequent siblings)
  15 siblings, 2 replies; 84+ messages in thread
From: Dmitry V. Levin @ 2018-11-09  3:15 UTC (permalink / raw)
  To: Andy Lutomirski, Vineet Gupta
  Cc: Elvira Khabirova, linux-snps-arc, linux-kernel

The uapi/linux/audit.h header is going to use EM_ARC in order
to define AUDIT_ARCH_ARC which is needed to implement
syscall_get_arch() which in turn is required to extend
the generic ptrace API with PTRACE_GET_SYSCALL_INFO request.

The value for EM_ARC has been taken from
http://www.sco.com/developers/gabi/2012-12-31/ch4.eheader.html

Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
---
 include/uapi/linux/elf-em.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/uapi/linux/elf-em.h b/include/uapi/linux/elf-em.h
index ba3696e3d694..56ff3f9d9633 100644
--- a/include/uapi/linux/elf-em.h
+++ b/include/uapi/linux/elf-em.h
@@ -26,6 +26,7 @@
 #define EM_ARM		40	/* ARM 32 bit */
 #define EM_SH		42	/* SuperH */
 #define EM_SPARCV9	43	/* SPARC v9 64-bit */
+#define EM_ARC		45	/* Argonaut RISC Core */
 #define EM_H8_300	46	/* Renesas H8/300 */
 #define EM_IA_64	50	/* HP/Intel IA-64 */
 #define EM_X86_64	62	/* AMD x86-64 */
-- 
ldv

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

* [PATCH 03/13] elf-em.h: add EM_NDS32
  2018-11-09  3:13   ` [PATCH 00/13] Prepare for PTRACE_GET_SYSCALL_INFO Dmitry V. Levin
  2018-11-09  3:15     ` [PATCH 01/13] Move EM_HEXAGON to uapi/linux/elf-em.h Dmitry V. Levin
  2018-11-09  3:15     ` [PATCH 02/13] elf-em.h: add EM_ARC Dmitry V. Levin
@ 2018-11-09  3:15     ` Dmitry V. Levin
  2018-11-09  3:15     ` [PATCH 04/13] elf-em.h: add EM_XTENSA Dmitry V. Levin
                       ` (12 subsequent siblings)
  15 siblings, 0 replies; 84+ messages in thread
From: Dmitry V. Levin @ 2018-11-09  3:15 UTC (permalink / raw)
  To: Andy Lutomirski, Greentime Hu, Vincent Chen
  Cc: Elvira Khabirova, linux-kernel

The uapi/linux/audit.h header is going to use EM_NDS32 in order
to define AUDIT_ARCH_NDS32 which is needed to implement
syscall_get_arch() which in turn is required to extend
the generic ptrace API with PTRACE_GET_SYSCALL_INFO request.

The value for EM_NDS32 has been taken from
http://www.sco.com/developers/gabi/2012-12-31/ch4.eheader.html

Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
---
 include/uapi/linux/elf-em.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/uapi/linux/elf-em.h b/include/uapi/linux/elf-em.h
index 56ff3f9d9633..f879c24a7c21 100644
--- a/include/uapi/linux/elf-em.h
+++ b/include/uapi/linux/elf-em.h
@@ -39,6 +39,8 @@
 #define EM_ALTERA_NIOS2	113	/* Altera Nios II soft-core processor */
 #define EM_TI_C6000	140	/* TI C6X DSPs */
 #define EM_HEXAGON	164	/* QUALCOMM Hexagon */
+#define EM_NDS32	167	/* Andes Technology compact code size
+				   embedded RISC processor family */
 #define EM_AARCH64	183	/* ARM 64 bit */
 #define EM_TILEPRO	188	/* Tilera TILEPro */
 #define EM_MICROBLAZE	189	/* Xilinx MicroBlaze */
-- 
ldv

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

* [PATCH 04/13] elf-em.h: add EM_XTENSA
  2018-11-09  3:13   ` [PATCH 00/13] Prepare for PTRACE_GET_SYSCALL_INFO Dmitry V. Levin
                       ` (2 preceding siblings ...)
  2018-11-09  3:15     ` [PATCH 03/13] elf-em.h: add EM_NDS32 Dmitry V. Levin
@ 2018-11-09  3:15     ` Dmitry V. Levin
  2018-11-09  6:45       ` Max Filippov
  2018-11-09  3:15     ` [PATCH 05/13] m68k: define syscall_get_arch() Dmitry V. Levin
                       ` (11 subsequent siblings)
  15 siblings, 1 reply; 84+ messages in thread
From: Dmitry V. Levin @ 2018-11-09  3:15 UTC (permalink / raw)
  To: Andy Lutomirski, Chris Zankel, Max Filippov
  Cc: Elvira Khabirova, linux-xtensa, linux-kernel

The uapi/linux/audit.h header is going to use EM_XTENSA in order
to define AUDIT_ARCH_XTENSA which is needed to implement
syscall_get_arch() which in turn is required to extend
the generic ptrace API with PTRACE_GET_SYSCALL_INFO request.

The value for EM_XTENSA has been taken from
http://www.sco.com/developers/gabi/2012-12-31/ch4.eheader.html

Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
---
 include/uapi/linux/elf-em.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/uapi/linux/elf-em.h b/include/uapi/linux/elf-em.h
index f879c24a7c21..2639119bf459 100644
--- a/include/uapi/linux/elf-em.h
+++ b/include/uapi/linux/elf-em.h
@@ -35,6 +35,7 @@
 #define EM_M32R		88	/* Renesas M32R */
 #define EM_MN10300	89	/* Panasonic/MEI MN10300, AM33 */
 #define EM_OPENRISC     92     /* OpenRISC 32-bit embedded processor */
+#define EM_XTENSA	94	/* Tensilica Xtensa Architecture */
 #define EM_BLACKFIN     106     /* ADI Blackfin Processor */
 #define EM_ALTERA_NIOS2	113	/* Altera Nios II soft-core processor */
 #define EM_TI_C6000	140	/* TI C6X DSPs */
-- 
ldv

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

* [PATCH 05/13] m68k: define syscall_get_arch()
  2018-11-09  3:13   ` [PATCH 00/13] Prepare for PTRACE_GET_SYSCALL_INFO Dmitry V. Levin
                       ` (3 preceding siblings ...)
  2018-11-09  3:15     ` [PATCH 04/13] elf-em.h: add EM_XTENSA Dmitry V. Levin
@ 2018-11-09  3:15     ` Dmitry V. Levin
  2018-11-09  3:16     ` [PATCH 06/13] arc: " Dmitry V. Levin
                       ` (10 subsequent siblings)
  15 siblings, 0 replies; 84+ messages in thread
From: Dmitry V. Levin @ 2018-11-09  3:15 UTC (permalink / raw)
  To: Andy Lutomirski, Geert Uytterhoeven
  Cc: Elvira Khabirova, linux-m68k, linux-kernel

syscall_get_arch() is required to be implemented on all architectures
that use tracehook_report_syscall_entry() in order to extend
the generic ptrace API with PTRACE_GET_SYSCALL_INFO request.

Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
---
 arch/m68k/include/asm/syscall.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)
 create mode 100644 arch/m68k/include/asm/syscall.h

diff --git a/arch/m68k/include/asm/syscall.h b/arch/m68k/include/asm/syscall.h
new file mode 100644
index 000000000000..d4d7deda8d50
--- /dev/null
+++ b/arch/m68k/include/asm/syscall.h
@@ -0,0 +1,12 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _ASM_M68K_SYSCALL_H
+#define _ASM_M68K_SYSCALL_H
+
+#include <uapi/linux/audit.h>
+
+static inline int syscall_get_arch(void)
+{
+	return AUDIT_ARCH_M68K;
+}
+
+#endif	/* _ASM_M68K_SYSCALL_H */
-- 
ldv

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

* [PATCH 06/13] arc: define syscall_get_arch()
  2018-11-09  3:13   ` [PATCH 00/13] Prepare for PTRACE_GET_SYSCALL_INFO Dmitry V. Levin
                       ` (4 preceding siblings ...)
  2018-11-09  3:15     ` [PATCH 05/13] m68k: define syscall_get_arch() Dmitry V. Levin
@ 2018-11-09  3:16     ` Dmitry V. Levin
  2018-11-09 14:22       ` Alexey Brodkin
  2018-11-09 16:50       ` [PATCH 06/13] " Vineet Gupta
  2018-11-09  3:16     ` [PATCH 07/13] c6x: " Dmitry V. Levin
                       ` (9 subsequent siblings)
  15 siblings, 2 replies; 84+ messages in thread
From: Dmitry V. Levin @ 2018-11-09  3:16 UTC (permalink / raw)
  To: Andy Lutomirski, Vineet Gupta, Paul Moore, Eric Paris
  Cc: Elvira Khabirova, linux-snps-arc, linux-audit, linux-kernel

syscall_get_arch() is required to be implemented on all architectures
that use tracehook_report_syscall_entry() in order to extend
the generic ptrace API with PTRACE_GET_SYSCALL_INFO request.

Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
---
 arch/arc/include/asm/syscall.h | 6 ++++++
 include/uapi/linux/audit.h     | 1 +
 2 files changed, 7 insertions(+)

diff --git a/arch/arc/include/asm/syscall.h b/arch/arc/include/asm/syscall.h
index 29de09804306..5662778a7411 100644
--- a/arch/arc/include/asm/syscall.h
+++ b/arch/arc/include/asm/syscall.h
@@ -9,6 +9,7 @@
 #ifndef _ASM_ARC_SYSCALL_H
 #define _ASM_ARC_SYSCALL_H  1
 
+#include <uapi/linux/audit.h>
 #include <linux/err.h>
 #include <linux/sched.h>
 #include <asm/unistd.h>
@@ -68,4 +69,9 @@ syscall_get_arguments(struct task_struct *task, struct pt_regs *regs,
 	}
 }
 
+static inline int syscall_get_arch(void)
+{
+	return AUDIT_ARCH_ARC;
+}
+
 #endif
diff --git a/include/uapi/linux/audit.h b/include/uapi/linux/audit.h
index 818ae690ab79..a7149ceb5b98 100644
--- a/include/uapi/linux/audit.h
+++ b/include/uapi/linux/audit.h
@@ -375,6 +375,7 @@ enum {
 
 #define AUDIT_ARCH_AARCH64	(EM_AARCH64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
 #define AUDIT_ARCH_ALPHA	(EM_ALPHA|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
+#define AUDIT_ARCH_ARC		(EM_ARC)
 #define AUDIT_ARCH_ARM		(EM_ARM|__AUDIT_ARCH_LE)
 #define AUDIT_ARCH_ARMEB	(EM_ARM)
 #define AUDIT_ARCH_CRIS		(EM_CRIS|__AUDIT_ARCH_LE)
-- 
ldv

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

* [PATCH 07/13] c6x: define syscall_get_arch()
  2018-11-09  3:13   ` [PATCH 00/13] Prepare for PTRACE_GET_SYSCALL_INFO Dmitry V. Levin
                       ` (5 preceding siblings ...)
  2018-11-09  3:16     ` [PATCH 06/13] arc: " Dmitry V. Levin
@ 2018-11-09  3:16     ` Dmitry V. Levin
  2018-11-10  2:01       ` [PATCH 07/13 v2] " Dmitry V. Levin
  2018-11-09  3:16     ` [PATCH 08/13] h8300: " Dmitry V. Levin
                       ` (8 subsequent siblings)
  15 siblings, 1 reply; 84+ messages in thread
From: Dmitry V. Levin @ 2018-11-09  3:16 UTC (permalink / raw)
  To: Andy Lutomirski, Mark Salter, Aurelien Jacquiot, Paul Moore, Eric Paris
  Cc: Elvira Khabirova, linux-c6x-dev, linux-audit, linux-kernel

syscall_get_arch() is required to be implemented on all architectures
that use tracehook_report_syscall_entry() in order to extend
the generic ptrace API with PTRACE_GET_SYSCALL_INFO request.

Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
---
 arch/c6x/include/asm/syscall.h | 6 ++++++
 include/uapi/linux/audit.h     | 1 +
 2 files changed, 7 insertions(+)

diff --git a/arch/c6x/include/asm/syscall.h b/arch/c6x/include/asm/syscall.h
index ae2be315ee9c..235c1353a44b 100644
--- a/arch/c6x/include/asm/syscall.h
+++ b/arch/c6x/include/asm/syscall.h
@@ -11,6 +11,7 @@
 #ifndef __ASM_C6X_SYSCALL_H
 #define __ASM_C6X_SYSCALL_H
 
+#include <uapi/linux/audit.h>
 #include <linux/err.h>
 #include <linux/sched.h>
 
@@ -120,4 +121,9 @@ static inline void syscall_set_arguments(struct task_struct *task,
 	}
 }
 
+static inline int syscall_get_arch(void)
+{
+	return AUDIT_ARCH_C6X;
+}
+
 #endif /* __ASM_C6X_SYSCALLS_H */
diff --git a/include/uapi/linux/audit.h b/include/uapi/linux/audit.h
index a7149ceb5b98..3eb1397c2b8f 100644
--- a/include/uapi/linux/audit.h
+++ b/include/uapi/linux/audit.h
@@ -378,6 +378,7 @@ enum {
 #define AUDIT_ARCH_ARC		(EM_ARC)
 #define AUDIT_ARCH_ARM		(EM_ARM|__AUDIT_ARCH_LE)
 #define AUDIT_ARCH_ARMEB	(EM_ARM)
+#define AUDIT_ARCH_C6X		(EM_TI_C6000)
 #define AUDIT_ARCH_CRIS		(EM_CRIS|__AUDIT_ARCH_LE)
 #define AUDIT_ARCH_FRV		(EM_FRV)
 #define AUDIT_ARCH_I386		(EM_386|__AUDIT_ARCH_LE)
-- 
ldv

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

* [PATCH 08/13] h8300: define syscall_get_arch()
  2018-11-09  3:13   ` [PATCH 00/13] Prepare for PTRACE_GET_SYSCALL_INFO Dmitry V. Levin
                       ` (6 preceding siblings ...)
  2018-11-09  3:16     ` [PATCH 07/13] c6x: " Dmitry V. Levin
@ 2018-11-09  3:16     ` Dmitry V. Levin
  2018-11-09  3:16     ` [PATCH 09/13] hexagon: " Dmitry V. Levin
                       ` (7 subsequent siblings)
  15 siblings, 0 replies; 84+ messages in thread
From: Dmitry V. Levin @ 2018-11-09  3:16 UTC (permalink / raw)
  To: Andy Lutomirski, Yoshinori Sato, Paul Moore, Eric Paris
  Cc: Elvira Khabirova, uclinux-h8-devel, linux-audit, linux-kernel

syscall_get_arch() is required to be implemented on all architectures
that use tracehook_report_syscall_entry() in order to extend
the generic ptrace API with PTRACE_GET_SYSCALL_INFO request.

Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
---
 arch/h8300/include/asm/syscall.h | 5 +++++
 include/uapi/linux/audit.h       | 1 +
 2 files changed, 6 insertions(+)

diff --git a/arch/h8300/include/asm/syscall.h b/arch/h8300/include/asm/syscall.h
index 924990401237..699664a0b1be 100644
--- a/arch/h8300/include/asm/syscall.h
+++ b/arch/h8300/include/asm/syscall.h
@@ -8,6 +8,7 @@
 #include <linux/linkage.h>
 #include <linux/types.h>
 #include <linux/ptrace.h>
+#include <uapi/linux/audit.h>
 
 static inline int
 syscall_get_nr(struct task_struct *task, struct pt_regs *regs)
@@ -47,6 +48,10 @@ syscall_get_arguments(struct task_struct *task, struct pt_regs *regs,
 	}
 }
 
+static inline int syscall_get_arch(void)
+{
+	return AUDIT_ARCH_H8300;
+}
 
 
 /* Misc syscall related bits */
diff --git a/include/uapi/linux/audit.h b/include/uapi/linux/audit.h
index 3eb1397c2b8f..2319283f00e5 100644
--- a/include/uapi/linux/audit.h
+++ b/include/uapi/linux/audit.h
@@ -381,6 +381,7 @@ enum {
 #define AUDIT_ARCH_C6X		(EM_TI_C6000)
 #define AUDIT_ARCH_CRIS		(EM_CRIS|__AUDIT_ARCH_LE)
 #define AUDIT_ARCH_FRV		(EM_FRV)
+#define AUDIT_ARCH_H8300	(EM_H8_300)
 #define AUDIT_ARCH_I386		(EM_386|__AUDIT_ARCH_LE)
 #define AUDIT_ARCH_IA64		(EM_IA_64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
 #define AUDIT_ARCH_M32R		(EM_M32R)
-- 
ldv

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

* [PATCH 09/13] hexagon: define syscall_get_arch()
  2018-11-09  3:13   ` [PATCH 00/13] Prepare for PTRACE_GET_SYSCALL_INFO Dmitry V. Levin
                       ` (7 preceding siblings ...)
  2018-11-09  3:16     ` [PATCH 08/13] h8300: " Dmitry V. Levin
@ 2018-11-09  3:16     ` Dmitry V. Levin
  2018-11-09  3:16     ` [PATCH 10/13] nds32: " Dmitry V. Levin
                       ` (6 subsequent siblings)
  15 siblings, 0 replies; 84+ messages in thread
From: Dmitry V. Levin @ 2018-11-09  3:16 UTC (permalink / raw)
  To: Andy Lutomirski, Richard Kuo, Paul Moore, Eric Paris
  Cc: Elvira Khabirova, linux-hexagon, linux-audit, linux-kernel

syscall_get_arch() is required to be implemented on all architectures
that use tracehook_report_syscall_entry() in order to extend
the generic ptrace API with PTRACE_GET_SYSCALL_INFO request.

Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
---
 arch/hexagon/include/asm/syscall.h | 8 ++++++++
 include/uapi/linux/audit.h         | 1 +
 2 files changed, 9 insertions(+)

diff --git a/arch/hexagon/include/asm/syscall.h b/arch/hexagon/include/asm/syscall.h
index 4af9c7b6f13a..de3917aad3fd 100644
--- a/arch/hexagon/include/asm/syscall.h
+++ b/arch/hexagon/include/asm/syscall.h
@@ -21,6 +21,8 @@
 #ifndef _ASM_HEXAGON_SYSCALL_H
 #define _ASM_HEXAGON_SYSCALL_H
 
+#include <uapi/linux/audit.h>
+
 typedef long (*syscall_fn)(unsigned long, unsigned long,
 	unsigned long, unsigned long,
 	unsigned long, unsigned long);
@@ -43,4 +45,10 @@ static inline void syscall_get_arguments(struct task_struct *task,
 	BUG_ON(i + n > 6);
 	memcpy(args, &(&regs->r00)[i], n * sizeof(args[0]));
 }
+
+static inline int syscall_get_arch(void)
+{
+	return AUDIT_ARCH_HEXAGON;
+}
+
 #endif
diff --git a/include/uapi/linux/audit.h b/include/uapi/linux/audit.h
index 2319283f00e5..d5a4f623e47e 100644
--- a/include/uapi/linux/audit.h
+++ b/include/uapi/linux/audit.h
@@ -382,6 +382,7 @@ enum {
 #define AUDIT_ARCH_CRIS		(EM_CRIS|__AUDIT_ARCH_LE)
 #define AUDIT_ARCH_FRV		(EM_FRV)
 #define AUDIT_ARCH_H8300	(EM_H8_300)
+#define AUDIT_ARCH_HEXAGON	(EM_HEXAGON)
 #define AUDIT_ARCH_I386		(EM_386|__AUDIT_ARCH_LE)
 #define AUDIT_ARCH_IA64		(EM_IA_64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
 #define AUDIT_ARCH_M32R		(EM_M32R)
-- 
ldv

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

* [PATCH 10/13] nds32: define syscall_get_arch()
  2018-11-09  3:13   ` [PATCH 00/13] Prepare for PTRACE_GET_SYSCALL_INFO Dmitry V. Levin
                       ` (8 preceding siblings ...)
  2018-11-09  3:16     ` [PATCH 09/13] hexagon: " Dmitry V. Levin
@ 2018-11-09  3:16     ` Dmitry V. Levin
  2018-11-10  2:01       ` [PATCH 10/13 v2] " Dmitry V. Levin
  2018-11-09  3:17     ` [PATCH 11/13] nios2: " Dmitry V. Levin
                       ` (5 subsequent siblings)
  15 siblings, 1 reply; 84+ messages in thread
From: Dmitry V. Levin @ 2018-11-09  3:16 UTC (permalink / raw)
  To: Andy Lutomirski, Greentime Hu, Vincent Chen, Paul Moore, Eric Paris
  Cc: Elvira Khabirova, linux-audit, linux-kernel

syscall_get_arch() is required to be implemented on all architectures
that use tracehook_report_syscall_entry() in order to extend
the generic ptrace API with PTRACE_GET_SYSCALL_INFO request.

Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
---
 arch/nds32/include/asm/syscall.h | 7 +++++++
 include/uapi/linux/audit.h       | 1 +
 2 files changed, 8 insertions(+)

diff --git a/arch/nds32/include/asm/syscall.h b/arch/nds32/include/asm/syscall.h
index f7e5e86765fe..b7f4a4eccf42 100644
--- a/arch/nds32/include/asm/syscall.h
+++ b/arch/nds32/include/asm/syscall.h
@@ -5,6 +5,7 @@
 #ifndef _ASM_NDS32_SYSCALL_H
 #define _ASM_NDS32_SYSCALL_H	1
 
+#include <uapi/linux/audit.h>
 #include <linux/err.h>
 struct task_struct;
 struct pt_regs;
@@ -185,4 +186,10 @@ void syscall_set_arguments(struct task_struct *task, struct pt_regs *regs,
 
 	memcpy(&regs->uregs[0] + i, args, n * sizeof(args[0]));
 }
+
+static inline int syscall_get_arch(void)
+{
+	return AUDIT_ARCH_NDS32;
+}
+
 #endif /* _ASM_NDS32_SYSCALL_H */
diff --git a/include/uapi/linux/audit.h b/include/uapi/linux/audit.h
index d5a4f623e47e..99e2b63ef765 100644
--- a/include/uapi/linux/audit.h
+++ b/include/uapi/linux/audit.h
@@ -396,6 +396,7 @@ enum {
 #define AUDIT_ARCH_MIPSEL64	(EM_MIPS|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
 #define AUDIT_ARCH_MIPSEL64N32	(EM_MIPS|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE|\
 				 __AUDIT_ARCH_CONVENTION_MIPS64_N32)
+#define AUDIT_ARCH_NDS32	(EM_NDS32)
 #define AUDIT_ARCH_OPENRISC	(EM_OPENRISC)
 #define AUDIT_ARCH_PARISC	(EM_PARISC)
 #define AUDIT_ARCH_PARISC64	(EM_PARISC|__AUDIT_ARCH_64BIT)
-- 
ldv

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

* [PATCH 11/13] nios2: define syscall_get_arch()
  2018-11-09  3:13   ` [PATCH 00/13] Prepare for PTRACE_GET_SYSCALL_INFO Dmitry V. Levin
                       ` (9 preceding siblings ...)
  2018-11-09  3:16     ` [PATCH 10/13] nds32: " Dmitry V. Levin
@ 2018-11-09  3:17     ` Dmitry V. Levin
  2018-11-09  3:17     ` [PATCH 12/13] riscv: " Dmitry V. Levin
                       ` (4 subsequent siblings)
  15 siblings, 0 replies; 84+ messages in thread
From: Dmitry V. Levin @ 2018-11-09  3:17 UTC (permalink / raw)
  To: Andy Lutomirski, Ley Foon Tan, Paul Moore, Eric Paris
  Cc: Elvira Khabirova, nios2-dev, linux-audit, linux-kernel

syscall_get_arch() is required to be implemented on all architectures
that use tracehook_report_syscall_entry() in order to extend
the generic ptrace API with PTRACE_GET_SYSCALL_INFO request.

Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
---
 arch/nios2/include/asm/syscall.h | 6 ++++++
 include/uapi/linux/audit.h       | 1 +
 2 files changed, 7 insertions(+)

diff --git a/arch/nios2/include/asm/syscall.h b/arch/nios2/include/asm/syscall.h
index 9de220854c4a..cf35e210fc4d 100644
--- a/arch/nios2/include/asm/syscall.h
+++ b/arch/nios2/include/asm/syscall.h
@@ -17,6 +17,7 @@
 #ifndef __ASM_NIOS2_SYSCALL_H__
 #define __ASM_NIOS2_SYSCALL_H__
 
+#include <uapi/linux/audit.h>
 #include <linux/err.h>
 #include <linux/sched.h>
 
@@ -135,4 +136,9 @@ static inline void syscall_set_arguments(struct task_struct *task,
 	}
 }
 
+static inline int syscall_get_arch(void)
+{
+	return AUDIT_ARCH_NIOS2;
+}
+
 #endif
diff --git a/include/uapi/linux/audit.h b/include/uapi/linux/audit.h
index 99e2b63ef765..c4c8b131af48 100644
--- a/include/uapi/linux/audit.h
+++ b/include/uapi/linux/audit.h
@@ -397,6 +397,7 @@ enum {
 #define AUDIT_ARCH_MIPSEL64N32	(EM_MIPS|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE|\
 				 __AUDIT_ARCH_CONVENTION_MIPS64_N32)
 #define AUDIT_ARCH_NDS32	(EM_NDS32)
+#define AUDIT_ARCH_NIOS2	(EM_ALTERA_NIOS2|__AUDIT_ARCH_LE)
 #define AUDIT_ARCH_OPENRISC	(EM_OPENRISC)
 #define AUDIT_ARCH_PARISC	(EM_PARISC)
 #define AUDIT_ARCH_PARISC64	(EM_PARISC|__AUDIT_ARCH_64BIT)
-- 
ldv

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

* [PATCH 12/13] riscv: define syscall_get_arch()
  2018-11-09  3:13   ` [PATCH 00/13] Prepare for PTRACE_GET_SYSCALL_INFO Dmitry V. Levin
                       ` (10 preceding siblings ...)
  2018-11-09  3:17     ` [PATCH 11/13] nios2: " Dmitry V. Levin
@ 2018-11-09  3:17     ` Dmitry V. Levin
  2018-11-09  6:59       ` David Abdurachmanov
  2018-11-09 18:45       ` Palmer Dabbelt
  2018-11-09  3:17     ` [PATCH 13/13] xtensa: " Dmitry V. Levin
                       ` (3 subsequent siblings)
  15 siblings, 2 replies; 84+ messages in thread
From: Dmitry V. Levin @ 2018-11-09  3:17 UTC (permalink / raw)
  To: Andy Lutomirski, Palmer Dabbelt, Albert Ou, Paul Moore, Eric Paris
  Cc: Elvira Khabirova, linux-riscv, linux-audit, linux-kernel

syscall_get_arch() is required to be implemented on all architectures
that use tracehook_report_syscall_entry() in order to extend
the generic ptrace API with PTRACE_GET_SYSCALL_INFO request.

Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
---
 arch/riscv/include/asm/syscall.h | 6 ++++++
 include/uapi/linux/audit.h       | 1 +
 2 files changed, 7 insertions(+)

diff --git a/arch/riscv/include/asm/syscall.h b/arch/riscv/include/asm/syscall.h
index 8d25f8904c00..7e1e26ca7317 100644
--- a/arch/riscv/include/asm/syscall.h
+++ b/arch/riscv/include/asm/syscall.h
@@ -18,6 +18,7 @@
 #ifndef _ASM_RISCV_SYSCALL_H
 #define _ASM_RISCV_SYSCALL_H
 
+#include <uapi/linux/audit.h>
 #include <linux/sched.h>
 #include <linux/err.h>
 
@@ -99,4 +100,9 @@ static inline void syscall_set_arguments(struct task_struct *task,
 	memcpy(&regs->a1 + i * sizeof(regs->a1), args, n * sizeof(regs->a0));
 }
 
+static inline int syscall_get_arch(void)
+{
+	return AUDIT_ARCH_RISCV;
+}
+
 #endif	/* _ASM_RISCV_SYSCALL_H */
diff --git a/include/uapi/linux/audit.h b/include/uapi/linux/audit.h
index c4c8b131af48..ad4105c602a1 100644
--- a/include/uapi/linux/audit.h
+++ b/include/uapi/linux/audit.h
@@ -405,6 +405,7 @@ enum {
 /* do not define AUDIT_ARCH_PPCLE since it is not supported by audit */
 #define AUDIT_ARCH_PPC64	(EM_PPC64|__AUDIT_ARCH_64BIT)
 #define AUDIT_ARCH_PPC64LE	(EM_PPC64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
+#define AUDIT_ARCH_RISCV	(EM_RISCV|__AUDIT_ARCH_64BIT)
 #define AUDIT_ARCH_S390		(EM_S390)
 #define AUDIT_ARCH_S390X	(EM_S390|__AUDIT_ARCH_64BIT)
 #define AUDIT_ARCH_SH		(EM_SH)
-- 
ldv

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

* [PATCH 13/13] xtensa: define syscall_get_arch()
  2018-11-09  3:13   ` [PATCH 00/13] Prepare for PTRACE_GET_SYSCALL_INFO Dmitry V. Levin
                       ` (11 preceding siblings ...)
  2018-11-09  3:17     ` [PATCH 12/13] riscv: " Dmitry V. Levin
@ 2018-11-09  3:17     ` Dmitry V. Levin
  2018-11-09  6:48       ` Max Filippov
  2018-11-09  6:06     ` [PATCH 00/13] Prepare for PTRACE_GET_SYSCALL_INFO Andy Lutomirski
                       ` (2 subsequent siblings)
  15 siblings, 1 reply; 84+ messages in thread
From: Dmitry V. Levin @ 2018-11-09  3:17 UTC (permalink / raw)
  To: Andy Lutomirski, Chris Zankel, Max Filippov, Paul Moore, Eric Paris
  Cc: Elvira Khabirova, linux-xtensa, linux-audit, linux-kernel

syscall_get_arch() is required to be implemented on all architectures
that use tracehook_report_syscall_entry() in order to extend
the generic ptrace API with PTRACE_GET_SYSCALL_INFO request.

Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
---
 arch/xtensa/include/asm/syscall.h | 7 +++++++
 include/uapi/linux/audit.h        | 1 +
 2 files changed, 8 insertions(+)

diff --git a/arch/xtensa/include/asm/syscall.h b/arch/xtensa/include/asm/syscall.h
index 3673ff1f1bc5..84144567095a 100644
--- a/arch/xtensa/include/asm/syscall.h
+++ b/arch/xtensa/include/asm/syscall.h
@@ -8,6 +8,13 @@
  * Copyright (C) 2001 - 2007 Tensilica Inc.
  */
 
+#include <uapi/linux/audit.h>
+
+static inline int syscall_get_arch(void)
+{
+	return AUDIT_ARCH_XTENSA;
+}
+
 struct pt_regs;
 asmlinkage long xtensa_ptrace(long, long, long, long);
 asmlinkage long xtensa_sigreturn(struct pt_regs*);
diff --git a/include/uapi/linux/audit.h b/include/uapi/linux/audit.h
index ad4105c602a1..28102e1430fa 100644
--- a/include/uapi/linux/audit.h
+++ b/include/uapi/linux/audit.h
@@ -418,6 +418,7 @@ enum {
 #define AUDIT_ARCH_TILEGX32	(EM_TILEGX|__AUDIT_ARCH_LE)
 #define AUDIT_ARCH_TILEPRO	(EM_TILEPRO|__AUDIT_ARCH_LE)
 #define AUDIT_ARCH_X86_64	(EM_X86_64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
+#define AUDIT_ARCH_XTENSA	(EM_XTENSA)
 
 #define AUDIT_PERM_EXEC		1
 #define AUDIT_PERM_WRITE	2
-- 
ldv

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

* Re: [PATCH 00/13] Prepare for PTRACE_GET_SYSCALL_INFO
  2018-11-09  3:13   ` [PATCH 00/13] Prepare for PTRACE_GET_SYSCALL_INFO Dmitry V. Levin
                       ` (12 preceding siblings ...)
  2018-11-09  3:17     ` [PATCH 13/13] xtensa: " Dmitry V. Levin
@ 2018-11-09  6:06     ` Andy Lutomirski
  2018-11-10 14:09     ` [PATCH 14/13] Move EM_UNICORE to uapi/linux/elf-em.h Dmitry V. Levin
  2018-11-10 14:10     ` [PATCH 15/13] unicore32: define syscall_get_arch() Dmitry V. Levin
  15 siblings, 0 replies; 84+ messages in thread
From: Andy Lutomirski @ 2018-11-09  6:06 UTC (permalink / raw)
  To: Andrew Lutomirski, Elvira Khabirova, aou, jacquiot.aurelien,
	Chris Zankel, Eric Paris, Geert Uytterhoeven, green.hu, lftan,
	Mark Salter, Max Filippov, palmer, Paul Moore, Richard Kuo,
	deanbo422, Vineet Gupta, Yoshinori Sato, linux-audit,
	linux-c6x-dev, linux-hexagon, linux-m68k, linux-riscv, arcml,
	linux-xtensa, nios2-dev, uclinux-h8-devel, LKML

On Thu, Nov 8, 2018 at 7:13 PM Dmitry V. Levin <ldv@altlinux.org> wrote:
>
> syscall_get_arch() is required to be implemented on all architectures
> that use tracehook_report_syscall_entry() in order to extend
> the generic ptrace API with PTRACE_GET_SYSCALL_INFO request.

Nice!

I'm pretty sure you have vastly more changelog than code here :)

--Andy

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

* Re: [PATCH 04/13] elf-em.h: add EM_XTENSA
  2018-11-09  3:15     ` [PATCH 04/13] elf-em.h: add EM_XTENSA Dmitry V. Levin
@ 2018-11-09  6:45       ` Max Filippov
  0 siblings, 0 replies; 84+ messages in thread
From: Max Filippov @ 2018-11-09  6:45 UTC (permalink / raw)
  To: Andrew Lutomirski, Chris Zankel, lineprinter, linux-xtensa, LKML

On Thu, Nov 8, 2018 at 7:15 PM Dmitry V. Levin <ldv@altlinux.org> wrote:
> The uapi/linux/audit.h header is going to use EM_XTENSA in order
> to define AUDIT_ARCH_XTENSA which is needed to implement
> syscall_get_arch() which in turn is required to extend
> the generic ptrace API with PTRACE_GET_SYSCALL_INFO request.
>
> The value for EM_XTENSA has been taken from
> http://www.sco.com/developers/gabi/2012-12-31/ch4.eheader.html
>
> Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
> ---
>  include/uapi/linux/elf-em.h | 1 +
>  1 file changed, 1 insertion(+)

Reviewed-by: Max Filippov <jcmvbkbc@gmail.com>

-- 
Thanks.
-- Max

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

* Re: [PATCH 13/13] xtensa: define syscall_get_arch()
  2018-11-09  3:17     ` [PATCH 13/13] xtensa: " Dmitry V. Levin
@ 2018-11-09  6:48       ` Max Filippov
  0 siblings, 0 replies; 84+ messages in thread
From: Max Filippov @ 2018-11-09  6:48 UTC (permalink / raw)
  To: Andrew Lutomirski, Chris Zankel, paul, eparis, lineprinter,
	linux-xtensa, linux-audit, LKML

On Thu, Nov 8, 2018 at 7:17 PM Dmitry V. Levin <ldv@altlinux.org> wrote:
> syscall_get_arch() is required to be implemented on all architectures
> that use tracehook_report_syscall_entry() in order to extend
> the generic ptrace API with PTRACE_GET_SYSCALL_INFO request.
>
> Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
> ---
>  arch/xtensa/include/asm/syscall.h | 7 +++++++
>  include/uapi/linux/audit.h        | 1 +
>  2 files changed, 8 insertions(+)

Acked-by: Max Filippov <jcmvbkbc@gmail.com>

-- 
Thanks.
-- Max

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

* Re: [PATCH 12/13] riscv: define syscall_get_arch()
  2018-11-09  3:17     ` [PATCH 12/13] riscv: " Dmitry V. Levin
@ 2018-11-09  6:59       ` David Abdurachmanov
  2018-11-09 22:28         ` Dmitry V. Levin
  2018-11-09 18:45       ` Palmer Dabbelt
  1 sibling, 1 reply; 84+ messages in thread
From: David Abdurachmanov @ 2018-11-09  6:59 UTC (permalink / raw)
  To: luto, Palmer Dabbelt, aou, Paul Moore, eparis, lineprinter,
	linux-riscv, linux-audit, linux-kernel

On Fri, Nov 9, 2018 at 4:17 AM Dmitry V. Levin <ldv@altlinux.org> wrote:
>
> syscall_get_arch() is required to be implemented on all architectures
> that use tracehook_report_syscall_entry() in order to extend
> the generic ptrace API with PTRACE_GET_SYSCALL_INFO request.
>

I have posted audit support patch for RISC-V in October. Pending review.
It defines both AUDIT_ARCH_RISCV32 and AUDIT_ARCH_RISCV64.

See thread: http://lists.infradead.org/pipermail/linux-riscv/2018-October/001933.html

david

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

* Re: [PATCH 02/13] elf-em.h: add EM_ARC
  2018-11-09  3:15     ` [PATCH 02/13] elf-em.h: add EM_ARC Dmitry V. Levin
@ 2018-11-09 14:20       ` Alexey Brodkin
  2018-11-09 16:41       ` Vineet Gupta
  1 sibling, 0 replies; 84+ messages in thread
From: Alexey Brodkin @ 2018-11-09 14:20 UTC (permalink / raw)
  To: ldv; +Cc: lineprinter, linux-kernel, luto, vineet.gupta1, linux-snps-arc

Hi Dmitry,

On Fri, 2018-11-09 at 06:15 +0300, Dmitry V. Levin wrote:
> The uapi/linux/audit.h header is going to use EM_ARC in order
> to define AUDIT_ARCH_ARC which is needed to implement
> syscall_get_arch() which in turn is required to extend
> the generic ptrace API with PTRACE_GET_SYSCALL_INFO request.
> 
> The value for EM_ARC has been taken from
> https://urldefense.proofpoint.com/v2/url?u=http-3A__www.sco.com_developers_gabi_2012-2D12-2D31_ch4.eheader.html&d=DwICAg&c=DPL6_X_6JkXFx7AXWqB0tg&r=lqdeeSSEes0GFDDl656eViXO7breS55ytWkhpk5R81I&m=Xh7PO9ZcwtbHwzwugwhu0NZypO9ObM5zMkXiQ2ja-QI&s=23pqjp37UXKSxQC0AFzqBjPquJdrh_4FjSW00FLRf4k&e=
> 
> Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
> ---
>  include/uapi/linux/elf-em.h | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/include/uapi/linux/elf-em.h b/include/uapi/linux/elf-em.h
> index ba3696e3d694..56ff3f9d9633 100644
> --- a/include/uapi/linux/elf-em.h
> +++ b/
> @@ -26,6 +26,7 @@
>  #define EM_ARM		40	/* ARM 32 bit */
>  #define EM_SH		42	/* SuperH */
>  #define EM_SPARCV9	43	/* SPARC v9 64-bit */
> +#define EM_ARC		45	/* Argonaut RISC Core */
>  #define EM_H8_300	46	/* Renesas H8/300 */
>  #define EM_IA_64	50	/* HP/Intel IA-64 */
>  #define EM_X86_64	62	/* AMD x86-64 */

I guess we need to add ARCv2 here as well like that:
------------------------>8-----------------------
diff --git a/include/uapi/linux/elf-em.h b/include/uapi/linux/elf-em.h
index 31aa10178335..5c6c263d5c69 100644
--- a/include/uapi/linux/elf-em.h
+++ b/include/uapi/linux/elf-em.h
@@ -41,6 +41,7 @@
 #define EM_TILEPRO     188     /* Tilera TILEPro */
 #define EM_MICROBLAZE  189     /* Xilinx MicroBlaze */
 #define EM_TILEGX      191     /* Tilera TILE-Gx */
+#define EM_ARCV2       195     /* Synopsys ARCv2 ISA */
 #define EM_BPF         247     /* Linux BPF - in-kernel virtual machine */
 #define EM_FRV         0x5441  /* Fujitsu FR-V */
------------------------>8-----------------------

See https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=blob;f=include/elf/common.h;hb=HEAD#l309
Note though that we're moving from EM_ARC_COMPACT2 to EM_ARCV2 name
so it matches real ISA name. This is what we use in Glibc port we're
upstreaming now.

-Alexey

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

* Re: [PATCH 06/13] arc: define syscall_get_arch()
  2018-11-09  3:16     ` [PATCH 06/13] arc: " Dmitry V. Levin
@ 2018-11-09 14:22       ` Alexey Brodkin
  2018-11-09 15:17         ` Andy Lutomirski
  2018-11-09 16:50       ` [PATCH 06/13] " Vineet Gupta
  1 sibling, 1 reply; 84+ messages in thread
From: Alexey Brodkin @ 2018-11-09 14:22 UTC (permalink / raw)
  To: ldv
  Cc: linux-kernel, linux-audit, vineet.gupta1, eparis, linux-snps-arc,
	luto, paul, lineprinter

Hi Dmitry,

On Fri, 2018-11-09 at 06:16 +0300, Dmitry V. Levin wrote:
> syscall_get_arch() is required to be implemented on all architectures
> that use tracehook_report_syscall_entry() in order to extend
> the generic ptrace API with PTRACE_GET_SYSCALL_INFO request.
> 
> Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
> ---
>  arch/arc/include/asm/syscall.h | 6 ++++++
>  include/uapi/linux/audit.h     | 1 +
>  2 files changed, 7 insertions(+)

[snip]

> diff --git a/include/uapi/linux/audit.h b/include/uapi/linux/audit.h
> index 818ae690ab79..a7149ceb5b98 100644
> --- a/include/uapi/linux/audit.h
> +++ b/include/uapi/linux/audit.h
> @@ -375,6 +375,7 @@ enum {
>  
>  #define AUDIT_ARCH_AARCH64	(EM_AARCH64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
>  #define AUDIT_ARCH_ALPHA	(EM_ALPHA|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
> +#define AUDIT_ARCH_ARC		(EM_ARC)

Similarly here we need to have:
---------------------------->8-----------------------------
+#define AUDIT_ARCH_ARC		(EM_ARC|EM_ARCV2)
---------------------------->8-----------------------------

-Alexey

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

* Re: [PATCH 06/13] arc: define syscall_get_arch()
  2018-11-09 14:22       ` Alexey Brodkin
@ 2018-11-09 15:17         ` Andy Lutomirski
  2018-11-09 15:27           ` Alexey Brodkin
  0 siblings, 1 reply; 84+ messages in thread
From: Andy Lutomirski @ 2018-11-09 15:17 UTC (permalink / raw)
  To: Alexey Brodkin
  Cc: Dmitry V. Levin, LKML, linux-audit, Vineet Gupta, Eric Paris,
	arcml, Andrew Lutomirski, Paul Moore, Elvira Khabirova

On Fri, Nov 9, 2018 at 6:22 AM Alexey Brodkin
<alexey.brodkin@synopsys.com> wrote:
>
> Hi Dmitry,
>
> On Fri, 2018-11-09 at 06:16 +0300, Dmitry V. Levin wrote:
> > syscall_get_arch() is required to be implemented on all architectures
> > that use tracehook_report_syscall_entry() in order to extend
> > the generic ptrace API with PTRACE_GET_SYSCALL_INFO request.
> >
> > Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
> > ---
> >  arch/arc/include/asm/syscall.h | 6 ++++++
> >  include/uapi/linux/audit.h     | 1 +
> >  2 files changed, 7 insertions(+)
>
> [snip]
>
> > diff --git a/include/uapi/linux/audit.h b/include/uapi/linux/audit.h
> > index 818ae690ab79..a7149ceb5b98 100644
> > --- a/include/uapi/linux/audit.h
> > +++ b/include/uapi/linux/audit.h
> > @@ -375,6 +375,7 @@ enum {
> >
> >  #define AUDIT_ARCH_AARCH64   (EM_AARCH64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
> >  #define AUDIT_ARCH_ALPHA     (EM_ALPHA|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
> > +#define AUDIT_ARCH_ARC               (EM_ARC)
>
> Similarly here we need to have:
> ---------------------------->8-----------------------------
> +#define AUDIT_ARCH_ARC         (EM_ARC|EM_ARCV2)
> ---------------------------->8-----------------------------
>

Huh?  How does the bitwise or of two ELF machine codes make any sense?

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

* Re: [PATCH 06/13] arc: define syscall_get_arch()
  2018-11-09 15:17         ` Andy Lutomirski
@ 2018-11-09 15:27           ` Alexey Brodkin
  2018-11-09 15:56             ` Andy Lutomirski
  0 siblings, 1 reply; 84+ messages in thread
From: Alexey Brodkin @ 2018-11-09 15:27 UTC (permalink / raw)
  To: luto
  Cc: linux-kernel, linux-audit, vineet.gupta1, eparis, ldv,
	linux-snps-arc, paul, lineprinter

Hi Andy,

On Fri, 2018-11-09 at 07:17 -0800, Andy Lutomirski wrote:
> On Fri, Nov 9, 2018 at 6:22 AM Alexey Brodkin
> <alexey.brodkin@synopsys.com> wrote:
> > Hi Dmitry,
> > 
> > On Fri, 2018-11-09 at 06:16 +0300, Dmitry V. Levin wrote:
> > > syscall_get_arch() is required to be implemented on all architectures
> > > that use tracehook_report_syscall_entry() in order to extend
> > > the generic ptrace API with PTRACE_GET_SYSCALL_INFO request.
> > > 
> > > Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
> > > ---
> > >  arch/arc/include/asm/syscall.h | 6 ++++++
> > >  include/uapi/linux/audit.h     | 1 +
> > >  2 files changed, 7 insertions(+)
> > 
> > [snip]
> > 
> > > diff --git a/include/uapi/linux/audit.h b/include/uapi/linux/audit.h
> > > index 818ae690ab79..a7149ceb5b98 100644
> > > --- a/include/uapi/linux/audit.h
> > > +++ b/include/uapi/linux/audit.h
> > > @@ -375,6 +375,7 @@ enum {
> > > 
> > >  #define AUDIT_ARCH_AARCH64   (EM_AARCH64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
> > >  #define AUDIT_ARCH_ALPHA     (EM_ALPHA|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
> > > +#define AUDIT_ARCH_ARC               (EM_ARC)
> > 
> > Similarly here we need to have:
> > ---------------------------->8-----------------------------
> > +#define AUDIT_ARCH_ARC         (EM_ARC|EM_ARCV2)
> > ---------------------------->8-----------------------------
> > 
> 
> Huh?  How does the bitwise or of two ELF machine codes make any sense?

Oops... I didn't read examples of AUDIT_ARCH_ALPHA above :(
Indeed that was stupid.

But what would be a proper fix then?

Something like that?
---------------------------->8-----------------------------
#define AUDIT_ARCH_ARC               (EM_ARC)
#define AUDIT_ARCH_ARCV2             (EM_ARCV2)


static inline int syscall_get_arch(void)
{
#ifdef __ARC700__
       return AUDIT_ARCH_ARC;
#else
       return AUDIT_ARCH_ARCV2;
#endif
}
---------------------------->8-----------------------------

-Alexey

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

* Re: [PATCH 06/13] arc: define syscall_get_arch()
  2018-11-09 15:27           ` Alexey Brodkin
@ 2018-11-09 15:56             ` Andy Lutomirski
  2018-11-09 16:11               ` Alexey Brodkin
  0 siblings, 1 reply; 84+ messages in thread
From: Andy Lutomirski @ 2018-11-09 15:56 UTC (permalink / raw)
  To: Alexey Brodkin
  Cc: luto, linux-kernel, linux-audit, vineet.gupta1, eparis, ldv,
	linux-snps-arc, paul, lineprinter



> On Nov 9, 2018, at 7:27 AM, Alexey Brodkin <alexey.brodkin@synopsys.com> wrote:
> 
> Hi Andy,
> 
>> On Fri, 2018-11-09 at 07:17 -0800, Andy Lutomirski wrote:
>> On Fri, Nov 9, 2018 at 6:22 AM Alexey Brodkin
>> <alexey.brodkin@synopsys.com> wrote:
>>> Hi Dmitry,
>>> 
>>>> On Fri, 2018-11-09 at 06:16 +0300, Dmitry V. Levin wrote:
>>>> syscall_get_arch() is required to be implemented on all architectures
>>>> that use tracehook_report_syscall_entry() in order to extend
>>>> the generic ptrace API with PTRACE_GET_SYSCALL_INFO request.
>>>> 
>>>> Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
>>>> ---
>>>> arch/arc/include/asm/syscall.h | 6 ++++++
>>>> include/uapi/linux/audit.h     | 1 +
>>>> 2 files changed, 7 insertions(+)
>>> 
>>> [snip]
>>> 
>>>> diff --git a/include/uapi/linux/audit.h b/include/uapi/linux/audit.h
>>>> index 818ae690ab79..a7149ceb5b98 100644
>>>> --- a/include/uapi/linux/audit.h
>>>> +++ b/include/uapi/linux/audit.h
>>>> @@ -375,6 +375,7 @@ enum {
>>>> 
>>>> #define AUDIT_ARCH_AARCH64   (EM_AARCH64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
>>>> #define AUDIT_ARCH_ALPHA     (EM_ALPHA|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
>>>> +#define AUDIT_ARCH_ARC               (EM_ARC)
>>> 
>>> Similarly here we need to have:
>>> ---------------------------->8-----------------------------
>>> +#define AUDIT_ARCH_ARC         (EM_ARC|EM_ARCV2)
>>> ---------------------------->8-----------------------------
>>> 
>> 
>> Huh?  How does the bitwise or of two ELF machine codes make any sense?
> 
> Oops... I didn't read examples of AUDIT_ARCH_ALPHA above :(
> Indeed that was stupid.
> 
> But what would be a proper fix then?
> 
> Something like that?
> ---------------------------->8-----------------------------
> #define AUDIT_ARCH_ARC               (EM_ARC)
> #define AUDIT_ARCH_ARCV2             (EM_ARCV2)
> 
> 
> static inline int syscall_get_arch(void)
> {
> #ifdef __ARC700__
>       return AUDIT_ARCH_ARC;
> #else
>       return AUDIT_ARCH_ARCV2;
> #endif
> }
> ---------------------------->8-----------------------------
> 

Maybe, but I know basically nothing about ARC.  Is the syscall numbering or calling convention different on ARC vs ARCv2?

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

* Re: [PATCH 06/13] arc: define syscall_get_arch()
  2018-11-09 15:56             ` Andy Lutomirski
@ 2018-11-09 16:11               ` Alexey Brodkin
  2018-11-09 16:35                 ` Andy Lutomirski
  0 siblings, 1 reply; 84+ messages in thread
From: Alexey Brodkin @ 2018-11-09 16:11 UTC (permalink / raw)
  To: luto
  Cc: linux-kernel, linux-audit, vineet.gupta1, eparis, ldv,
	linux-snps-arc, luto, paul, lineprinter

Hi Andy,

On Fri, 2018-11-09 at 07:56 -0800, Andy Lutomirski wrote:
> > On Nov 9, 2018, at 7:27 AM, Alexey Brodkin <alexey.brodkin@synopsys.com> wrote:
> > 
> > Hi Andy,
> > 
> > > On Fri, 2018-11-09 at 07:17 -0800, Andy Lutomirski wrote:
> > > On Fri, Nov 9, 2018 at 6:22 AM Alexey Brodkin
> > > <alexey.brodkin@synopsys.com> wrote:
> > > > Hi Dmitry,
> > > > 
> > > > > On Fri, 2018-11-09 at 06:16 +0300, Dmitry V. Levin wrote:
> > > > > syscall_get_arch() is required to be implemented on all architectures
> > > > > that use tracehook_report_syscall_entry() in order to extend
> > > > > the generic ptrace API with PTRACE_GET_SYSCALL_INFO request.
> > > > > 
> > > > > Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
> > > > > ---
> > > > > arch/arc/include/asm/syscall.h | 6 ++++++
> > > > > include/uapi/linux/audit.h     | 1 +
> > > > > 2 files changed, 7 insertions(+)
> > > > 
> > > > [snip]
> > > > 
> > > > > diff --git a/include/uapi/linux/audit.h b/include/uapi/linux/audit.h
> > > > > index 818ae690ab79..a7149ceb5b98 100644
> > > > > --- a/include/uapi/linux/audit.h
> > > > > +++ b/include/uapi/linux/audit.h
> > > > > @@ -375,6 +375,7 @@ enum {
> > > > > 
> > > > > #define AUDIT_ARCH_AARCH64   (EM_AARCH64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
> > > > > #define AUDIT_ARCH_ALPHA     (EM_ALPHA|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
> > > > > +#define AUDIT_ARCH_ARC               (EM_ARC)
> > > > 
> > > > Similarly here we need to have:
> > > > ---------------------------->8-----------------------------
> > > > +#define AUDIT_ARCH_ARC         (EM_ARC|EM_ARCV2)
> > > > ---------------------------->8-----------------------------
> > > > 
> > > 
> > > Huh?  How does the bitwise or of two ELF machine codes make any sense?
> > 
> > Oops... I didn't read examples of AUDIT_ARCH_ALPHA above :(
> > Indeed that was stupid.
> > 
> > But what would be a proper fix then?
> > 
> > Something like that?
> > ---------------------------->8-----------------------------
> > #define AUDIT_ARCH_ARC               (EM_ARC)
> > #define AUDIT_ARCH_ARCV2             (EM_ARCV2)
> > 
> > 
> > static inline int syscall_get_arch(void)
> > {
> > #ifdef __ARC700__
> >       return AUDIT_ARCH_ARC;
> > #else
> >       return AUDIT_ARCH_ARCV2;
> > #endif
> > }
> > ---------------------------->8-----------------------------
> > 
> 
> Maybe, but I know basically nothing about ARC.  Is the syscall numbering or calling convention different on ARC vs ARCv2?

Syscall numbering should be the same as we use UAPI for both ARCompact (AKA ARCv1)
and ARCv2. As for calling convention I think it indeed differs.

Note ARCompact and ARCv2 ISAs are binary incompatible!

Even though assembly look pretty much the same (sans instructions
available only for either ARCompact or ARCv2) encodings are different so
in that sense these are completely different architectures.

Also I'm wondering what could be other cases for use of syscall_get_arch().

So I'd say it's better to report different values for ARC ISAs.
And given we use the same values as in Binutils IMHO it would be good
to not mix IDs here.

-Alexey

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

* Re: [PATCH 06/13] arc: define syscall_get_arch()
  2018-11-09 16:11               ` Alexey Brodkin
@ 2018-11-09 16:35                 ` Andy Lutomirski
  2018-11-09 23:33                   ` [PATCH 06/13 v2] " Dmitry V. Levin
  0 siblings, 1 reply; 84+ messages in thread
From: Andy Lutomirski @ 2018-11-09 16:35 UTC (permalink / raw)
  To: Alexey Brodkin
  Cc: LKML, linux-audit, Vineet Gupta, Eric Paris, Dmitry V. Levin,
	arcml, Andrew Lutomirski, Paul Moore, Elvira Khabirova

On Fri, Nov 9, 2018 at 8:11 AM Alexey Brodkin
<alexey.brodkin@synopsys.com> wrote:
>
> Hi Andy,
>
> On Fri, 2018-11-09 at 07:56 -0800, Andy Lutomirski wrote:
> > > On Nov 9, 2018, at 7:27 AM, Alexey Brodkin <alexey.brodkin@synopsys.com> wrote:
> > >
> > > Hi Andy,
> > >
> > > > On Fri, 2018-11-09 at 07:17 -0800, Andy Lutomirski wrote:
> > > > On Fri, Nov 9, 2018 at 6:22 AM Alexey Brodkin
> > > > <alexey.brodkin@synopsys.com> wrote:
> > > > > Hi Dmitry,
> > > > >
> > > > > > On Fri, 2018-11-09 at 06:16 +0300, Dmitry V. Levin wrote:
> > > > > > syscall_get_arch() is required to be implemented on all architectures
> > > > > > that use tracehook_report_syscall_entry() in order to extend
> > > > > > the generic ptrace API with PTRACE_GET_SYSCALL_INFO request.
> > > > > >
> > > > > > Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
> > > > > > ---
> > > > > > arch/arc/include/asm/syscall.h | 6 ++++++
> > > > > > include/uapi/linux/audit.h     | 1 +
> > > > > > 2 files changed, 7 insertions(+)
> > > > >
> > > > > [snip]
> > > > >
> > > > > > diff --git a/include/uapi/linux/audit.h b/include/uapi/linux/audit.h
> > > > > > index 818ae690ab79..a7149ceb5b98 100644
> > > > > > --- a/include/uapi/linux/audit.h
> > > > > > +++ b/include/uapi/linux/audit.h
> > > > > > @@ -375,6 +375,7 @@ enum {
> > > > > >
> > > > > > #define AUDIT_ARCH_AARCH64   (EM_AARCH64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
> > > > > > #define AUDIT_ARCH_ALPHA     (EM_ALPHA|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
> > > > > > +#define AUDIT_ARCH_ARC               (EM_ARC)
> > > > >
> > > > > Similarly here we need to have:
> > > > > ---------------------------->8-----------------------------
> > > > > +#define AUDIT_ARCH_ARC         (EM_ARC|EM_ARCV2)
> > > > > ---------------------------->8-----------------------------
> > > > >
> > > >
> > > > Huh?  How does the bitwise or of two ELF machine codes make any sense?
> > >
> > > Oops... I didn't read examples of AUDIT_ARCH_ALPHA above :(
> > > Indeed that was stupid.
> > >
> > > But what would be a proper fix then?
> > >
> > > Something like that?
> > > ---------------------------->8-----------------------------
> > > #define AUDIT_ARCH_ARC               (EM_ARC)
> > > #define AUDIT_ARCH_ARCV2             (EM_ARCV2)
> > >
> > >
> > > static inline int syscall_get_arch(void)
> > > {
> > > #ifdef __ARC700__
> > >       return AUDIT_ARCH_ARC;
> > > #else
> > >       return AUDIT_ARCH_ARCV2;
> > > #endif
> > > }
> > > ---------------------------->8-----------------------------
> > >
> >
> > Maybe, but I know basically nothing about ARC.  Is the syscall numbering or calling convention different on ARC vs ARCv2?
>
> Syscall numbering should be the same as we use UAPI for both ARCompact (AKA ARCv1)
> and ARCv2. As for calling convention I think it indeed differs.
>
> Note ARCompact and ARCv2 ISAs are binary incompatible!
>
> Even though assembly look pretty much the same (sans instructions
> available only for either ARCompact or ARCv2) encodings are different so
> in that sense these are completely different architectures.
>
> Also I'm wondering what could be other cases for use of syscall_get_arch().

The intent of syscall_get_arch() is that the tuple:

(arch, nr, arg1, ..., arg6)

fully identifies a system call and its arguments.  So it sounds like
we do indeed need to arch values.

>
> So I'd say it's better to report different values for ARC ISAs.
> And given we use the same values as in Binutils IMHO it would be good
> to not mix IDs here.
>
> -Alexey



-- 
Andy Lutomirski
AMA Capital Management, LLC

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

* Re: [PATCH 02/13] elf-em.h: add EM_ARC
  2018-11-09  3:15     ` [PATCH 02/13] elf-em.h: add EM_ARC Dmitry V. Levin
  2018-11-09 14:20       ` Alexey Brodkin
@ 2018-11-09 16:41       ` Vineet Gupta
  2018-11-09 21:44         ` Dmitry V. Levin
  1 sibling, 1 reply; 84+ messages in thread
From: Vineet Gupta @ 2018-11-09 16:41 UTC (permalink / raw)
  To: Dmitry V. Levin, Andy Lutomirski
  Cc: Elvira Khabirova, linux-snps-arc, linux-kernel

On 11/8/18 7:15 PM, Dmitry V. Levin wrote:
> The uapi/linux/audit.h header is going to use EM_ARC in order
> to define AUDIT_ARCH_ARC which is needed to implement
> syscall_get_arch() which in turn is required to extend
> the generic ptrace API with PTRACE_GET_SYSCALL_INFO request.
>
> The value for EM_ARC has been taken from
> https://urldefense.proofpoint.com/v2/url?u=http-3A__www.sco.com_developers_gabi_2012-2D12-2D31_ch4.eheader.html&d=DwIBAg&c=DPL6_X_6JkXFx7AXWqB0tg&r=c14YS-cH-kdhTOW89KozFhBtBJgs1zXscZojEZQ0THs&m=UCr-dDO1BWV4K-CXhpcDRnN4Urr4_UgSKBeEaczUAmE&s=XmSWUKeqq324aU46NSTbHc12dH-1vVnA4G3Rm-01WD4&e=
>
> Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
> ---
>  include/uapi/linux/elf-em.h | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/include/uapi/linux/elf-em.h b/include/uapi/linux/elf-em.h
> index ba3696e3d694..56ff3f9d9633 100644
> --- a/include/uapi/linux/elf-em.h
> +++ b/include/uapi/linux/elf-em.h
> @@ -26,6 +26,7 @@
>  #define EM_ARM		40	/* ARM 32 bit */
>  #define EM_SH		42	/* SuperH */
>  #define EM_SPARCV9	43	/* SPARC v9 64-bit */
> +#define EM_ARC		45	/* Argonaut RISC Core */

Please use EM_ARCOMPACT (for original ARC ISA) and EM_ARCV2 - both defined in
arch/arc/include/asm/elf.h

-Vineet

>  #define EM_H8_300	46	/* Renesas H8/300 */
>  #define EM_IA_64	50	/* HP/Intel IA-64 */
>  #define EM_X86_64	62	/* AMD x86-64 */


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

* Re: [PATCH 06/13] arc: define syscall_get_arch()
  2018-11-09  3:16     ` [PATCH 06/13] arc: " Dmitry V. Levin
  2018-11-09 14:22       ` Alexey Brodkin
@ 2018-11-09 16:50       ` Vineet Gupta
  2018-11-09 19:03         ` Andy Lutomirski
  1 sibling, 1 reply; 84+ messages in thread
From: Vineet Gupta @ 2018-11-09 16:50 UTC (permalink / raw)
  To: Dmitry V. Levin, Andy Lutomirski, Paul Moore, Eric Paris
  Cc: Elvira Khabirova, linux-snps-arc, linux-audit, linux-kernel

On 11/8/18 7:16 PM, Dmitry V. Levin wrote:
> syscall_get_arch() is required to be implemented on all architectures
> that use tracehook_report_syscall_entry() in order to extend
> the generic ptrace API with PTRACE_GET_SYSCALL_INFO request.
>
> Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
> ---
>  arch/arc/include/asm/syscall.h | 6 ++++++
>  include/uapi/linux/audit.h     | 1 +
>  2 files changed, 7 insertions(+)
>
> diff --git a/arch/arc/include/asm/syscall.h b/arch/arc/include/asm/syscall.h
> index 29de09804306..5662778a7411 100644
> --- a/arch/arc/include/asm/syscall.h
> +++ b/arch/arc/include/asm/syscall.h
> @@ -9,6 +9,7 @@
>  #ifndef _ASM_ARC_SYSCALL_H
>  #define _ASM_ARC_SYSCALL_H  1
>  
> +#include <uapi/linux/audit.h>
>  #include <linux/err.h>
>  #include <linux/sched.h>
>  #include <asm/unistd.h>
> @@ -68,4 +69,9 @@ syscall_get_arguments(struct task_struct *task, struct pt_regs *regs,
>  	}
>  }
>  
> +static inline int syscall_get_arch(void)
> +{
> +	return AUDIT_ARCH_ARC;
> +}
> +

Does ptrace (or user of this API) need a unique value per arch. Otherwise instead
of adding the boilerplate code to all arches, they could simply define AUDIT_ARCH
and common code could return it. Also the EM_xxx are not there in
include/uapi/linux/elf.h to begin with since libc elf.h already defines them.

>  #endif
> diff --git a/include/uapi/linux/audit.h b/include/uapi/linux/audit.h
> index 818ae690ab79..a7149ceb5b98 100644
> --- a/include/uapi/linux/audit.h
> +++ b/include/uapi/linux/audit.h
> @@ -375,6 +375,7 @@ enum {
>  
>  #define AUDIT_ARCH_AARCH64	(EM_AARCH64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
>  #define AUDIT_ARCH_ALPHA	(EM_ALPHA|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
> +#define AUDIT_ARCH_ARC		(EM_ARC)
>  #define AUDIT_ARCH_ARM		(EM_ARM|__AUDIT_ARCH_LE)
>  #define AUDIT_ARCH_ARMEB	(EM_ARM)
>  #define AUDIT_ARCH_CRIS		(EM_CRIS|__AUDIT_ARCH_LE)

So I don't have the context of this patch (or coverletter) but what exactly are we
trying to do with this (adding LE to audit)  - what happens when an arch is
capable of either and is say built for BE ?

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

* Re: [PATCH 12/13] riscv: define syscall_get_arch()
  2018-11-09  3:17     ` [PATCH 12/13] riscv: " Dmitry V. Levin
  2018-11-09  6:59       ` David Abdurachmanov
@ 2018-11-09 18:45       ` Palmer Dabbelt
  2018-11-09 21:31         ` Dmitry V. Levin
  1 sibling, 1 reply; 84+ messages in thread
From: Palmer Dabbelt @ 2018-11-09 18:45 UTC (permalink / raw)
  To: ldv
  Cc: luto, aou, paul, eparis, lineprinter, linux-riscv, linux-audit,
	linux-kernel

On Thu, 08 Nov 2018 19:17:13 PST (-0800), ldv@altlinux.org wrote:
> syscall_get_arch() is required to be implemented on all architectures
> that use tracehook_report_syscall_entry() in order to extend
> the generic ptrace API with PTRACE_GET_SYSCALL_INFO request.
>
> Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
> ---
>  arch/riscv/include/asm/syscall.h | 6 ++++++
>  include/uapi/linux/audit.h       | 1 +
>  2 files changed, 7 insertions(+)
>
> diff --git a/arch/riscv/include/asm/syscall.h b/arch/riscv/include/asm/syscall.h
> index 8d25f8904c00..7e1e26ca7317 100644
> --- a/arch/riscv/include/asm/syscall.h
> +++ b/arch/riscv/include/asm/syscall.h
> @@ -18,6 +18,7 @@
>  #ifndef _ASM_RISCV_SYSCALL_H
>  #define _ASM_RISCV_SYSCALL_H
>
> +#include <uapi/linux/audit.h>
>  #include <linux/sched.h>
>  #include <linux/err.h>
>
> @@ -99,4 +100,9 @@ static inline void syscall_set_arguments(struct task_struct *task,
>  	memcpy(&regs->a1 + i * sizeof(regs->a1), args, n * sizeof(regs->a0));
>  }
>
> +static inline int syscall_get_arch(void)
> +{
> +	return AUDIT_ARCH_RISCV;
> +}
> +
>  #endif	/* _ASM_RISCV_SYSCALL_H */
> diff --git a/include/uapi/linux/audit.h b/include/uapi/linux/audit.h
> index c4c8b131af48..ad4105c602a1 100644
> --- a/include/uapi/linux/audit.h
> +++ b/include/uapi/linux/audit.h
> @@ -405,6 +405,7 @@ enum {
>  /* do not define AUDIT_ARCH_PPCLE since it is not supported by audit */
>  #define AUDIT_ARCH_PPC64	(EM_PPC64|__AUDIT_ARCH_64BIT)
>  #define AUDIT_ARCH_PPC64LE	(EM_PPC64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
> +#define AUDIT_ARCH_RISCV	(EM_RISCV|__AUDIT_ARCH_64BIT)
>  #define AUDIT_ARCH_S390		(EM_S390)
>  #define AUDIT_ARCH_S390X	(EM_S390|__AUDIT_ARCH_64BIT)
>  #define AUDIT_ARCH_SH		(EM_SH)

I think this is incorrect: EM_RISCV has 32-bit and 64-bit variants, and if I 
understand what's going on here this is marking all RISC-V targets as 64-bit.  
Since this is a userspace header, I think the right thing to switch on is 
__riscv_xlen, which will be defined to either 32 or 64 depending on the base 
ISA.

We're also little endian.

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

* Re: [PATCH 06/13] arc: define syscall_get_arch()
  2018-11-09 16:50       ` [PATCH 06/13] " Vineet Gupta
@ 2018-11-09 19:03         ` Andy Lutomirski
  2018-11-09 19:13           ` Vineet Gupta
  0 siblings, 1 reply; 84+ messages in thread
From: Andy Lutomirski @ 2018-11-09 19:03 UTC (permalink / raw)
  To: Vineet Gupta
  Cc: Dmitry V. Levin, Andy Lutomirski, Paul Moore, Eric Paris,
	Elvira Khabirova, linux-snps-arc, linux-audit, linux-kernel



> On Nov 9, 2018, at 8:50 AM, Vineet Gupta <vineet.gupta1@synopsys.com> wrote:
> 
>> On 11/8/18 7:16 PM, Dmitry V. Levin wrote:
>> syscall_get_arch() is required to be implemented on all architectures
>> that use tracehook_report_syscall_entry() in order to extend
>> the generic ptrace API with PTRACE_GET_SYSCALL_INFO request.
>> 
>> Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
>> ---
>> arch/arc/include/asm/syscall.h | 6 ++++++
>> include/uapi/linux/audit.h     | 1 +
>> 2 files changed, 7 insertions(+)
>> 
>> diff --git a/arch/arc/include/asm/syscall.h b/arch/arc/include/asm/syscall.h
>> index 29de09804306..5662778a7411 100644
>> --- a/arch/arc/include/asm/syscall.h
>> +++ b/arch/arc/include/asm/syscall.h
>> @@ -9,6 +9,7 @@
>> #ifndef _ASM_ARC_SYSCALL_H
>> #define _ASM_ARC_SYSCALL_H  1
>> 
>> +#include <uapi/linux/audit.h>
>> #include <linux/err.h>
>> #include <linux/sched.h>
>> #include <asm/unistd.h>
>> @@ -68,4 +69,9 @@ syscall_get_arguments(struct task_struct *task, struct pt_regs *regs,
>>    }
>> }
>> 
>> +static inline int syscall_get_arch(void)
>> +{
>> +    return AUDIT_ARCH_ARC;
>> +}
>> +
> 
> Does ptrace (or user of this API) need a unique value per arch. Otherwise instead
> of adding the boilerplate code to all arches, they could simply define AUDIT_ARCH
> and common code could return it. Also the EM_xxx are not there in
> include/uapi/linux/elf.h to begin with since libc elf.h already defines them.

A lot of architectures allow multiple audit_arches at runtime due to compat support and similar features, so it really does want to be a function.  The goal of this patch set is to get it supported everywhere.

>> #endif
>> diff --git a/include/uapi/linux/audit.h b/include/uapi/linux/audit.h
>> index 818ae690ab79..a7149ceb5b98 100644
>> --- a/include/uapi/linux/audit.h
>> +++ b/include/uapi/linux/audit.h
>> @@ -375,6 +375,7 @@ enum {
>> 
>> #define AUDIT_ARCH_AARCH64    (EM_AARCH64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
>> #define AUDIT_ARCH_ALPHA    (EM_ALPHA|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
>> +#define AUDIT_ARCH_ARC        (EM_ARC)
>> #define AUDIT_ARCH_ARM        (EM_ARM|__AUDIT_ARCH_LE)
>> #define AUDIT_ARCH_ARMEB    (EM_ARM)
>> #define AUDIT_ARCH_CRIS        (EM_CRIS|__AUDIT_ARCH_LE)
> 
> So I don't have the context of this patch (or coverletter) but what exactly are we
> trying to do with this (adding LE to audit)  - what happens when an arch is
> capable of either and is say built for BE ?

The primary intent is that the triple (audit_arch, syscall_nr, arg1, ..., arg6) should describe what system call is being called and what its arguments are.  I’m personally not sure what, if any, technical value there is in the LE bit.

I do think it makes sense for BE and LE to have different values.

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

* Re: [PATCH 06/13] arc: define syscall_get_arch()
  2018-11-09 19:03         ` Andy Lutomirski
@ 2018-11-09 19:13           ` Vineet Gupta
  0 siblings, 0 replies; 84+ messages in thread
From: Vineet Gupta @ 2018-11-09 19:13 UTC (permalink / raw)
  To: Andy Lutomirski
  Cc: Dmitry V. Levin, Andy Lutomirski, Paul Moore, Eric Paris,
	Elvira Khabirova, linux-snps-arc, linux-audit, linux-kernel

On 11/9/18 11:03 AM, Andy Lutomirski wrote:
>> Does ptrace (or user of this API) need a unique value per arch. Otherwise instead
>> of adding the boilerplate code to all arches, they could simply define AUDIT_ARCH
>> and common code could return it. Also the EM_xxx are not there in
>> include/uapi/linux/elf.h to begin with since libc elf.h already defines them.
>>
> A lot of architectures allow multiple audit_arches at runtime due to compat support and similar features, so it really does want to be a function.  The goal of this patch set is to get it supported everywhere.
> 

I was wondering if we could have a common syscall_get_arch() simply returning an
per-arch AUDIT_ARCH. But seems like the function itself needs to be per arch
anyways due to the nuances above.


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

* Re: [PATCH 12/13] riscv: define syscall_get_arch()
  2018-11-09 18:45       ` Palmer Dabbelt
@ 2018-11-09 21:31         ` Dmitry V. Levin
  2018-11-09 22:48           ` [PATCH 12/13 v2] " Dmitry V. Levin
  0 siblings, 1 reply; 84+ messages in thread
From: Dmitry V. Levin @ 2018-11-09 21:31 UTC (permalink / raw)
  To: Palmer Dabbelt
  Cc: Andy Lutomirski, Elvira Khabirova, Albert Ou, Paul Moore,
	Eric Paris, linux-riscv, linux-audit, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 2602 bytes --]

On Fri, Nov 09, 2018 at 10:45:54AM -0800, Palmer Dabbelt wrote:
> On Thu, 08 Nov 2018 19:17:13 PST (-0800), ldv@altlinux.org wrote:
> > syscall_get_arch() is required to be implemented on all architectures
> > that use tracehook_report_syscall_entry() in order to extend
> > the generic ptrace API with PTRACE_GET_SYSCALL_INFO request.
> >
> > Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
> > ---
> >  arch/riscv/include/asm/syscall.h | 6 ++++++
> >  include/uapi/linux/audit.h       | 1 +
> >  2 files changed, 7 insertions(+)
> >
> > diff --git a/arch/riscv/include/asm/syscall.h b/arch/riscv/include/asm/syscall.h
> > index 8d25f8904c00..7e1e26ca7317 100644
> > --- a/arch/riscv/include/asm/syscall.h
> > +++ b/arch/riscv/include/asm/syscall.h
> > @@ -18,6 +18,7 @@
> >  #ifndef _ASM_RISCV_SYSCALL_H
> >  #define _ASM_RISCV_SYSCALL_H
> >
> > +#include <uapi/linux/audit.h>
> >  #include <linux/sched.h>
> >  #include <linux/err.h>
> >
> > @@ -99,4 +100,9 @@ static inline void syscall_set_arguments(struct task_struct *task,
> >  	memcpy(&regs->a1 + i * sizeof(regs->a1), args, n * sizeof(regs->a0));
> >  }
> >
> > +static inline int syscall_get_arch(void)
> > +{
> > +	return AUDIT_ARCH_RISCV;
> > +}
> > +
> >  #endif	/* _ASM_RISCV_SYSCALL_H */
> > diff --git a/include/uapi/linux/audit.h b/include/uapi/linux/audit.h
> > index c4c8b131af48..ad4105c602a1 100644
> > --- a/include/uapi/linux/audit.h
> > +++ b/include/uapi/linux/audit.h
> > @@ -405,6 +405,7 @@ enum {
> >  /* do not define AUDIT_ARCH_PPCLE since it is not supported by audit */
> >  #define AUDIT_ARCH_PPC64	(EM_PPC64|__AUDIT_ARCH_64BIT)
> >  #define AUDIT_ARCH_PPC64LE	(EM_PPC64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
> > +#define AUDIT_ARCH_RISCV	(EM_RISCV|__AUDIT_ARCH_64BIT)
> >  #define AUDIT_ARCH_S390		(EM_S390)
> >  #define AUDIT_ARCH_S390X	(EM_S390|__AUDIT_ARCH_64BIT)
> >  #define AUDIT_ARCH_SH		(EM_SH)
> 
> I think this is incorrect: EM_RISCV has 32-bit and 64-bit variants, and if I 
> understand what's going on here this is marking all RISC-V targets as 64-bit.  
> Since this is a userspace header, I think the right thing to switch on is 
> __riscv_xlen, which will be defined to either 32 or 64 depending on the base 
> ISA.
> We're also little endian.

OK, it means we need to introduce two different AUDIT_ARCH_ constants
for RISC-V.  Do you have any preferences for their names,
e.g. AUDIT_ARCH_RISCV and AUDIT_ARCH_RISCV64, or
AUDIT_ARCH_RISCV and AUDIT_ARCH_RISCV32, or
AUDIT_ARCH_RISCV64 and AUDIT_ARCH_RISCV32,
or anything else?


-- 
ldv

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

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

* Re: [PATCH 02/13] elf-em.h: add EM_ARC
  2018-11-09 16:41       ` Vineet Gupta
@ 2018-11-09 21:44         ` Dmitry V. Levin
  2018-11-09 23:33           ` [PATCH 02/13 v2] Move EM_ARCOMPACT and EM_ARCV2 to uapi/linux/elf-em.h Dmitry V. Levin
  0 siblings, 1 reply; 84+ messages in thread
From: Dmitry V. Levin @ 2018-11-09 21:44 UTC (permalink / raw)
  To: Vineet Gupta
  Cc: Andy Lutomirski, Elvira Khabirova, linux-snps-arc, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1585 bytes --]

On Fri, Nov 09, 2018 at 04:41:36PM +0000, Vineet Gupta wrote:
> On 11/8/18 7:15 PM, Dmitry V. Levin wrote:
> > The uapi/linux/audit.h header is going to use EM_ARC in order
> > to define AUDIT_ARCH_ARC which is needed to implement
> > syscall_get_arch() which in turn is required to extend
> > the generic ptrace API with PTRACE_GET_SYSCALL_INFO request.
> >
> > The value for EM_ARC has been taken from
> > https://urldefense.proofpoint.com/v2/url?u=http-3A__www.sco.com_developers_gabi_2012-2D12-2D31_ch4.eheader.html&d=DwIBAg&c=DPL6_X_6JkXFx7AXWqB0tg&r=c14YS-cH-kdhTOW89KozFhBtBJgs1zXscZojEZQ0THs&m=UCr-dDO1BWV4K-CXhpcDRnN4Urr4_UgSKBeEaczUAmE&s=XmSWUKeqq324aU46NSTbHc12dH-1vVnA4G3Rm-01WD4&e=
> >
> > Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
> > ---
> >  include/uapi/linux/elf-em.h | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/include/uapi/linux/elf-em.h b/include/uapi/linux/elf-em.h
> > index ba3696e3d694..56ff3f9d9633 100644
> > --- a/include/uapi/linux/elf-em.h
> > +++ b/include/uapi/linux/elf-em.h
> > @@ -26,6 +26,7 @@
> >  #define EM_ARM		40	/* ARM 32 bit */
> >  #define EM_SH		42	/* SuperH */
> >  #define EM_SPARCV9	43	/* SPARC v9 64-bit */
> > +#define EM_ARC		45	/* Argonaut RISC Core */
> 
> Please use EM_ARCOMPACT (for original ARC ISA) and EM_ARCV2 - both defined in
> arch/arc/include/asm/elf.h

OK, but we would have to move both EM_ARCOMPACT and EM_ARCV2
to include/uapi/linux/elf-em.h file first, so they could be used
to define AUDIT_ARCH_* constants in include/uapi/linux/audit.h file.


-- 
ldv

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

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

* Re: [PATCH 12/13] riscv: define syscall_get_arch()
  2018-11-09  6:59       ` David Abdurachmanov
@ 2018-11-09 22:28         ` Dmitry V. Levin
  2018-11-10  5:12           ` David Abdurachmanov
  2018-11-10  9:27           ` Andreas Schwab
  0 siblings, 2 replies; 84+ messages in thread
From: Dmitry V. Levin @ 2018-11-09 22:28 UTC (permalink / raw)
  To: David Abdurachmanov
  Cc: Andy Lutomirski, Palmer Dabbelt, aou, Paul Moore, eparis,
	Elvira Khabirova, linux-riscv, linux-audit, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 769 bytes --]

On Fri, Nov 09, 2018 at 07:59:13AM +0100, David Abdurachmanov wrote:
> On Fri, Nov 9, 2018 at 4:17 AM Dmitry V. Levin <ldv@altlinux.org> wrote:
> >
> > syscall_get_arch() is required to be implemented on all architectures
> > that use tracehook_report_syscall_entry() in order to extend
> > the generic ptrace API with PTRACE_GET_SYSCALL_INFO request.
> 
> I have posted audit support patch for RISC-V in October. Pending review.
> It defines both AUDIT_ARCH_RISCV32 and AUDIT_ARCH_RISCV64.
> 
> See thread: http://lists.infradead.org/pipermail/linux-riscv/2018-October/001933.html

I'll take your version of RISC-V related change of include/uapi/linux/audit.h
to this series, thanks!

P.S. It would be great if you replied to me as well.


-- 
ldv

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

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

* [PATCH 12/13 v2] riscv: define syscall_get_arch()
  2018-11-09 21:31         ` Dmitry V. Levin
@ 2018-11-09 22:48           ` Dmitry V. Levin
  2018-11-11 21:21             ` Palmer Dabbelt
  0 siblings, 1 reply; 84+ messages in thread
From: Dmitry V. Levin @ 2018-11-09 22:48 UTC (permalink / raw)
  To: Palmer Dabbelt
  Cc: Andy Lutomirski, Elvira Khabirova, David Abdurachmanov,
	Albert Ou, Paul Moore, Eric Paris, linux-riscv, linux-audit,
	linux-kernel

syscall_get_arch() is required to be implemented on all architectures
that use tracehook_report_syscall_entry() in order to extend
the generic ptrace API with PTRACE_GET_SYSCALL_INFO request.

Based-on-patch-by: David Abdurachmanov <david.abdurachmanov@gmail.com>
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
---
 arch/riscv/include/asm/syscall.h | 10 ++++++++++
 include/uapi/linux/audit.h       |  2 ++
 2 files changed, 12 insertions(+)

diff --git a/arch/riscv/include/asm/syscall.h b/arch/riscv/include/asm/syscall.h
index 8d25f8904c00..bba3da6ef157 100644
--- a/arch/riscv/include/asm/syscall.h
+++ b/arch/riscv/include/asm/syscall.h
@@ -18,6 +18,7 @@
 #ifndef _ASM_RISCV_SYSCALL_H
 #define _ASM_RISCV_SYSCALL_H
 
+#include <uapi/linux/audit.h>
 #include <linux/sched.h>
 #include <linux/err.h>
 
@@ -99,4 +100,13 @@ static inline void syscall_set_arguments(struct task_struct *task,
 	memcpy(&regs->a1 + i * sizeof(regs->a1), args, n * sizeof(regs->a0));
 }
 
+static inline int syscall_get_arch(void)
+{
+#ifdef CONFIG_64BIT
+	return AUDIT_ARCH_RISCV64;
+#else
+	return AUDIT_ARCH_RISCV32;
+#endif
+}
+
 #endif	/* _ASM_RISCV_SYSCALL_H */
diff --git a/include/uapi/linux/audit.h b/include/uapi/linux/audit.h
index c4c8b131af48..1b199a77a6b9 100644
--- a/include/uapi/linux/audit.h
+++ b/include/uapi/linux/audit.h
@@ -405,6 +405,8 @@ enum {
 /* do not define AUDIT_ARCH_PPCLE since it is not supported by audit */
 #define AUDIT_ARCH_PPC64	(EM_PPC64|__AUDIT_ARCH_64BIT)
 #define AUDIT_ARCH_PPC64LE	(EM_PPC64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
+#define AUDIT_ARCH_RISCV32	(EM_RISCV|__AUDIT_ARCH_LE)
+#define AUDIT_ARCH_RISCV64	(EM_RISCV|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
 #define AUDIT_ARCH_S390		(EM_S390)
 #define AUDIT_ARCH_S390X	(EM_S390|__AUDIT_ARCH_64BIT)
 #define AUDIT_ARCH_SH		(EM_SH)
-- 
ldv

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

* [PATCH 02/13 v2] Move EM_ARCOMPACT and EM_ARCV2 to uapi/linux/elf-em.h
  2018-11-09 21:44         ` Dmitry V. Levin
@ 2018-11-09 23:33           ` Dmitry V. Levin
  2018-11-09 23:42             ` Vineet Gupta
  0 siblings, 1 reply; 84+ messages in thread
From: Dmitry V. Levin @ 2018-11-09 23:33 UTC (permalink / raw)
  To: Vineet Gupta, Andy Lutomirski
  Cc: Elvira Khabirova, Alexey Brodkin, linux-snps-arc, linux-kernel

These should never have been defined in the arch tree to begin with, and
now uapi/linux/audit.h header is going to use EM_ARCOMPACT and EM_ARCV2 in
order to define AUDIT_ARCH_ARCOMPACT and AUDIT_ARCH_ARCV2 which are needed
to implement syscall_get_arch() which in turn is required to extend the
generic ptrace API with PTRACE_GET_SYSCALL_INFO request.

Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
---
v2: do not add EM_ARC, move EM_ARCOMPACT and EM_ARCV2 instead.

 arch/arc/include/asm/elf.h  | 6 +-----
 include/uapi/linux/elf-em.h | 2 ++
 2 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/arch/arc/include/asm/elf.h b/arch/arc/include/asm/elf.h
index aa2d6da9d187..2b80c184c9c8 100644
--- a/arch/arc/include/asm/elf.h
+++ b/arch/arc/include/asm/elf.h
@@ -10,13 +10,9 @@
 #define __ASM_ARC_ELF_H
 
 #include <linux/types.h>
+#include <linux/elf-em.h>
 #include <uapi/asm/elf.h>
 
-/* These ELF defines belong to uapi but libc elf.h already defines them */
-#define EM_ARCOMPACT		93
-
-#define EM_ARCV2		195	/* ARCv2 Cores */
-
 #define EM_ARC_INUSE		(IS_ENABLED(CONFIG_ISA_ARCOMPACT) ? \
 					EM_ARCOMPACT : EM_ARCV2)
 
diff --git a/include/uapi/linux/elf-em.h b/include/uapi/linux/elf-em.h
index ba3696e3d694..91b33833630b 100644
--- a/include/uapi/linux/elf-em.h
+++ b/include/uapi/linux/elf-em.h
@@ -34,6 +34,7 @@
 #define EM_M32R		88	/* Renesas M32R */
 #define EM_MN10300	89	/* Panasonic/MEI MN10300, AM33 */
 #define EM_OPENRISC     92     /* OpenRISC 32-bit embedded processor */
+#define EM_ARCOMPACT	93	/* ARCompact processor */
 #define EM_BLACKFIN     106     /* ADI Blackfin Processor */
 #define EM_ALTERA_NIOS2	113	/* Altera Nios II soft-core processor */
 #define EM_TI_C6000	140	/* TI C6X DSPs */
@@ -42,6 +43,7 @@
 #define EM_TILEPRO	188	/* Tilera TILEPro */
 #define EM_MICROBLAZE	189	/* Xilinx MicroBlaze */
 #define EM_TILEGX	191	/* Tilera TILE-Gx */
+#define EM_ARCV2	195	/* ARCv2 Cores */
 #define EM_RISCV	243	/* RISC-V */
 #define EM_BPF		247	/* Linux BPF - in-kernel virtual machine */
 #define EM_FRV		0x5441	/* Fujitsu FR-V */
-- 
ldv

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

* [PATCH 06/13 v2] arc: define syscall_get_arch()
  2018-11-09 16:35                 ` Andy Lutomirski
@ 2018-11-09 23:33                   ` Dmitry V. Levin
  2018-11-09 23:39                     ` Vineet Gupta
  0 siblings, 1 reply; 84+ messages in thread
From: Dmitry V. Levin @ 2018-11-09 23:33 UTC (permalink / raw)
  To: Andrew Lutomirski, Alexey Brodkin, Vineet Gupta
  Cc: Elvira Khabirova, Paul Moore, Eric Paris, linux-snps-arc,
	linux-audit, linux-kernel

syscall_get_arch() is required to be implemented on all architectures
that use tracehook_report_syscall_entry() in order to extend
the generic ptrace API with PTRACE_GET_SYSCALL_INFO request.

Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
---
v2: define AUDIT_ARCH_ARCOMPACT, AUDIT_ARCH_ARCOMPACTLE, AUDIT_ARCH_ARCV2,
and AUDIT_ARCH_ARCV2LE instead of AUDIT_ARCH_ARC, update
syscall_get_arch() implementation accordingly.

 arch/arc/include/asm/syscall.h | 18 ++++++++++++++++++
 include/uapi/linux/audit.h     |  4 ++++
 2 files changed, 22 insertions(+)

diff --git a/arch/arc/include/asm/syscall.h b/arch/arc/include/asm/syscall.h
index 29de09804306..a1b698290778 100644
--- a/arch/arc/include/asm/syscall.h
+++ b/arch/arc/include/asm/syscall.h
@@ -9,6 +9,7 @@
 #ifndef _ASM_ARC_SYSCALL_H
 #define _ASM_ARC_SYSCALL_H  1
 
+#include <uapi/linux/audit.h>
 #include <linux/err.h>
 #include <linux/sched.h>
 #include <asm/unistd.h>
@@ -68,4 +69,21 @@ syscall_get_arguments(struct task_struct *task, struct pt_regs *regs,
 	}
 }
 
+static inline int syscall_get_arch(void)
+{
+#ifdef CONFIG_ISA_ARCOMPACT
+# ifdef CONFIG_CPU_BIG_ENDIAN
+	return AUDIT_ARCH_ARCOMPACT;
+# else
+	return AUDIT_ARCH_ARCOMPACTLE;
+# endif
+#else	/* CONFIG_ISA_ARCV2 */
+# ifdef CONFIG_CPU_BIG_ENDIAN
+	return AUDIT_ARCH_ARCV2;
+# else
+	return AUDIT_ARCH_ARCV2LE;
+# endif
+#endif
+}
+
 #endif
diff --git a/include/uapi/linux/audit.h b/include/uapi/linux/audit.h
index 818ae690ab79..8e70fb70b8f8 100644
--- a/include/uapi/linux/audit.h
+++ b/include/uapi/linux/audit.h
@@ -375,6 +375,10 @@ enum {
 
 #define AUDIT_ARCH_AARCH64	(EM_AARCH64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
 #define AUDIT_ARCH_ALPHA	(EM_ALPHA|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
+#define AUDIT_ARCH_ARCOMPACT	(EM_ARCOMPACT)
+#define AUDIT_ARCH_ARCOMPACTLE	(EM_ARCOMPACT|__AUDIT_ARCH_LE)
+#define AUDIT_ARCH_ARCV2	(EM_ARCV2)
+#define AUDIT_ARCH_ARCV2LE	(EM_ARCV2|__AUDIT_ARCH_LE)
 #define AUDIT_ARCH_ARM		(EM_ARM|__AUDIT_ARCH_LE)
 #define AUDIT_ARCH_ARMEB	(EM_ARM)
 #define AUDIT_ARCH_CRIS		(EM_CRIS|__AUDIT_ARCH_LE)
-- 
ldv

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

* Re: [PATCH 06/13 v2] arc: define syscall_get_arch()
  2018-11-09 23:33                   ` [PATCH 06/13 v2] " Dmitry V. Levin
@ 2018-11-09 23:39                     ` Vineet Gupta
  2018-11-09 23:54                       ` [PATCH 06/13 v3] " Dmitry V. Levin
  0 siblings, 1 reply; 84+ messages in thread
From: Vineet Gupta @ 2018-11-09 23:39 UTC (permalink / raw)
  To: Dmitry V. Levin, Andrew Lutomirski, Alexey Brodkin, Vineet Gupta
  Cc: Elvira Khabirova, Paul Moore, Eric Paris, linux-snps-arc,
	linux-audit, linux-kernel

On 11/9/18 3:33 PM, Dmitry V. Levin wrote:
> syscall_get_arch() is required to be implemented on all architectures
> that use tracehook_report_syscall_entry() in order to extend
> the generic ptrace API with PTRACE_GET_SYSCALL_INFO request.
>
> Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
> ---
> v2: define AUDIT_ARCH_ARCOMPACT, AUDIT_ARCH_ARCOMPACTLE, AUDIT_ARCH_ARCV2,
> and AUDIT_ARCH_ARCV2LE instead of AUDIT_ARCH_ARC, update
> syscall_get_arch() implementation accordingly.
>
>  arch/arc/include/asm/syscall.h | 18 ++++++++++++++++++
>  include/uapi/linux/audit.h     |  4 ++++
>  2 files changed, 22 insertions(+)
>
> diff --git a/arch/arc/include/asm/syscall.h b/arch/arc/include/asm/syscall.h
> index 29de09804306..a1b698290778 100644
> --- a/arch/arc/include/asm/syscall.h
> +++ b/arch/arc/include/asm/syscall.h
> @@ -9,6 +9,7 @@
>  #ifndef _ASM_ARC_SYSCALL_H
>  #define _ASM_ARC_SYSCALL_H  1
>  
> +#include <uapi/linux/audit.h>
>  #include <linux/err.h>
>  #include <linux/sched.h>
>  #include <asm/unistd.h>
> @@ -68,4 +69,21 @@ syscall_get_arguments(struct task_struct *task, struct pt_regs *regs,
>  	}
>  }
>  
> +static inline int syscall_get_arch(void)
> +{
> +#ifdef CONFIG_ISA_ARCOMPACT
> +# ifdef CONFIG_CPU_BIG_ENDIAN
> +	return AUDIT_ARCH_ARCOMPACT;
> +# else
> +	return AUDIT_ARCH_ARCOMPACTLE;
> +# endif
> +#else	/* CONFIG_ISA_ARCV2 */
> +# ifdef CONFIG_CPU_BIG_ENDIAN
> +	return AUDIT_ARCH_ARCV2;
> +# else
> +	return AUDIT_ARCH_ARCV2LE;
> +# endif
> +#endif
> +}

Bike shedding, but will using IS_ENABLED make the code any better.


> +
>  #endif
> diff --git a/include/uapi/linux/audit.h b/include/uapi/linux/audit.h
> index 818ae690ab79..8e70fb70b8f8 100644
> --- a/include/uapi/linux/audit.h
> +++ b/include/uapi/linux/audit.h
> @@ -375,6 +375,10 @@ enum {
>  
>  #define AUDIT_ARCH_AARCH64	(EM_AARCH64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
>  #define AUDIT_ARCH_ALPHA	(EM_ALPHA|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
> +#define AUDIT_ARCH_ARCOMPACT	(EM_ARCOMPACT)
> +#define AUDIT_ARCH_ARCOMPACTLE	(EM_ARCOMPACT|__AUDIT_ARCH_LE)
> +#define AUDIT_ARCH_ARCV2	(EM_ARCV2)
> +#define AUDIT_ARCH_ARCV2LE	(EM_ARCV2|__AUDIT_ARCH_LE)

More Bike shedding, can we make LE as default and add BE suffixes variants please.

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

* Re: [PATCH 02/13 v2] Move EM_ARCOMPACT and EM_ARCV2 to uapi/linux/elf-em.h
  2018-11-09 23:33           ` [PATCH 02/13 v2] Move EM_ARCOMPACT and EM_ARCV2 to uapi/linux/elf-em.h Dmitry V. Levin
@ 2018-11-09 23:42             ` Vineet Gupta
  0 siblings, 0 replies; 84+ messages in thread
From: Vineet Gupta @ 2018-11-09 23:42 UTC (permalink / raw)
  To: Dmitry V. Levin, Andy Lutomirski
  Cc: Elvira Khabirova, Alexey Brodkin, linux-snps-arc, linux-kernel

On 11/9/18 3:33 PM, Dmitry V. Levin wrote:
> These should never have been defined in the arch tree to begin with, and
> now uapi/linux/audit.h header is going to use EM_ARCOMPACT and EM_ARCV2 in
> order to define AUDIT_ARCH_ARCOMPACT and AUDIT_ARCH_ARCV2 which are needed
> to implement syscall_get_arch() which in turn is required to extend the
> generic ptrace API with PTRACE_GET_SYSCALL_INFO request.
>
> Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
> ---
> v2: do not add EM_ARC, move EM_ARCOMPACT and EM_ARCV2 instead.
>
>  arch/arc/include/asm/elf.h  | 6 +-----
>  include/uapi/linux/elf-em.h | 2 ++
>  2 files changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/arch/arc/include/asm/elf.h b/arch/arc/include/asm/elf.h
> index aa2d6da9d187..2b80c184c9c8 100644
> --- a/arch/arc/include/asm/elf.h
> +++ b/arch/arc/include/asm/elf.h
> @@ -10,13 +10,9 @@
>  #define __ASM_ARC_ELF_H
>  
>  #include <linux/types.h>
> +#include <linux/elf-em.h>
>  #include <uapi/asm/elf.h>
>  
> -/* These ELF defines belong to uapi but libc elf.h already defines them */
> -#define EM_ARCOMPACT		93
> -
> -#define EM_ARCV2		195	/* ARCv2 Cores */
> -
>  #define EM_ARC_INUSE		(IS_ENABLED(CONFIG_ISA_ARCOMPACT) ? \
>  					EM_ARCOMPACT : EM_ARCV2)
>  
> diff --git a/include/uapi/linux/elf-em.h b/include/uapi/linux/elf-em.h
> index ba3696e3d694..91b33833630b 100644
> --- a/include/uapi/linux/elf-em.h
> +++ b/include/uapi/linux/elf-em.h
> @@ -34,6 +34,7 @@
>  #define EM_M32R		88	/* Renesas M32R */
>  #define EM_MN10300	89	/* Panasonic/MEI MN10300, AM33 */
>  #define EM_OPENRISC     92     /* OpenRISC 32-bit embedded processor */
> +#define EM_ARCOMPACT	93	/* ARCompact processor */
>  #define EM_BLACKFIN     106     /* ADI Blackfin Processor */
>  #define EM_ALTERA_NIOS2	113	/* Altera Nios II soft-core processor */
>  #define EM_TI_C6000	140	/* TI C6X DSPs */
> @@ -42,6 +43,7 @@
>  #define EM_TILEPRO	188	/* Tilera TILEPro */
>  #define EM_MICROBLAZE	189	/* Xilinx MicroBlaze */
>  #define EM_TILEGX	191	/* Tilera TILE-Gx */
> +#define EM_ARCV2	195	/* ARCv2 Cores */
>  #define EM_RISCV	243	/* RISC-V */
>  #define EM_BPF		247	/* Linux BPF - in-kernel virtual machine */
>  #define EM_FRV		0x5441	/* Fujitsu FR-V */

Seems OK in theory - but now we are exporting these to uapi and per my original
comment there were redef errors with libc elf.h atleast. Perhaps this being a
different header might be OK !

Acked-by: Vineet Gupta <vgupta@synopsys.com>




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

* [PATCH 06/13 v3] arc: define syscall_get_arch()
  2018-11-09 23:39                     ` Vineet Gupta
@ 2018-11-09 23:54                       ` Dmitry V. Levin
  2018-11-10  0:06                         ` Vineet Gupta
  0 siblings, 1 reply; 84+ messages in thread
From: Dmitry V. Levin @ 2018-11-09 23:54 UTC (permalink / raw)
  To: Vineet Gupta, Andrew Lutomirski, Alexey Brodkin
  Cc: Elvira Khabirova, Paul Moore, Eric Paris, linux-snps-arc,
	linux-audit, linux-kernel

syscall_get_arch() is required to be implemented on all architectures
that use tracehook_report_syscall_entry() in order to extend
the generic ptrace API with PTRACE_GET_SYSCALL_INFO request.

Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
---
v3: replaced #ifdefs with IS_ENABLED,
    made LE as default, added BE suffixes variants
v2: defined AUDIT_ARCH_ARCOMPACT, AUDIT_ARCH_ARCOMPACTLE, AUDIT_ARCH_ARCV2,
    and AUDIT_ARCH_ARCV2LE instead of AUDIT_ARCH_ARC,
    updated syscall_get_arch() implementation accordingly.

 arch/arc/include/asm/syscall.h | 10 ++++++++++
 include/uapi/linux/audit.h     |  4 ++++
 2 files changed, 14 insertions(+)

diff --git a/arch/arc/include/asm/syscall.h b/arch/arc/include/asm/syscall.h
index 29de09804306..10b2e7523bc8 100644
--- a/arch/arc/include/asm/syscall.h
+++ b/arch/arc/include/asm/syscall.h
@@ -9,6 +9,7 @@
 #ifndef _ASM_ARC_SYSCALL_H
 #define _ASM_ARC_SYSCALL_H  1
 
+#include <uapi/linux/audit.h>
 #include <linux/err.h>
 #include <linux/sched.h>
 #include <asm/unistd.h>
@@ -68,4 +69,13 @@ syscall_get_arguments(struct task_struct *task, struct pt_regs *regs,
 	}
 }
 
+static inline int syscall_get_arch(void)
+{
+	return IS_ENABLED(CONFIG_ISA_ARCOMPACT)
+		? (IS_ENABLED(CONFIG_CPU_BIG_ENDIAN)
+			? AUDIT_ARCH_ARCOMPACTBE : AUDIT_ARCH_ARCOMPACT)
+		: (IS_ENABLED(CONFIG_CPU_BIG_ENDIAN)
+			? AUDIT_ARCH_ARCV2BE : AUDIT_ARCH_ARCV2);
+}
+
 #endif
diff --git a/include/uapi/linux/audit.h b/include/uapi/linux/audit.h
index 818ae690ab79..bedf3bf54c3a 100644
--- a/include/uapi/linux/audit.h
+++ b/include/uapi/linux/audit.h
@@ -375,6 +375,10 @@ enum {
 
 #define AUDIT_ARCH_AARCH64	(EM_AARCH64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
 #define AUDIT_ARCH_ALPHA	(EM_ALPHA|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
+#define AUDIT_ARCH_ARCOMPACT	(EM_ARCOMPACT|__AUDIT_ARCH_LE)
+#define AUDIT_ARCH_ARCOMPACTBE	(EM_ARCOMPACT)
+#define AUDIT_ARCH_ARCV2	(EM_ARCV2|__AUDIT_ARCH_LE)
+#define AUDIT_ARCH_ARCV2BE	(EM_ARCV2)
 #define AUDIT_ARCH_ARM		(EM_ARM|__AUDIT_ARCH_LE)
 #define AUDIT_ARCH_ARMEB	(EM_ARM)
 #define AUDIT_ARCH_CRIS		(EM_CRIS|__AUDIT_ARCH_LE)
-- 
ldv

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

* Re: [PATCH 06/13 v3] arc: define syscall_get_arch()
  2018-11-09 23:54                       ` [PATCH 06/13 v3] " Dmitry V. Levin
@ 2018-11-10  0:06                         ` Vineet Gupta
  0 siblings, 0 replies; 84+ messages in thread
From: Vineet Gupta @ 2018-11-10  0:06 UTC (permalink / raw)
  To: Dmitry V. Levin, Andrew Lutomirski, Alexey Brodkin
  Cc: Elvira Khabirova, Paul Moore, Eric Paris, linux-snps-arc,
	linux-audit, linux-kernel

On 11/9/18 3:54 PM, Dmitry V. Levin wrote:
> syscall_get_arch() is required to be implemented on all architectures
> that use tracehook_report_syscall_entry() in order to extend
> the generic ptrace API with PTRACE_GET_SYSCALL_INFO request.
>
> Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>

Acked-by: Vineet Gupta <vgupta@synopsys.com>

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

* [PATCH 07/13 v2] c6x: define syscall_get_arch()
  2018-11-09  3:16     ` [PATCH 07/13] c6x: " Dmitry V. Levin
@ 2018-11-10  2:01       ` Dmitry V. Levin
  0 siblings, 0 replies; 84+ messages in thread
From: Dmitry V. Levin @ 2018-11-10  2:01 UTC (permalink / raw)
  To: Andy Lutomirski, Mark Salter, Aurelien Jacquiot, Paul Moore, Eric Paris
  Cc: Elvira Khabirova, linux-c6x-dev, linux-audit, linux-kernel

syscall_get_arch() is required to be implemented on all architectures
that use tracehook_report_syscall_entry() in order to extend
the generic ptrace API with PTRACE_GET_SYSCALL_INFO request.

Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
---
v2: apparently, this architecture can be configured as big-endian,
    so changed AUDIT_ARCH_C6X to be little-endian, and added AUDIT_ARCH_C6XBE.

 arch/c6x/include/asm/syscall.h | 7 +++++++
 include/uapi/linux/audit.h     | 2 ++
 2 files changed, 9 insertions(+)

diff --git a/arch/c6x/include/asm/syscall.h b/arch/c6x/include/asm/syscall.h
index ae2be315ee9c..39dbd1ef994c 100644
--- a/arch/c6x/include/asm/syscall.h
+++ b/arch/c6x/include/asm/syscall.h
@@ -11,6 +11,7 @@
 #ifndef __ASM_C6X_SYSCALL_H
 #define __ASM_C6X_SYSCALL_H
 
+#include <uapi/linux/audit.h>
 #include <linux/err.h>
 #include <linux/sched.h>
 
@@ -120,4 +121,10 @@ static inline void syscall_set_arguments(struct task_struct *task,
 	}
 }
 
+static inline int syscall_get_arch(void)
+{
+	return IS_ENABLED(CONFIG_CPU_BIG_ENDIAN)
+		? AUDIT_ARCH_C6XBE : AUDIT_ARCH_C6X;
+}
+
 #endif /* __ASM_C6X_SYSCALLS_H */
diff --git a/include/uapi/linux/audit.h b/include/uapi/linux/audit.h
index bedf3bf54c3a..72aeea0a740d 100644
--- a/include/uapi/linux/audit.h
+++ b/include/uapi/linux/audit.h
@@ -381,6 +381,8 @@ enum {
 #define AUDIT_ARCH_ARCV2BE	(EM_ARCV2)
 #define AUDIT_ARCH_ARM		(EM_ARM|__AUDIT_ARCH_LE)
 #define AUDIT_ARCH_ARMEB	(EM_ARM)
+#define AUDIT_ARCH_C6X		(EM_TI_C6000|__AUDIT_ARCH_LE)
+#define AUDIT_ARCH_C6XBE	(EM_TI_C6000)
 #define AUDIT_ARCH_CRIS		(EM_CRIS|__AUDIT_ARCH_LE)
 #define AUDIT_ARCH_FRV		(EM_FRV)
 #define AUDIT_ARCH_I386		(EM_386|__AUDIT_ARCH_LE)
-- 
ldv

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

* [PATCH 10/13 v2] nds32: define syscall_get_arch()
  2018-11-09  3:16     ` [PATCH 10/13] nds32: " Dmitry V. Levin
@ 2018-11-10  2:01       ` Dmitry V. Levin
  0 siblings, 0 replies; 84+ messages in thread
From: Dmitry V. Levin @ 2018-11-10  2:01 UTC (permalink / raw)
  To: Andy Lutomirski, Greentime Hu, Vincent Chen, Paul Moore, Eric Paris
  Cc: Elvira Khabirova, linux-audit, linux-kernel

syscall_get_arch() is required to be implemented on all architectures
that use tracehook_report_syscall_entry() in order to extend
the generic ptrace API with PTRACE_GET_SYSCALL_INFO request.

Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
---
v2: apparently, this architecture can be configured as big-endian,
    so changed AUDIT_ARCH_NDS32 to be little-endian, and added
    AUDIT_ARCH_NDS32BE.

 arch/nds32/include/asm/syscall.h | 8 ++++++++
 include/uapi/linux/audit.h       | 2 ++
 2 files changed, 10 insertions(+)

diff --git a/arch/nds32/include/asm/syscall.h b/arch/nds32/include/asm/syscall.h
index f7e5e86765fe..569149ca25da 100644
--- a/arch/nds32/include/asm/syscall.h
+++ b/arch/nds32/include/asm/syscall.h
@@ -5,6 +5,7 @@
 #ifndef _ASM_NDS32_SYSCALL_H
 #define _ASM_NDS32_SYSCALL_H	1
 
+#include <uapi/linux/audit.h>
 #include <linux/err.h>
 struct task_struct;
 struct pt_regs;
@@ -185,4 +186,11 @@ void syscall_set_arguments(struct task_struct *task, struct pt_regs *regs,
 
 	memcpy(&regs->uregs[0] + i, args, n * sizeof(args[0]));
 }
+
+static inline int syscall_get_arch(void)
+{
+	return IS_ENABLED(CONFIG_CPU_BIG_ENDIAN)
+		? AUDIT_ARCH_NDS32BE : AUDIT_ARCH_NDS32;
+}
+
 #endif /* _ASM_NDS32_SYSCALL_H */
diff --git a/include/uapi/linux/audit.h b/include/uapi/linux/audit.h
index 421953fc2f13..b9ce3016e85b 100644
--- a/include/uapi/linux/audit.h
+++ b/include/uapi/linux/audit.h
@@ -400,6 +400,8 @@ enum {
 #define AUDIT_ARCH_MIPSEL64	(EM_MIPS|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
 #define AUDIT_ARCH_MIPSEL64N32	(EM_MIPS|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE|\
 				 __AUDIT_ARCH_CONVENTION_MIPS64_N32)
+#define AUDIT_ARCH_NDS32	(EM_NDS32|__AUDIT_ARCH_LE)
+#define AUDIT_ARCH_NDS32BE	(EM_NDS32)
 #define AUDIT_ARCH_OPENRISC	(EM_OPENRISC)
 #define AUDIT_ARCH_PARISC	(EM_PARISC)
 #define AUDIT_ARCH_PARISC64	(EM_PARISC|__AUDIT_ARCH_64BIT)
-- 
ldv

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

* Re: [PATCH 12/13] riscv: define syscall_get_arch()
  2018-11-09 22:28         ` Dmitry V. Levin
@ 2018-11-10  5:12           ` David Abdurachmanov
  2018-11-10  9:27           ` Andreas Schwab
  1 sibling, 0 replies; 84+ messages in thread
From: David Abdurachmanov @ 2018-11-10  5:12 UTC (permalink / raw)
  To: luto, Palmer Dabbelt, aou, Paul Moore, eparis, lineprinter,
	linux-riscv, linux-audit, linux-kernel

On Fri, Nov 9, 2018 at 11:28 PM Dmitry V. Levin <ldv@altlinux.org> wrote:
>
> P.S. It would be great if you replied to me as well.
>

My apologies. I did hit "Reply All", but that somehow didn't
include all records from to, cc, to-replay fields :/

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

* Re: [PATCH 12/13] riscv: define syscall_get_arch()
  2018-11-09 22:28         ` Dmitry V. Levin
  2018-11-10  5:12           ` David Abdurachmanov
@ 2018-11-10  9:27           ` Andreas Schwab
  1 sibling, 0 replies; 84+ messages in thread
From: Andreas Schwab @ 2018-11-10  9:27 UTC (permalink / raw)
  To: David Abdurachmanov
  Cc: Andy Lutomirski, Palmer Dabbelt, aou, Paul Moore, eparis,
	Elvira Khabirova, linux-riscv, linux-audit, linux-kernel

On Nov 10 2018, "Dmitry V. Levin" <ldv@altlinux.org> wrote:

> P.S. It would be great if you replied to me as well.

You are explicitly forbidding that.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."

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

* [PATCH 14/13] Move EM_UNICORE to uapi/linux/elf-em.h
  2018-11-09  3:13   ` [PATCH 00/13] Prepare for PTRACE_GET_SYSCALL_INFO Dmitry V. Levin
                       ` (13 preceding siblings ...)
  2018-11-09  6:06     ` [PATCH 00/13] Prepare for PTRACE_GET_SYSCALL_INFO Andy Lutomirski
@ 2018-11-10 14:09     ` Dmitry V. Levin
  2018-11-10 14:10     ` [PATCH 15/13] unicore32: define syscall_get_arch() Dmitry V. Levin
  15 siblings, 0 replies; 84+ messages in thread
From: Dmitry V. Levin @ 2018-11-10 14:09 UTC (permalink / raw)
  To: Andy Lutomirski, Guan Xuetao; +Cc: Elvira Khabirova, linux-kernel

This should never have been defined in the arch tree to begin with,
and now uapi/linux/audit.h header is going to use EM_UNICORE
in order to define AUDIT_ARCH_UNICORE which is needed to implement
syscall_get_arch() which in turn is required to extend
the generic ptrace API with PTRACE_GET_SYSCALL_INFO request.

Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
---
Apparently, we need to implement syscall_get_arch() on all architectures
where linux/tracehook.h is compiled, not just those that use
tracehook_report_syscall_entry().
This adds one more architecture to the initial list of 9 architectures
where syscall_get_arch() has to be implemented.

 arch/unicore32/include/asm/elf.h | 3 +--
 include/uapi/linux/elf-em.h      | 1 +
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/unicore32/include/asm/elf.h b/arch/unicore32/include/asm/elf.h
index 829042d07722..ae66dc1be49e 100644
--- a/arch/unicore32/include/asm/elf.h
+++ b/arch/unicore32/include/asm/elf.h
@@ -19,6 +19,7 @@
  * ELF register definitions..
  */
 #include <asm/ptrace.h>
+#include <linux/elf-em.h>
 
 typedef unsigned long elf_greg_t;
 typedef unsigned long elf_freg_t[3];
@@ -28,8 +29,6 @@ typedef elf_greg_t elf_gregset_t[ELF_NGREG];
 
 typedef struct fp_state elf_fpregset_t;
 
-#define EM_UNICORE		110
-
 #define R_UNICORE_NONE		0
 #define R_UNICORE_PC24		1
 #define R_UNICORE_ABS32		2
diff --git a/include/uapi/linux/elf-em.h b/include/uapi/linux/elf-em.h
index 4b81fc1a949a..7b02cf339d8f 100644
--- a/include/uapi/linux/elf-em.h
+++ b/include/uapi/linux/elf-em.h
@@ -37,6 +37,7 @@
 #define EM_ARCOMPACT	93	/* ARCompact processor */
 #define EM_XTENSA	94	/* Tensilica Xtensa Architecture */
 #define EM_BLACKFIN     106     /* ADI Blackfin Processor */
+#define EM_UNICORE	110	/* UniCore-32 */
 #define EM_ALTERA_NIOS2	113	/* Altera Nios II soft-core processor */
 #define EM_TI_C6000	140	/* TI C6X DSPs */
 #define EM_HEXAGON	164	/* QUALCOMM Hexagon */
-- 
ldv

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

* [PATCH 15/13] unicore32: define syscall_get_arch()
  2018-11-09  3:13   ` [PATCH 00/13] Prepare for PTRACE_GET_SYSCALL_INFO Dmitry V. Levin
                       ` (14 preceding siblings ...)
  2018-11-10 14:09     ` [PATCH 14/13] Move EM_UNICORE to uapi/linux/elf-em.h Dmitry V. Levin
@ 2018-11-10 14:10     ` Dmitry V. Levin
  15 siblings, 0 replies; 84+ messages in thread
From: Dmitry V. Levin @ 2018-11-10 14:10 UTC (permalink / raw)
  To: Andy Lutomirski, Guan Xuetao
  Cc: Paul Moore, Eric Paris, Elvira Khabirova, linux-audit, linux-kernel

syscall_get_arch() is required to be implemented on all architectures
in order to extend the generic ptrace API with PTRACE_GET_SYSCALL_INFO
request.

Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
---
Apparently, we need to implement syscall_get_arch() on all architectures
where linux/tracehook.h is compiled, not just those that use
tracehook_report_syscall_entry().
This adds one more architecture to the initial list of 9 architectures
where syscall_get_arch() has to be implemented.

 arch/unicore32/include/asm/syscall.h | 12 ++++++++++++
 include/uapi/linux/audit.h           |  1 +
 2 files changed, 13 insertions(+)
 create mode 100644 arch/unicore32/include/asm/syscall.h

diff --git a/arch/unicore32/include/asm/syscall.h b/arch/unicore32/include/asm/syscall.h
new file mode 100644
index 000000000000..3a6b885476b4
--- /dev/null
+++ b/arch/unicore32/include/asm/syscall.h
@@ -0,0 +1,12 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _ASM_UNICORE_SYSCALL_H
+#define _ASM_UNICORE_SYSCALL_H
+
+#include <uapi/linux/audit.h>
+
+static inline int syscall_get_arch(void)
+{
+	return AUDIT_ARCH_UNICORE;
+}
+
+#endif	/* _ASM_UNICORE_SYSCALL_H */
diff --git a/include/uapi/linux/audit.h b/include/uapi/linux/audit.h
index c3127e6cde2c..904d713f6cdd 100644
--- a/include/uapi/linux/audit.h
+++ b/include/uapi/linux/audit.h
@@ -423,6 +423,7 @@ enum {
 #define AUDIT_ARCH_TILEGX	(EM_TILEGX|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
 #define AUDIT_ARCH_TILEGX32	(EM_TILEGX|__AUDIT_ARCH_LE)
 #define AUDIT_ARCH_TILEPRO	(EM_TILEPRO|__AUDIT_ARCH_LE)
+#define AUDIT_ARCH_UNICORE	(EM_UNICORE|__AUDIT_ARCH_LE)
 #define AUDIT_ARCH_X86_64	(EM_X86_64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
 #define AUDIT_ARCH_XTENSA	(EM_XTENSA)
 
-- 
ldv

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

* Re: [PATCH 12/13 v2] riscv: define syscall_get_arch()
  2018-11-09 22:48           ` [PATCH 12/13 v2] " Dmitry V. Levin
@ 2018-11-11 21:21             ` Palmer Dabbelt
  0 siblings, 0 replies; 84+ messages in thread
From: Palmer Dabbelt @ 2018-11-11 21:21 UTC (permalink / raw)
  To: ldv
  Cc: luto, lineprinter, david.abdurachmanov, aou, paul, eparis,
	linux-riscv, linux-audit, linux-kernel

On Fri, 09 Nov 2018 14:48:33 PST (-0800), ldv@altlinux.org wrote:
> syscall_get_arch() is required to be implemented on all architectures
> that use tracehook_report_syscall_entry() in order to extend
> the generic ptrace API with PTRACE_GET_SYSCALL_INFO request.
>
> Based-on-patch-by: David Abdurachmanov <david.abdurachmanov@gmail.com>
> Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
> ---
>  arch/riscv/include/asm/syscall.h | 10 ++++++++++
>  include/uapi/linux/audit.h       |  2 ++
>  2 files changed, 12 insertions(+)
>
> diff --git a/arch/riscv/include/asm/syscall.h b/arch/riscv/include/asm/syscall.h
> index 8d25f8904c00..bba3da6ef157 100644
> --- a/arch/riscv/include/asm/syscall.h
> +++ b/arch/riscv/include/asm/syscall.h
> @@ -18,6 +18,7 @@
>  #ifndef _ASM_RISCV_SYSCALL_H
>  #define _ASM_RISCV_SYSCALL_H
>
> +#include <uapi/linux/audit.h>
>  #include <linux/sched.h>
>  #include <linux/err.h>
>
> @@ -99,4 +100,13 @@ static inline void syscall_set_arguments(struct task_struct *task,
>  	memcpy(&regs->a1 + i * sizeof(regs->a1), args, n * sizeof(regs->a0));
>  }
>
> +static inline int syscall_get_arch(void)
> +{
> +#ifdef CONFIG_64BIT
> +	return AUDIT_ARCH_RISCV64;
> +#else
> +	return AUDIT_ARCH_RISCV32;
> +#endif
> +}
> +
>  #endif	/* _ASM_RISCV_SYSCALL_H */
> diff --git a/include/uapi/linux/audit.h b/include/uapi/linux/audit.h
> index c4c8b131af48..1b199a77a6b9 100644
> --- a/include/uapi/linux/audit.h
> +++ b/include/uapi/linux/audit.h
> @@ -405,6 +405,8 @@ enum {
>  /* do not define AUDIT_ARCH_PPCLE since it is not supported by audit */
>  #define AUDIT_ARCH_PPC64	(EM_PPC64|__AUDIT_ARCH_64BIT)
>  #define AUDIT_ARCH_PPC64LE	(EM_PPC64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
> +#define AUDIT_ARCH_RISCV32	(EM_RISCV|__AUDIT_ARCH_LE)
> +#define AUDIT_ARCH_RISCV64	(EM_RISCV|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
>  #define AUDIT_ARCH_S390		(EM_S390)
>  #define AUDIT_ARCH_S390X	(EM_S390|__AUDIT_ARCH_64BIT)
>  #define AUDIT_ARCH_SH		(EM_SH)

Reviewed-by: Palmer Dabbelt <palmer@sifive.com>

Thanks!

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

* Re: [RFC PATCH] ptrace: add PTRACE_GET_SYSCALL_INFO request
  2018-11-07 20:44 ` Andy Lutomirski
  2018-11-09  3:13   ` [PATCH 00/13] Prepare for PTRACE_GET_SYSCALL_INFO Dmitry V. Levin
@ 2018-11-13  3:38   ` Dmitry V. Levin
  2018-11-20  0:11   ` [PATCH v2 00/15] Prepare for PTRACE_GET_SYSCALL_INFO Dmitry V. Levin
  2 siblings, 0 replies; 84+ messages in thread
From: Dmitry V. Levin @ 2018-11-13  3:38 UTC (permalink / raw)
  To: Andy Lutomirski, Oleg Nesterov, Elvira Khabirova
  Cc: Steven Rostedt, Ingo Molnar, Eugene Syromiatnikov, LKML, strace-devel

On Wed, Nov 07, 2018 at 12:44:58PM -0800, Andy Lutomirski wrote:
> > On Nov 6, 2018, at 7:27 PM, Elvira Khabirova <lineprinter@altlinux.org> wrote:
> >
> > PTRACE_GET_SYSCALL_INFO lets ptracer obtain details of the syscall
> > the tracee is blocked in. The request returns meaningful data only
> > when the tracee is in a syscall-enter-stop or a syscall-exit-stop.
> >
> > There are two reasons for a special syscall-related ptrace request.
> >
> > Firstly, with the current ptrace API there are cases when ptracer cannot
> > retrieve necessary information about syscalls. Some examples include:
> > * The notorious int-0x80-from-64-bit-task issue. See [1] for details.
> > In short, if a 64-bit task performs a syscall through int 0x80, its tracer
> > has no reliable means to find out that the syscall was, in fact,
> > a compat syscall, and misidentifies it.
> > * Syscall-enter-stop and syscall-exit-stop look the same for the tracer.
> > Common practice is to keep track of the sequence of ptrace-stops in order
> > not to mix the two syscall-stops up. But it is not as simple as it looks;
> > for example, strace had a (just recently fixed) long-standing bug where
> > attaching strace to a tracee that is performing the execve system call
> > led to the tracer identifying the following syscall-exit-stop as
> > syscall-enter-stop, which messed up all the state tracking.
> > * Since the introduction of commit 84d77d3f06e7e8dea057d10e8ec77ad71f721be3
> > ("ptrace: Don't allow accessing an undumpable mm"), both PTRACE_PEEKDATA
> > and process_vm_readv become unavailable when the process dumpable flag
> > is cleared. On ia64 this results in all syscall arguments being unavailable.
> >
> > Secondly, ptracers also have to support a lot of arch-specific code for
> > obtaining information about the tracee. For some architectures, this
> > requires a ptrace(PTRACE_PEEKUSER, ...) invocation for every syscall
> > argument and return value.
> >
> > PTRACE_GET_SYSCALL_INFO returns the following structure:
> >
> > struct ptrace_syscall_info {
> >    __u8 op; /* 0 for entry, 1 for exit */
> 
> Please consider adding another op for a seccomp stop.

If there are going to be more than two values, I'd suggest introducing
a enum or at least define appropriate macros.

wrt PTRACE_EVENT_SECCOMP, I don't see how the current proposed
implementation of PTRACE_GET_SYSCALL_INFO (based on ptrace_message)
could work in case of PTRACE_EVENT_SECCOMP (which also sets
ptrace_message).  Any ideas?


-- 
ldv

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

* [PATCH v2 00/15] Prepare for PTRACE_GET_SYSCALL_INFO
  2018-11-07 20:44 ` Andy Lutomirski
  2018-11-09  3:13   ` [PATCH 00/13] Prepare for PTRACE_GET_SYSCALL_INFO Dmitry V. Levin
  2018-11-13  3:38   ` [RFC PATCH] ptrace: add PTRACE_GET_SYSCALL_INFO request Dmitry V. Levin
@ 2018-11-20  0:11   ` Dmitry V. Levin
  2018-11-20  0:14     ` [PATCH v2 01/15] Move EM_HEXAGON to uapi/linux/elf-em.h Dmitry V. Levin
                       ` (16 more replies)
  2 siblings, 17 replies; 84+ messages in thread
From: Dmitry V. Levin @ 2018-11-20  0:11 UTC (permalink / raw)
  To: Andy Lutomirski
  Cc: Elvira Khabirova, Albert Ou, Alexey Brodkin, Aurelien Jacquiot,
	Chris Zankel, Eric Paris, Geert Uytterhoeven, Greentime Hu,
	Ley Foon Tan, Mark Salter, Max Filippov, Palmer Dabbelt,
	Paul Moore, Richard Kuo, Vincent Chen, Vineet Gupta,
	Yoshinori Sato, linux-audit, linux-c6x-dev, linux-hexagon,
	linux-m68k, linux-riscv, linux-snps-arc, linux-xtensa, nios2-dev,
	uclinux-h8-devel, linux-kernel

syscall_get_arch() is required to be implemented on all architectures
in order to extend the generic ptrace API with PTRACE_GET_SYSCALL_INFO
request.

The primary intent is that the triple (audit_arch, syscall_nr, arg1..arg6)
should describe what system call is being called and what its arguments are.


Dmitry V. Levin (15):
  Move EM_HEXAGON to uapi/linux/elf-em.h
  Move EM_ARCOMPACT and EM_ARCV2 to uapi/linux/elf-em.h
  Move EM_UNICORE to uapi/linux/elf-em.h
  elf-em.h: add EM_NDS32
  elf-em.h: add EM_XTENSA
  m68k: define syscall_get_arch()
  arc: define syscall_get_arch()
  c6x: define syscall_get_arch()
  h8300: define syscall_get_arch()
  hexagon: define syscall_get_arch()
  nds32: define syscall_get_arch()
  nios2: define syscall_get_arch()
  riscv: define syscall_get_arch()
  unicore32: define syscall_get_arch()
  xtensa: define syscall_get_arch()

 arch/arc/include/asm/elf.h           |  6 +-----
 arch/arc/include/asm/syscall.h       | 10 ++++++++++
 arch/c6x/include/asm/syscall.h       |  7 +++++++
 arch/h8300/include/asm/syscall.h     |  5 +++++
 arch/hexagon/include/asm/elf.h       |  6 +-----
 arch/hexagon/include/asm/syscall.h   |  8 ++++++++
 arch/m68k/include/asm/syscall.h      | 12 ++++++++++++
 arch/nds32/include/asm/syscall.h     |  8 ++++++++
 arch/nios2/include/asm/syscall.h     |  6 ++++++
 arch/riscv/include/asm/syscall.h     | 10 ++++++++++
 arch/unicore32/include/asm/elf.h     |  3 +--
 arch/unicore32/include/asm/syscall.h | 12 ++++++++++++
 arch/xtensa/include/asm/syscall.h    |  7 +++++++
 include/uapi/linux/audit.h           | 15 +++++++++++++++
 include/uapi/linux/elf-em.h          |  7 +++++++
 15 files changed, 110 insertions(+), 12 deletions(-)
 create mode 100644 arch/m68k/include/asm/syscall.h
 create mode 100644 arch/unicore32/include/asm/syscall.h

-- 
ldv

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

* [PATCH v2 01/15] Move EM_HEXAGON to uapi/linux/elf-em.h
  2018-11-20  0:11   ` [PATCH v2 00/15] Prepare for PTRACE_GET_SYSCALL_INFO Dmitry V. Levin
@ 2018-11-20  0:14     ` Dmitry V. Levin
  2018-11-20  0:14     ` [PATCH v2 02/15] Move EM_ARCOMPACT and EM_ARCV2 " Dmitry V. Levin
                       ` (15 subsequent siblings)
  16 siblings, 0 replies; 84+ messages in thread
From: Dmitry V. Levin @ 2018-11-20  0:14 UTC (permalink / raw)
  To: Andy Lutomirski, Richard Kuo
  Cc: Elvira Khabirova, linux-hexagon, linux-kernel

This should never have been defined in the arch tree to begin with,
and now uapi/linux/audit.h header is going to use EM_HEXAGON
in order to define AUDIT_ARCH_HEXAGON which is needed to implement
syscall_get_arch() which in turn is required to extend
the generic ptrace API with PTRACE_GET_SYSCALL_INFO request.

Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
---
v2: unchanged since v1

 arch/hexagon/include/asm/elf.h | 6 +-----
 include/uapi/linux/elf-em.h    | 1 +
 2 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/arch/hexagon/include/asm/elf.h b/arch/hexagon/include/asm/elf.h
index 80311e7b8ca6..d10fbd54ae51 100644
--- a/arch/hexagon/include/asm/elf.h
+++ b/arch/hexagon/include/asm/elf.h
@@ -23,11 +23,7 @@
 
 #include <asm/ptrace.h>
 #include <asm/user.h>
-
-/*
- * This should really be in linux/elf-em.h.
- */
-#define EM_HEXAGON	164   /* QUALCOMM Hexagon */
+#include <linux/elf-em.h>
 
 struct elf32_hdr;
 
diff --git a/include/uapi/linux/elf-em.h b/include/uapi/linux/elf-em.h
index 93722e60204c..ba3696e3d694 100644
--- a/include/uapi/linux/elf-em.h
+++ b/include/uapi/linux/elf-em.h
@@ -37,6 +37,7 @@
 #define EM_BLACKFIN     106     /* ADI Blackfin Processor */
 #define EM_ALTERA_NIOS2	113	/* Altera Nios II soft-core processor */
 #define EM_TI_C6000	140	/* TI C6X DSPs */
+#define EM_HEXAGON	164	/* QUALCOMM Hexagon */
 #define EM_AARCH64	183	/* ARM 64 bit */
 #define EM_TILEPRO	188	/* Tilera TILEPro */
 #define EM_MICROBLAZE	189	/* Xilinx MicroBlaze */
-- 
ldv

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

* [PATCH v2 02/15] Move EM_ARCOMPACT and EM_ARCV2 to uapi/linux/elf-em.h
  2018-11-20  0:11   ` [PATCH v2 00/15] Prepare for PTRACE_GET_SYSCALL_INFO Dmitry V. Levin
  2018-11-20  0:14     ` [PATCH v2 01/15] Move EM_HEXAGON to uapi/linux/elf-em.h Dmitry V. Levin
@ 2018-11-20  0:14     ` Dmitry V. Levin
  2018-11-20  0:14     ` [PATCH v2 03/15] Move EM_UNICORE " Dmitry V. Levin
                       ` (14 subsequent siblings)
  16 siblings, 0 replies; 84+ messages in thread
From: Dmitry V. Levin @ 2018-11-20  0:14 UTC (permalink / raw)
  To: Andy Lutomirski, Vineet Gupta
  Cc: Elvira Khabirova, Alexey Brodkin, linux-snps-arc, linux-kernel

These should never have been defined in the arch tree to begin with, and
now uapi/linux/audit.h header is going to use EM_ARCOMPACT and EM_ARCV2
in order to define AUDIT_ARCH_ARCOMPACT and AUDIT_ARCH_ARCV2 which are
needed to implement syscall_get_arch() which in turn is required to
extend the generic ptrace API with PTRACE_GET_SYSCALL_INFO request.

Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
Acked-by: Vineet Gupta <vgupta@synopsys.com>
---
v2: added Acked-by to [PATCH 02/13 v2]

 arch/arc/include/asm/elf.h  | 6 +-----
 include/uapi/linux/elf-em.h | 2 ++
 2 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/arch/arc/include/asm/elf.h b/arch/arc/include/asm/elf.h
index aa2d6da9d187..2b80c184c9c8 100644
--- a/arch/arc/include/asm/elf.h
+++ b/arch/arc/include/asm/elf.h
@@ -10,13 +10,9 @@
 #define __ASM_ARC_ELF_H
 
 #include <linux/types.h>
+#include <linux/elf-em.h>
 #include <uapi/asm/elf.h>
 
-/* These ELF defines belong to uapi but libc elf.h already defines them */
-#define EM_ARCOMPACT		93
-
-#define EM_ARCV2		195	/* ARCv2 Cores */
-
 #define EM_ARC_INUSE		(IS_ENABLED(CONFIG_ISA_ARCOMPACT) ? \
 					EM_ARCOMPACT : EM_ARCV2)
 
diff --git a/include/uapi/linux/elf-em.h b/include/uapi/linux/elf-em.h
index ba3696e3d694..91b33833630b 100644
--- a/include/uapi/linux/elf-em.h
+++ b/include/uapi/linux/elf-em.h
@@ -34,6 +34,7 @@
 #define EM_M32R		88	/* Renesas M32R */
 #define EM_MN10300	89	/* Panasonic/MEI MN10300, AM33 */
 #define EM_OPENRISC     92     /* OpenRISC 32-bit embedded processor */
+#define EM_ARCOMPACT	93	/* ARCompact processor */
 #define EM_BLACKFIN     106     /* ADI Blackfin Processor */
 #define EM_ALTERA_NIOS2	113	/* Altera Nios II soft-core processor */
 #define EM_TI_C6000	140	/* TI C6X DSPs */
@@ -42,6 +43,7 @@
 #define EM_TILEPRO	188	/* Tilera TILEPro */
 #define EM_MICROBLAZE	189	/* Xilinx MicroBlaze */
 #define EM_TILEGX	191	/* Tilera TILE-Gx */
+#define EM_ARCV2	195	/* ARCv2 Cores */
 #define EM_RISCV	243	/* RISC-V */
 #define EM_BPF		247	/* Linux BPF - in-kernel virtual machine */
 #define EM_FRV		0x5441	/* Fujitsu FR-V */
-- 
ldv

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

* [PATCH v2 03/15] Move EM_UNICORE to uapi/linux/elf-em.h
  2018-11-20  0:11   ` [PATCH v2 00/15] Prepare for PTRACE_GET_SYSCALL_INFO Dmitry V. Levin
  2018-11-20  0:14     ` [PATCH v2 01/15] Move EM_HEXAGON to uapi/linux/elf-em.h Dmitry V. Levin
  2018-11-20  0:14     ` [PATCH v2 02/15] Move EM_ARCOMPACT and EM_ARCV2 " Dmitry V. Levin
@ 2018-11-20  0:14     ` Dmitry V. Levin
  2018-11-20  0:15     ` [PATCH v2 04/15] elf-em.h: add EM_NDS32 Dmitry V. Levin
                       ` (13 subsequent siblings)
  16 siblings, 0 replies; 84+ messages in thread
From: Dmitry V. Levin @ 2018-11-20  0:14 UTC (permalink / raw)
  To: Andy Lutomirski, Guan Xuetao; +Cc: Elvira Khabirova, linux-kernel

This should never have been defined in the arch tree to begin with,
and now uapi/linux/audit.h header is going to use EM_UNICORE
in order to define AUDIT_ARCH_UNICORE which is needed to implement
syscall_get_arch() which in turn is required to extend
the generic ptrace API with PTRACE_GET_SYSCALL_INFO request.

Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
---
v2: unchanged since v1

 arch/unicore32/include/asm/elf.h | 3 +--
 include/uapi/linux/elf-em.h      | 1 +
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/unicore32/include/asm/elf.h b/arch/unicore32/include/asm/elf.h
index 829042d07722..ae66dc1be49e 100644
--- a/arch/unicore32/include/asm/elf.h
+++ b/arch/unicore32/include/asm/elf.h
@@ -19,6 +19,7 @@
  * ELF register definitions..
  */
 #include <asm/ptrace.h>
+#include <linux/elf-em.h>
 
 typedef unsigned long elf_greg_t;
 typedef unsigned long elf_freg_t[3];
@@ -28,8 +29,6 @@ typedef elf_greg_t elf_gregset_t[ELF_NGREG];
 
 typedef struct fp_state elf_fpregset_t;
 
-#define EM_UNICORE		110
-
 #define R_UNICORE_NONE		0
 #define R_UNICORE_PC24		1
 #define R_UNICORE_ABS32		2
diff --git a/include/uapi/linux/elf-em.h b/include/uapi/linux/elf-em.h
index 91b33833630b..a4fba79abbb9 100644
--- a/include/uapi/linux/elf-em.h
+++ b/include/uapi/linux/elf-em.h
@@ -36,6 +36,7 @@
 #define EM_OPENRISC     92     /* OpenRISC 32-bit embedded processor */
 #define EM_ARCOMPACT	93	/* ARCompact processor */
 #define EM_BLACKFIN     106     /* ADI Blackfin Processor */
+#define EM_UNICORE	110	/* UniCore-32 */
 #define EM_ALTERA_NIOS2	113	/* Altera Nios II soft-core processor */
 #define EM_TI_C6000	140	/* TI C6X DSPs */
 #define EM_HEXAGON	164	/* QUALCOMM Hexagon */
-- 
ldv

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

* [PATCH v2 04/15] elf-em.h: add EM_NDS32
  2018-11-20  0:11   ` [PATCH v2 00/15] Prepare for PTRACE_GET_SYSCALL_INFO Dmitry V. Levin
                       ` (2 preceding siblings ...)
  2018-11-20  0:14     ` [PATCH v2 03/15] Move EM_UNICORE " Dmitry V. Levin
@ 2018-11-20  0:15     ` Dmitry V. Levin
  2018-11-20  0:15     ` [PATCH v2 05/15] elf-em.h: add EM_XTENSA Dmitry V. Levin
                       ` (12 subsequent siblings)
  16 siblings, 0 replies; 84+ messages in thread
From: Dmitry V. Levin @ 2018-11-20  0:15 UTC (permalink / raw)
  To: Andy Lutomirski, Greentime Hu, Vincent Chen
  Cc: Elvira Khabirova, linux-kernel

The uapi/linux/audit.h header is going to use EM_NDS32 in order
to define AUDIT_ARCH_NDS32 which is needed to implement
syscall_get_arch() which in turn is required to extend
the generic ptrace API with PTRACE_GET_SYSCALL_INFO request.

The value for EM_NDS32 has been taken from
http://www.sco.com/developers/gabi/2012-12-31/ch4.eheader.html

Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
---
v2: unchanged since v1

 include/uapi/linux/elf-em.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/uapi/linux/elf-em.h b/include/uapi/linux/elf-em.h
index a4fba79abbb9..ba2e64cdbb6f 100644
--- a/include/uapi/linux/elf-em.h
+++ b/include/uapi/linux/elf-em.h
@@ -40,6 +40,8 @@
 #define EM_ALTERA_NIOS2	113	/* Altera Nios II soft-core processor */
 #define EM_TI_C6000	140	/* TI C6X DSPs */
 #define EM_HEXAGON	164	/* QUALCOMM Hexagon */
+#define EM_NDS32	167	/* Andes Technology compact code size
+				   embedded RISC processor family */
 #define EM_AARCH64	183	/* ARM 64 bit */
 #define EM_TILEPRO	188	/* Tilera TILEPro */
 #define EM_MICROBLAZE	189	/* Xilinx MicroBlaze */
-- 
ldv

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

* [PATCH v2 05/15] elf-em.h: add EM_XTENSA
  2018-11-20  0:11   ` [PATCH v2 00/15] Prepare for PTRACE_GET_SYSCALL_INFO Dmitry V. Levin
                       ` (3 preceding siblings ...)
  2018-11-20  0:15     ` [PATCH v2 04/15] elf-em.h: add EM_NDS32 Dmitry V. Levin
@ 2018-11-20  0:15     ` Dmitry V. Levin
  2018-11-20  0:15     ` [PATCH v2 06/15] m68k: define syscall_get_arch() Dmitry V. Levin
                       ` (11 subsequent siblings)
  16 siblings, 0 replies; 84+ messages in thread
From: Dmitry V. Levin @ 2018-11-20  0:15 UTC (permalink / raw)
  To: Andy Lutomirski, Max Filippov, Chris Zankel
  Cc: Elvira Khabirova, linux-xtensa, linux-kernel

The uapi/linux/audit.h header is going to use EM_XTENSA in order
to define AUDIT_ARCH_XTENSA which is needed to implement
syscall_get_arch() which in turn is required to extend
the generic ptrace API with PTRACE_GET_SYSCALL_INFO request.

The value for EM_XTENSA has been taken from
http://www.sco.com/developers/gabi/2012-12-31/ch4.eheader.html

Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
Reviewed-by: Max Filippov <jcmvbkbc@gmail.com>
---
v2: added Reviewed-by to v1

 include/uapi/linux/elf-em.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/uapi/linux/elf-em.h b/include/uapi/linux/elf-em.h
index ba2e64cdbb6f..7b02cf339d8f 100644
--- a/include/uapi/linux/elf-em.h
+++ b/include/uapi/linux/elf-em.h
@@ -35,6 +35,7 @@
 #define EM_MN10300	89	/* Panasonic/MEI MN10300, AM33 */
 #define EM_OPENRISC     92     /* OpenRISC 32-bit embedded processor */
 #define EM_ARCOMPACT	93	/* ARCompact processor */
+#define EM_XTENSA	94	/* Tensilica Xtensa Architecture */
 #define EM_BLACKFIN     106     /* ADI Blackfin Processor */
 #define EM_UNICORE	110	/* UniCore-32 */
 #define EM_ALTERA_NIOS2	113	/* Altera Nios II soft-core processor */
-- 
ldv

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

* [PATCH v2 06/15] m68k: define syscall_get_arch()
  2018-11-20  0:11   ` [PATCH v2 00/15] Prepare for PTRACE_GET_SYSCALL_INFO Dmitry V. Levin
                       ` (4 preceding siblings ...)
  2018-11-20  0:15     ` [PATCH v2 05/15] elf-em.h: add EM_XTENSA Dmitry V. Levin
@ 2018-11-20  0:15     ` Dmitry V. Levin
  2018-12-02 10:29       ` Geert Uytterhoeven
  2018-11-20  0:15     ` [PATCH v2 07/15] arc: " Dmitry V. Levin
                       ` (10 subsequent siblings)
  16 siblings, 1 reply; 84+ messages in thread
From: Dmitry V. Levin @ 2018-11-20  0:15 UTC (permalink / raw)
  To: Andy Lutomirski, Geert Uytterhoeven
  Cc: Elvira Khabirova, linux-m68k, linux-kernel

syscall_get_arch() is required to be implemented on all architectures
in order to extend the generic ptrace API with PTRACE_GET_SYSCALL_INFO
request.

Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
---
v2: unchanged since v1

 arch/m68k/include/asm/syscall.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)
 create mode 100644 arch/m68k/include/asm/syscall.h

diff --git a/arch/m68k/include/asm/syscall.h b/arch/m68k/include/asm/syscall.h
new file mode 100644
index 000000000000..d4d7deda8d50
--- /dev/null
+++ b/arch/m68k/include/asm/syscall.h
@@ -0,0 +1,12 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _ASM_M68K_SYSCALL_H
+#define _ASM_M68K_SYSCALL_H
+
+#include <uapi/linux/audit.h>
+
+static inline int syscall_get_arch(void)
+{
+	return AUDIT_ARCH_M68K;
+}
+
+#endif	/* _ASM_M68K_SYSCALL_H */
-- 
ldv

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

* [PATCH v2 07/15] arc: define syscall_get_arch()
  2018-11-20  0:11   ` [PATCH v2 00/15] Prepare for PTRACE_GET_SYSCALL_INFO Dmitry V. Levin
                       ` (5 preceding siblings ...)
  2018-11-20  0:15     ` [PATCH v2 06/15] m68k: define syscall_get_arch() Dmitry V. Levin
@ 2018-11-20  0:15     ` Dmitry V. Levin
  2018-11-20  0:15     ` [PATCH v2 08/15] c6x: " Dmitry V. Levin
                       ` (9 subsequent siblings)
  16 siblings, 0 replies; 84+ messages in thread
From: Dmitry V. Levin @ 2018-11-20  0:15 UTC (permalink / raw)
  To: Andy Lutomirski, Vineet Gupta, Alexey Brodkin
  Cc: Elvira Khabirova, Paul Moore, Eric Paris, linux-snps-arc,
	linux-audit, linux-kernel

syscall_get_arch() is required to be implemented on all architectures
in order to extend the generic ptrace API with PTRACE_GET_SYSCALL_INFO
request.

Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
Acked-by: Vineet Gupta <vgupta@synopsys.com>
---
v2: added Acked-by to [PATCH 06/13 v3]

 arch/arc/include/asm/syscall.h | 10 ++++++++++
 include/uapi/linux/audit.h     |  4 ++++
 2 files changed, 14 insertions(+)

diff --git a/arch/arc/include/asm/syscall.h b/arch/arc/include/asm/syscall.h
index 29de09804306..10b2e7523bc8 100644
--- a/arch/arc/include/asm/syscall.h
+++ b/arch/arc/include/asm/syscall.h
@@ -9,6 +9,7 @@
 #ifndef _ASM_ARC_SYSCALL_H
 #define _ASM_ARC_SYSCALL_H  1
 
+#include <uapi/linux/audit.h>
 #include <linux/err.h>
 #include <linux/sched.h>
 #include <asm/unistd.h>
@@ -68,4 +69,13 @@ syscall_get_arguments(struct task_struct *task, struct pt_regs *regs,
 	}
 }
 
+static inline int syscall_get_arch(void)
+{
+	return IS_ENABLED(CONFIG_ISA_ARCOMPACT)
+		? (IS_ENABLED(CONFIG_CPU_BIG_ENDIAN)
+			? AUDIT_ARCH_ARCOMPACTBE : AUDIT_ARCH_ARCOMPACT)
+		: (IS_ENABLED(CONFIG_CPU_BIG_ENDIAN)
+			? AUDIT_ARCH_ARCV2BE : AUDIT_ARCH_ARCV2);
+}
+
 #endif
diff --git a/include/uapi/linux/audit.h b/include/uapi/linux/audit.h
index 818ae690ab79..bedf3bf54c3a 100644
--- a/include/uapi/linux/audit.h
+++ b/include/uapi/linux/audit.h
@@ -375,6 +375,10 @@ enum {
 
 #define AUDIT_ARCH_AARCH64	(EM_AARCH64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
 #define AUDIT_ARCH_ALPHA	(EM_ALPHA|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
+#define AUDIT_ARCH_ARCOMPACT	(EM_ARCOMPACT|__AUDIT_ARCH_LE)
+#define AUDIT_ARCH_ARCOMPACTBE	(EM_ARCOMPACT)
+#define AUDIT_ARCH_ARCV2	(EM_ARCV2|__AUDIT_ARCH_LE)
+#define AUDIT_ARCH_ARCV2BE	(EM_ARCV2)
 #define AUDIT_ARCH_ARM		(EM_ARM|__AUDIT_ARCH_LE)
 #define AUDIT_ARCH_ARMEB	(EM_ARM)
 #define AUDIT_ARCH_CRIS		(EM_CRIS|__AUDIT_ARCH_LE)
-- 
ldv

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

* [PATCH v2 08/15] c6x: define syscall_get_arch()
  2018-11-20  0:11   ` [PATCH v2 00/15] Prepare for PTRACE_GET_SYSCALL_INFO Dmitry V. Levin
                       ` (6 preceding siblings ...)
  2018-11-20  0:15     ` [PATCH v2 07/15] arc: " Dmitry V. Levin
@ 2018-11-20  0:15     ` Dmitry V. Levin
  2018-11-20  0:16     ` [PATCH v2 09/15] h8300: " Dmitry V. Levin
                       ` (8 subsequent siblings)
  16 siblings, 0 replies; 84+ messages in thread
From: Dmitry V. Levin @ 2018-11-20  0:15 UTC (permalink / raw)
  To: Andy Lutomirski, Mark Salter, Aurelien Jacquiot, Paul Moore, Eric Paris
  Cc: Elvira Khabirova, linux-c6x-dev, linux-audit, linux-kernel

syscall_get_arch() is required to be implemented on all architectures
in order to extend the generic ptrace API with PTRACE_GET_SYSCALL_INFO
request.

Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
---
v2: unchanged since [PATCH 07/13 v2]

 arch/c6x/include/asm/syscall.h | 7 +++++++
 include/uapi/linux/audit.h     | 2 ++
 2 files changed, 9 insertions(+)

diff --git a/arch/c6x/include/asm/syscall.h b/arch/c6x/include/asm/syscall.h
index ae2be315ee9c..39dbd1ef994c 100644
--- a/arch/c6x/include/asm/syscall.h
+++ b/arch/c6x/include/asm/syscall.h
@@ -11,6 +11,7 @@
 #ifndef __ASM_C6X_SYSCALL_H
 #define __ASM_C6X_SYSCALL_H
 
+#include <uapi/linux/audit.h>
 #include <linux/err.h>
 #include <linux/sched.h>
 
@@ -120,4 +121,10 @@ static inline void syscall_set_arguments(struct task_struct *task,
 	}
 }
 
+static inline int syscall_get_arch(void)
+{
+	return IS_ENABLED(CONFIG_CPU_BIG_ENDIAN)
+		? AUDIT_ARCH_C6XBE : AUDIT_ARCH_C6X;
+}
+
 #endif /* __ASM_C6X_SYSCALLS_H */
diff --git a/include/uapi/linux/audit.h b/include/uapi/linux/audit.h
index bedf3bf54c3a..72aeea0a740d 100644
--- a/include/uapi/linux/audit.h
+++ b/include/uapi/linux/audit.h
@@ -381,6 +381,8 @@ enum {
 #define AUDIT_ARCH_ARCV2BE	(EM_ARCV2)
 #define AUDIT_ARCH_ARM		(EM_ARM|__AUDIT_ARCH_LE)
 #define AUDIT_ARCH_ARMEB	(EM_ARM)
+#define AUDIT_ARCH_C6X		(EM_TI_C6000|__AUDIT_ARCH_LE)
+#define AUDIT_ARCH_C6XBE	(EM_TI_C6000)
 #define AUDIT_ARCH_CRIS		(EM_CRIS|__AUDIT_ARCH_LE)
 #define AUDIT_ARCH_FRV		(EM_FRV)
 #define AUDIT_ARCH_I386		(EM_386|__AUDIT_ARCH_LE)
-- 
ldv

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

* [PATCH v2 09/15] h8300: define syscall_get_arch()
  2018-11-20  0:11   ` [PATCH v2 00/15] Prepare for PTRACE_GET_SYSCALL_INFO Dmitry V. Levin
                       ` (7 preceding siblings ...)
  2018-11-20  0:15     ` [PATCH v2 08/15] c6x: " Dmitry V. Levin
@ 2018-11-20  0:16     ` Dmitry V. Levin
  2018-11-20  0:16     ` [PATCH v2 10/15] hexagon: " Dmitry V. Levin
                       ` (7 subsequent siblings)
  16 siblings, 0 replies; 84+ messages in thread
From: Dmitry V. Levin @ 2018-11-20  0:16 UTC (permalink / raw)
  To: Andy Lutomirski, Yoshinori Sato, Paul Moore, Eric Paris
  Cc: Elvira Khabirova, uclinux-h8-devel, linux-audit, linux-kernel

syscall_get_arch() is required to be implemented on all architectures
in order to extend the generic ptrace API with PTRACE_GET_SYSCALL_INFO
request.

Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
---
v2: unchanged since v1

 arch/h8300/include/asm/syscall.h | 5 +++++
 include/uapi/linux/audit.h       | 1 +
 2 files changed, 6 insertions(+)

diff --git a/arch/h8300/include/asm/syscall.h b/arch/h8300/include/asm/syscall.h
index 924990401237..699664a0b1be 100644
--- a/arch/h8300/include/asm/syscall.h
+++ b/arch/h8300/include/asm/syscall.h
@@ -8,6 +8,7 @@
 #include <linux/linkage.h>
 #include <linux/types.h>
 #include <linux/ptrace.h>
+#include <uapi/linux/audit.h>
 
 static inline int
 syscall_get_nr(struct task_struct *task, struct pt_regs *regs)
@@ -47,6 +48,10 @@ syscall_get_arguments(struct task_struct *task, struct pt_regs *regs,
 	}
 }
 
+static inline int syscall_get_arch(void)
+{
+	return AUDIT_ARCH_H8300;
+}
 
 
 /* Misc syscall related bits */
diff --git a/include/uapi/linux/audit.h b/include/uapi/linux/audit.h
index 72aeea0a740d..d7fa1ba8dc82 100644
--- a/include/uapi/linux/audit.h
+++ b/include/uapi/linux/audit.h
@@ -385,6 +385,7 @@ enum {
 #define AUDIT_ARCH_C6XBE	(EM_TI_C6000)
 #define AUDIT_ARCH_CRIS		(EM_CRIS|__AUDIT_ARCH_LE)
 #define AUDIT_ARCH_FRV		(EM_FRV)
+#define AUDIT_ARCH_H8300	(EM_H8_300)
 #define AUDIT_ARCH_I386		(EM_386|__AUDIT_ARCH_LE)
 #define AUDIT_ARCH_IA64		(EM_IA_64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
 #define AUDIT_ARCH_M32R		(EM_M32R)
-- 
ldv

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

* [PATCH v2 10/15] hexagon: define syscall_get_arch()
  2018-11-20  0:11   ` [PATCH v2 00/15] Prepare for PTRACE_GET_SYSCALL_INFO Dmitry V. Levin
                       ` (8 preceding siblings ...)
  2018-11-20  0:16     ` [PATCH v2 09/15] h8300: " Dmitry V. Levin
@ 2018-11-20  0:16     ` Dmitry V. Levin
  2018-11-20  0:16     ` [PATCH v2 11/15] nds32: " Dmitry V. Levin
                       ` (6 subsequent siblings)
  16 siblings, 0 replies; 84+ messages in thread
From: Dmitry V. Levin @ 2018-11-20  0:16 UTC (permalink / raw)
  To: Andy Lutomirski, Richard Kuo, Paul Moore, Eric Paris
  Cc: Elvira Khabirova, linux-hexagon, linux-audit, linux-kernel

syscall_get_arch() is required to be implemented on all architectures
in order to extend the generic ptrace API with PTRACE_GET_SYSCALL_INFO
request.

Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
---
v2: unchanged since v1

 arch/hexagon/include/asm/syscall.h | 8 ++++++++
 include/uapi/linux/audit.h         | 1 +
 2 files changed, 9 insertions(+)

diff --git a/arch/hexagon/include/asm/syscall.h b/arch/hexagon/include/asm/syscall.h
index 4af9c7b6f13a..de3917aad3fd 100644
--- a/arch/hexagon/include/asm/syscall.h
+++ b/arch/hexagon/include/asm/syscall.h
@@ -21,6 +21,8 @@
 #ifndef _ASM_HEXAGON_SYSCALL_H
 #define _ASM_HEXAGON_SYSCALL_H
 
+#include <uapi/linux/audit.h>
+
 typedef long (*syscall_fn)(unsigned long, unsigned long,
 	unsigned long, unsigned long,
 	unsigned long, unsigned long);
@@ -43,4 +45,10 @@ static inline void syscall_get_arguments(struct task_struct *task,
 	BUG_ON(i + n > 6);
 	memcpy(args, &(&regs->r00)[i], n * sizeof(args[0]));
 }
+
+static inline int syscall_get_arch(void)
+{
+	return AUDIT_ARCH_HEXAGON;
+}
+
 #endif
diff --git a/include/uapi/linux/audit.h b/include/uapi/linux/audit.h
index d7fa1ba8dc82..421953fc2f13 100644
--- a/include/uapi/linux/audit.h
+++ b/include/uapi/linux/audit.h
@@ -386,6 +386,7 @@ enum {
 #define AUDIT_ARCH_CRIS		(EM_CRIS|__AUDIT_ARCH_LE)
 #define AUDIT_ARCH_FRV		(EM_FRV)
 #define AUDIT_ARCH_H8300	(EM_H8_300)
+#define AUDIT_ARCH_HEXAGON	(EM_HEXAGON)
 #define AUDIT_ARCH_I386		(EM_386|__AUDIT_ARCH_LE)
 #define AUDIT_ARCH_IA64		(EM_IA_64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
 #define AUDIT_ARCH_M32R		(EM_M32R)
-- 
ldv

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

* [PATCH v2 11/15] nds32: define syscall_get_arch()
  2018-11-20  0:11   ` [PATCH v2 00/15] Prepare for PTRACE_GET_SYSCALL_INFO Dmitry V. Levin
                       ` (9 preceding siblings ...)
  2018-11-20  0:16     ` [PATCH v2 10/15] hexagon: " Dmitry V. Levin
@ 2018-11-20  0:16     ` Dmitry V. Levin
  2018-11-20  0:16     ` [PATCH v2 12/15] nios2: " Dmitry V. Levin
                       ` (5 subsequent siblings)
  16 siblings, 0 replies; 84+ messages in thread
From: Dmitry V. Levin @ 2018-11-20  0:16 UTC (permalink / raw)
  To: Andy Lutomirski, Greentime Hu, Vincent Chen, Paul Moore, Eric Paris
  Cc: Elvira Khabirova, linux-audit, linux-kernel

syscall_get_arch() is required to be implemented on all architectures
in order to extend the generic ptrace API with PTRACE_GET_SYSCALL_INFO
request.

Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
---
v2: unchanged since [PATCH 10/13 v2]

 arch/nds32/include/asm/syscall.h | 8 ++++++++
 include/uapi/linux/audit.h       | 2 ++
 2 files changed, 10 insertions(+)

diff --git a/arch/nds32/include/asm/syscall.h b/arch/nds32/include/asm/syscall.h
index f7e5e86765fe..569149ca25da 100644
--- a/arch/nds32/include/asm/syscall.h
+++ b/arch/nds32/include/asm/syscall.h
@@ -5,6 +5,7 @@
 #ifndef _ASM_NDS32_SYSCALL_H
 #define _ASM_NDS32_SYSCALL_H	1
 
+#include <uapi/linux/audit.h>
 #include <linux/err.h>
 struct task_struct;
 struct pt_regs;
@@ -185,4 +186,11 @@ void syscall_set_arguments(struct task_struct *task, struct pt_regs *regs,
 
 	memcpy(&regs->uregs[0] + i, args, n * sizeof(args[0]));
 }
+
+static inline int syscall_get_arch(void)
+{
+	return IS_ENABLED(CONFIG_CPU_BIG_ENDIAN)
+		? AUDIT_ARCH_NDS32BE : AUDIT_ARCH_NDS32;
+}
+
 #endif /* _ASM_NDS32_SYSCALL_H */
diff --git a/include/uapi/linux/audit.h b/include/uapi/linux/audit.h
index 421953fc2f13..b9ce3016e85b 100644
--- a/include/uapi/linux/audit.h
+++ b/include/uapi/linux/audit.h
@@ -400,6 +400,8 @@ enum {
 #define AUDIT_ARCH_MIPSEL64	(EM_MIPS|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
 #define AUDIT_ARCH_MIPSEL64N32	(EM_MIPS|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE|\
 				 __AUDIT_ARCH_CONVENTION_MIPS64_N32)
+#define AUDIT_ARCH_NDS32	(EM_NDS32|__AUDIT_ARCH_LE)
+#define AUDIT_ARCH_NDS32BE	(EM_NDS32)
 #define AUDIT_ARCH_OPENRISC	(EM_OPENRISC)
 #define AUDIT_ARCH_PARISC	(EM_PARISC)
 #define AUDIT_ARCH_PARISC64	(EM_PARISC|__AUDIT_ARCH_64BIT)
-- 
ldv

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

* [PATCH v2 12/15] nios2: define syscall_get_arch()
  2018-11-20  0:11   ` [PATCH v2 00/15] Prepare for PTRACE_GET_SYSCALL_INFO Dmitry V. Levin
                       ` (10 preceding siblings ...)
  2018-11-20  0:16     ` [PATCH v2 11/15] nds32: " Dmitry V. Levin
@ 2018-11-20  0:16     ` Dmitry V. Levin
  2018-11-20  0:16     ` [PATCH v2 13/15] riscv: " Dmitry V. Levin
                       ` (4 subsequent siblings)
  16 siblings, 0 replies; 84+ messages in thread
From: Dmitry V. Levin @ 2018-11-20  0:16 UTC (permalink / raw)
  To: Andy Lutomirski, Ley Foon Tan, Paul Moore, Eric Paris
  Cc: Elvira Khabirova, nios2-dev, linux-audit, linux-kernel

syscall_get_arch() is required to be implemented on all architectures
in order to extend the generic ptrace API with PTRACE_GET_SYSCALL_INFO
request.

Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
---
v2: unchanged since v1

 arch/nios2/include/asm/syscall.h | 6 ++++++
 include/uapi/linux/audit.h       | 1 +
 2 files changed, 7 insertions(+)

diff --git a/arch/nios2/include/asm/syscall.h b/arch/nios2/include/asm/syscall.h
index 9de220854c4a..cf35e210fc4d 100644
--- a/arch/nios2/include/asm/syscall.h
+++ b/arch/nios2/include/asm/syscall.h
@@ -17,6 +17,7 @@
 #ifndef __ASM_NIOS2_SYSCALL_H__
 #define __ASM_NIOS2_SYSCALL_H__
 
+#include <uapi/linux/audit.h>
 #include <linux/err.h>
 #include <linux/sched.h>
 
@@ -135,4 +136,9 @@ static inline void syscall_set_arguments(struct task_struct *task,
 	}
 }
 
+static inline int syscall_get_arch(void)
+{
+	return AUDIT_ARCH_NIOS2;
+}
+
 #endif
diff --git a/include/uapi/linux/audit.h b/include/uapi/linux/audit.h
index b9ce3016e85b..205aa32d81ed 100644
--- a/include/uapi/linux/audit.h
+++ b/include/uapi/linux/audit.h
@@ -402,6 +402,7 @@ enum {
 				 __AUDIT_ARCH_CONVENTION_MIPS64_N32)
 #define AUDIT_ARCH_NDS32	(EM_NDS32|__AUDIT_ARCH_LE)
 #define AUDIT_ARCH_NDS32BE	(EM_NDS32)
+#define AUDIT_ARCH_NIOS2	(EM_ALTERA_NIOS2|__AUDIT_ARCH_LE)
 #define AUDIT_ARCH_OPENRISC	(EM_OPENRISC)
 #define AUDIT_ARCH_PARISC	(EM_PARISC)
 #define AUDIT_ARCH_PARISC64	(EM_PARISC|__AUDIT_ARCH_64BIT)
-- 
ldv

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

* [PATCH v2 13/15] riscv: define syscall_get_arch()
  2018-11-20  0:11   ` [PATCH v2 00/15] Prepare for PTRACE_GET_SYSCALL_INFO Dmitry V. Levin
                       ` (11 preceding siblings ...)
  2018-11-20  0:16     ` [PATCH v2 12/15] nios2: " Dmitry V. Levin
@ 2018-11-20  0:16     ` Dmitry V. Levin
  2018-11-20  0:16     ` [PATCH v2 14/15] unicore32: " Dmitry V. Levin
                       ` (3 subsequent siblings)
  16 siblings, 0 replies; 84+ messages in thread
From: Dmitry V. Levin @ 2018-11-20  0:16 UTC (permalink / raw)
  To: Andy Lutomirski, Palmer Dabbelt
  Cc: Elvira Khabirova, David Abdurachmanov, Albert Ou, Paul Moore,
	Eric Paris, linux-riscv, linux-audit, linux-kernel

syscall_get_arch() is required to be implemented on all architectures
in order to extend the generic ptrace API with PTRACE_GET_SYSCALL_INFO
request.

Based-on-patch-by: David Abdurachmanov <david.abdurachmanov@gmail.com>
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
Reviewed-by: Palmer Dabbelt <palmer@sifive.com>
---
v2: added Reviewed-by to [PATCH 12/13 v2]

 arch/riscv/include/asm/syscall.h | 10 ++++++++++
 include/uapi/linux/audit.h       |  2 ++
 2 files changed, 12 insertions(+)

diff --git a/arch/riscv/include/asm/syscall.h b/arch/riscv/include/asm/syscall.h
index 8d25f8904c00..bba3da6ef157 100644
--- a/arch/riscv/include/asm/syscall.h
+++ b/arch/riscv/include/asm/syscall.h
@@ -18,6 +18,7 @@
 #ifndef _ASM_RISCV_SYSCALL_H
 #define _ASM_RISCV_SYSCALL_H
 
+#include <uapi/linux/audit.h>
 #include <linux/sched.h>
 #include <linux/err.h>
 
@@ -99,4 +100,13 @@ static inline void syscall_set_arguments(struct task_struct *task,
 	memcpy(&regs->a1 + i * sizeof(regs->a1), args, n * sizeof(regs->a0));
 }
 
+static inline int syscall_get_arch(void)
+{
+#ifdef CONFIG_64BIT
+	return AUDIT_ARCH_RISCV64;
+#else
+	return AUDIT_ARCH_RISCV32;
+#endif
+}
+
 #endif	/* _ASM_RISCV_SYSCALL_H */
diff --git a/include/uapi/linux/audit.h b/include/uapi/linux/audit.h
index 205aa32d81ed..a97a29922de0 100644
--- a/include/uapi/linux/audit.h
+++ b/include/uapi/linux/audit.h
@@ -410,6 +410,8 @@ enum {
 /* do not define AUDIT_ARCH_PPCLE since it is not supported by audit */
 #define AUDIT_ARCH_PPC64	(EM_PPC64|__AUDIT_ARCH_64BIT)
 #define AUDIT_ARCH_PPC64LE	(EM_PPC64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
+#define AUDIT_ARCH_RISCV32	(EM_RISCV|__AUDIT_ARCH_LE)
+#define AUDIT_ARCH_RISCV64	(EM_RISCV|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
 #define AUDIT_ARCH_S390		(EM_S390)
 #define AUDIT_ARCH_S390X	(EM_S390|__AUDIT_ARCH_64BIT)
 #define AUDIT_ARCH_SH		(EM_SH)
-- 
ldv

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

* [PATCH v2 14/15] unicore32: define syscall_get_arch()
  2018-11-20  0:11   ` [PATCH v2 00/15] Prepare for PTRACE_GET_SYSCALL_INFO Dmitry V. Levin
                       ` (12 preceding siblings ...)
  2018-11-20  0:16     ` [PATCH v2 13/15] riscv: " Dmitry V. Levin
@ 2018-11-20  0:16     ` Dmitry V. Levin
  2018-11-20  0:17     ` [PATCH v2 15/15] xtensa: " Dmitry V. Levin
                       ` (2 subsequent siblings)
  16 siblings, 0 replies; 84+ messages in thread
From: Dmitry V. Levin @ 2018-11-20  0:16 UTC (permalink / raw)
  To: Andy Lutomirski, Guan Xuetao
  Cc: Paul Moore, Eric Paris, Elvira Khabirova, linux-audit, linux-kernel

syscall_get_arch() is required to be implemented on all architectures
in order to extend the generic ptrace API with PTRACE_GET_SYSCALL_INFO
request.

Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
---
v2: unchanged since v1

 arch/unicore32/include/asm/syscall.h | 12 ++++++++++++
 include/uapi/linux/audit.h           |  1 +
 2 files changed, 13 insertions(+)
 create mode 100644 arch/unicore32/include/asm/syscall.h

diff --git a/arch/unicore32/include/asm/syscall.h b/arch/unicore32/include/asm/syscall.h
new file mode 100644
index 000000000000..3a6b885476b4
--- /dev/null
+++ b/arch/unicore32/include/asm/syscall.h
@@ -0,0 +1,12 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _ASM_UNICORE_SYSCALL_H
+#define _ASM_UNICORE_SYSCALL_H
+
+#include <uapi/linux/audit.h>
+
+static inline int syscall_get_arch(void)
+{
+	return AUDIT_ARCH_UNICORE;
+}
+
+#endif	/* _ASM_UNICORE_SYSCALL_H */
diff --git a/include/uapi/linux/audit.h b/include/uapi/linux/audit.h
index a97a29922de0..b032748cb8ba 100644
--- a/include/uapi/linux/audit.h
+++ b/include/uapi/linux/audit.h
@@ -423,6 +423,7 @@ enum {
 #define AUDIT_ARCH_TILEGX	(EM_TILEGX|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
 #define AUDIT_ARCH_TILEGX32	(EM_TILEGX|__AUDIT_ARCH_LE)
 #define AUDIT_ARCH_TILEPRO	(EM_TILEPRO|__AUDIT_ARCH_LE)
+#define AUDIT_ARCH_UNICORE	(EM_UNICORE|__AUDIT_ARCH_LE)
 #define AUDIT_ARCH_X86_64	(EM_X86_64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
 
 #define AUDIT_PERM_EXEC		1
-- 
ldv

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

* [PATCH v2 15/15] xtensa: define syscall_get_arch()
  2018-11-20  0:11   ` [PATCH v2 00/15] Prepare for PTRACE_GET_SYSCALL_INFO Dmitry V. Levin
                       ` (13 preceding siblings ...)
  2018-11-20  0:16     ` [PATCH v2 14/15] unicore32: " Dmitry V. Levin
@ 2018-11-20  0:17     ` Dmitry V. Levin
  2018-11-20 20:26     ` [PATCH v2 00/15] Prepare for PTRACE_GET_SYSCALL_INFO Paul Moore
       [not found]     ` <20181121004422.GA29053@altlinux.org>
  16 siblings, 0 replies; 84+ messages in thread
From: Dmitry V. Levin @ 2018-11-20  0:17 UTC (permalink / raw)
  To: Andy Lutomirski, Max Filippov, Chris Zankel, Paul Moore, Eric Paris
  Cc: Elvira Khabirova, linux-xtensa, linux-audit, linux-kernel

syscall_get_arch() is required to be implemented on all architectures
in order to extend the generic ptrace API with PTRACE_GET_SYSCALL_INFO
request.

Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
Acked-by: Max Filippov <jcmvbkbc@gmail.com>
---
v2: added Acked-by to v1

 arch/xtensa/include/asm/syscall.h | 7 +++++++
 include/uapi/linux/audit.h        | 1 +
 2 files changed, 8 insertions(+)

diff --git a/arch/xtensa/include/asm/syscall.h b/arch/xtensa/include/asm/syscall.h
index 3673ff1f1bc5..84144567095a 100644
--- a/arch/xtensa/include/asm/syscall.h
+++ b/arch/xtensa/include/asm/syscall.h
@@ -8,6 +8,13 @@
  * Copyright (C) 2001 - 2007 Tensilica Inc.
  */
 
+#include <uapi/linux/audit.h>
+
+static inline int syscall_get_arch(void)
+{
+	return AUDIT_ARCH_XTENSA;
+}
+
 struct pt_regs;
 asmlinkage long xtensa_ptrace(long, long, long, long);
 asmlinkage long xtensa_sigreturn(struct pt_regs*);
diff --git a/include/uapi/linux/audit.h b/include/uapi/linux/audit.h
index b032748cb8ba..904d713f6cdd 100644
--- a/include/uapi/linux/audit.h
+++ b/include/uapi/linux/audit.h
@@ -425,6 +425,7 @@ enum {
 #define AUDIT_ARCH_TILEPRO	(EM_TILEPRO|__AUDIT_ARCH_LE)
 #define AUDIT_ARCH_UNICORE	(EM_UNICORE|__AUDIT_ARCH_LE)
 #define AUDIT_ARCH_X86_64	(EM_X86_64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
+#define AUDIT_ARCH_XTENSA	(EM_XTENSA)
 
 #define AUDIT_PERM_EXEC		1
 #define AUDIT_PERM_WRITE	2
-- 
ldv

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

* Re: [PATCH v2 00/15] Prepare for PTRACE_GET_SYSCALL_INFO
  2018-11-20  0:11   ` [PATCH v2 00/15] Prepare for PTRACE_GET_SYSCALL_INFO Dmitry V. Levin
                       ` (14 preceding siblings ...)
  2018-11-20  0:17     ` [PATCH v2 15/15] xtensa: " Dmitry V. Levin
@ 2018-11-20 20:26     ` Paul Moore
       [not found]     ` <20181121004422.GA29053@altlinux.org>
  16 siblings, 0 replies; 84+ messages in thread
From: Paul Moore @ 2018-11-20 20:26 UTC (permalink / raw)
  To: ldv
  Cc: luto, lineprinter, aou, alexey.brodkin, jacquiot.aurelien, chris,
	Eric Paris, geert, green.hu, lftan, msalter, jcmvbkbc, palmer,
	rkuo, deanbo422, vgupta, ysato, linux-audit, linux-c6x-dev,
	linux-hexagon, linux-m68k, linux-riscv, linux-snps-arc,
	linux-xtensa, nios2-dev, uclinux-h8-devel, linux-kernel

On Mon, Nov 19, 2018 at 7:11 PM Dmitry V. Levin <ldv@altlinux.org> wrote:
>
> syscall_get_arch() is required to be implemented on all architectures
> in order to extend the generic ptrace API with PTRACE_GET_SYSCALL_INFO
> request.
>
> The primary intent is that the triple (audit_arch, syscall_nr, arg1..arg6)
> should describe what system call is being called and what its arguments are.

No real comment from me, most of this is arch specific code so I'll
let the individual arch folks comment on that; they know far better
than I do what is correct.

That said, anything that gets us closer to being able to offer syscall
auditing for these arches gets a big thumbs up from me - thanks!

> Dmitry V. Levin (15):
>   Move EM_HEXAGON to uapi/linux/elf-em.h
>   Move EM_ARCOMPACT and EM_ARCV2 to uapi/linux/elf-em.h
>   Move EM_UNICORE to uapi/linux/elf-em.h
>   elf-em.h: add EM_NDS32
>   elf-em.h: add EM_XTENSA
>   m68k: define syscall_get_arch()
>   arc: define syscall_get_arch()
>   c6x: define syscall_get_arch()
>   h8300: define syscall_get_arch()
>   hexagon: define syscall_get_arch()
>   nds32: define syscall_get_arch()
>   nios2: define syscall_get_arch()
>   riscv: define syscall_get_arch()
>   unicore32: define syscall_get_arch()
>   xtensa: define syscall_get_arch()
>
>  arch/arc/include/asm/elf.h           |  6 +-----
>  arch/arc/include/asm/syscall.h       | 10 ++++++++++
>  arch/c6x/include/asm/syscall.h       |  7 +++++++
>  arch/h8300/include/asm/syscall.h     |  5 +++++
>  arch/hexagon/include/asm/elf.h       |  6 +-----
>  arch/hexagon/include/asm/syscall.h   |  8 ++++++++
>  arch/m68k/include/asm/syscall.h      | 12 ++++++++++++
>  arch/nds32/include/asm/syscall.h     |  8 ++++++++
>  arch/nios2/include/asm/syscall.h     |  6 ++++++
>  arch/riscv/include/asm/syscall.h     | 10 ++++++++++
>  arch/unicore32/include/asm/elf.h     |  3 +--
>  arch/unicore32/include/asm/syscall.h | 12 ++++++++++++
>  arch/xtensa/include/asm/syscall.h    |  7 +++++++
>  include/uapi/linux/audit.h           | 15 +++++++++++++++
>  include/uapi/linux/elf-em.h          |  7 +++++++
>  15 files changed, 110 insertions(+), 12 deletions(-)
>  create mode 100644 arch/m68k/include/asm/syscall.h
>  create mode 100644 arch/unicore32/include/asm/syscall.h

-- 
paul moore
www.paul-moore.com

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

* Re: [PATCH v2 16/15] syscall_get_arch: add "struct task_struct *" argument
       [not found]       ` <20181121184004.jro532jopnbmru2m@pburton-laptop>
@ 2018-11-21 19:00         ` Dmitry V. Levin
  2018-11-21 19:14           ` [PATCH] mips: fix mips_get_syscall_arg o32 check Dmitry V. Levin
  2018-11-21 19:35           ` [PATCH v2 16/15 v2] syscall_get_arch: add "struct task_struct *" argument Dmitry V. Levin
  0 siblings, 2 replies; 84+ messages in thread
From: Dmitry V. Levin @ 2018-11-21 19:00 UTC (permalink / raw)
  To: Paul Burton
  Cc: Andy Lutomirski, Eric Paris, Paul Moore, Elvira Khabirova,
	Eugene Syromyatnikov, Oleg Nesterov, linux-audit, linux-alpha,
	linux-arch, linux-arm-kernel, linux-c6x-dev, linux-hexagon,
	linux-ia64, linux-m68k, linux-mips, linux-parisc, linux-riscv,
	linux-s390, linux-sh, linux-snps-arc, linux-um, linux-xtensa,
	linuxppc-dev, nios2-dev, openrisc, sparclinux, uclinux-h8-devel,
	x86, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 3014 bytes --]

Hi Paul,

On Wed, Nov 21, 2018 at 06:40:06PM +0000, Paul Burton wrote:
> Hi Dmitry,
> 
> On Wed, Nov 21, 2018 at 03:44:22AM +0300, Dmitry V. Levin wrote:
> > This argument is required to extend the generic ptrace API
> > with PTRACE_GET_SYSCALL_INFO request: syscall_get_arch() is going to be
> > called from ptrace_request() along with other syscall_get_* functions
> > with a tracee as their argument.
> > 
> > This change partially reverts commit 5e937a9ae913 ("syscall_get_arch:
> > remove useless function arguments").
> > 
> >%
> > 
> > diff --git a/arch/mips/include/asm/syscall.h b/arch/mips/include/asm/syscall.h
> > index 0170602a1e4e..52b633f20abd 100644
> > --- a/arch/mips/include/asm/syscall.h
> > +++ b/arch/mips/include/asm/syscall.h
> > @@ -73,7 +73,7 @@ static inline unsigned long mips_get_syscall_arg(unsigned long *arg,
> >  #ifdef CONFIG_64BIT
> >  	case 4: case 5: case 6: case 7:
> >  #ifdef CONFIG_MIPS32_O32
> > -		if (test_thread_flag(TIF_32BIT_REGS))
> > +		if (test_ti_thread_flag(task_thread_info(task), TIF_32BIT_REGS))
> >  			return get_user(*arg, (int *)usp + n);
> >  		else
> >  #endif
> 
> This ought to be test_tsk_thread_flag(task, TIF_32BIT_REGS) instead of
> open-coding test_tsk_thread_flag.

This will be corrected, thanks for letting me know.

> More fundamentally though, this change doesn't seem to be (directly)
> related to the change you describe in the commit message - it's not
> syscall_get_arch being modified here. I suspect this should be a
> separate commit, or if not please explain in the commit message why this
> change is included.

Good point, this is a fix that should not have been included into this commit.
The bug was found while preparing the syscall_get_arch change, and this
hunk just slipped in.  I'll send it as a separate commit.

> Compounding the lack of clarity is the fact that I only received this
> patch, not the whole series, so I can't view the change in the context
> of the rest of the series.
> 
> > @@ -140,14 +140,14 @@ extern const unsigned long sys_call_table[];
> >  extern const unsigned long sys32_call_table[];
> >  extern const unsigned long sysn32_call_table[];
> >  
> > -static inline int syscall_get_arch(void)
> > +static inline int syscall_get_arch(struct task_struct *task)
> >  {
> >  	int arch = AUDIT_ARCH_MIPS;
> >  #ifdef CONFIG_64BIT
> > -	if (!test_thread_flag(TIF_32BIT_REGS)) {
> > +	if (!test_ti_thread_flag(task_thread_info(task), TIF_32BIT_REGS)) {
> >  		arch |= __AUDIT_ARCH_64BIT;
> >  		/* N32 sets only TIF_32BIT_ADDR */
> > -		if (test_thread_flag(TIF_32BIT_ADDR))
> > +		if (test_ti_thread_flag(task_thread_info(task), TIF_32BIT_ADDR))
> >  			arch |= __AUDIT_ARCH_CONVENTION_MIPS64_N32;
> >  	}
> >  #endif
> 
> This does seem like the described change, but there are 2 more instances
> of open-coding test_tsk_thread_flag which ought to be cleaned up.

This will be cleaned up, thanks for letting me know.


-- 
ldv

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

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

* [PATCH] mips: fix mips_get_syscall_arg o32 check
  2018-11-21 19:00         ` [PATCH v2 16/15] syscall_get_arch: add "struct task_struct *" argument Dmitry V. Levin
@ 2018-11-21 19:14           ` Dmitry V. Levin
  2018-11-21 19:23             ` Paul Burton
  2018-11-21 19:35           ` [PATCH v2 16/15 v2] syscall_get_arch: add "struct task_struct *" argument Dmitry V. Levin
  1 sibling, 1 reply; 84+ messages in thread
From: Dmitry V. Levin @ 2018-11-21 19:14 UTC (permalink / raw)
  To: Paul Burton
  Cc: Elvira Khabirova, Ralf Baechle, James Hogan, linux-mips, linux-kernel

When checking for TIF_32BIT_REGS flag, mips_get_syscall_arg() should
use the task specified as its argument instead of the current task.

This potentially affects all syscall_get_arguments() users
who specify tasks different from the current.

Fixes: c0ff3c53d4f99 ("MIPS: Enable HAVE_ARCH_TRACEHOOK.")
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
---
 arch/mips/include/asm/syscall.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/mips/include/asm/syscall.h b/arch/mips/include/asm/syscall.h
index 0170602a1e4e..6cf8ffb5367e 100644
--- a/arch/mips/include/asm/syscall.h
+++ b/arch/mips/include/asm/syscall.h
@@ -73,7 +73,7 @@ static inline unsigned long mips_get_syscall_arg(unsigned long *arg,
 #ifdef CONFIG_64BIT
 	case 4: case 5: case 6: case 7:
 #ifdef CONFIG_MIPS32_O32
-		if (test_thread_flag(TIF_32BIT_REGS))
+		if (test_tsk_thread_flag(task, TIF_32BIT_REGS))
 			return get_user(*arg, (int *)usp + n);
 		else
 #endif
-- 
ldv

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

* Re: [PATCH] mips: fix mips_get_syscall_arg o32 check
  2018-11-21 19:14           ` [PATCH] mips: fix mips_get_syscall_arg o32 check Dmitry V. Levin
@ 2018-11-21 19:23             ` Paul Burton
  0 siblings, 0 replies; 84+ messages in thread
From: Paul Burton @ 2018-11-21 19:23 UTC (permalink / raw)
  To: Dmitry V. Levin
  Cc: Paul Burton, Elvira Khabirova, Ralf Baechle, James Hogan,
	linux-mips, linux-kernel, linux-mips

Hello,

Dmitry V. Levin wrote:
> When checking for TIF_32BIT_REGS flag, mips_get_syscall_arg() should
> use the task specified as its argument instead of the current task.
> 
> This potentially affects all syscall_get_arguments() users
> who specify tasks different from the current.
> 
> Fixes: c0ff3c53d4f99 ("MIPS: Enable HAVE_ARCH_TRACEHOOK.")
> Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>

Applied to mips-fixes.

Thanks,
    Paul

[ This message was auto-generated; if you believe anything is incorrect
  then please email paul.burton@mips.com to report it. ]

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

* [PATCH v2 16/15 v2] syscall_get_arch: add "struct task_struct *" argument
  2018-11-21 19:00         ` [PATCH v2 16/15] syscall_get_arch: add "struct task_struct *" argument Dmitry V. Levin
  2018-11-21 19:14           ` [PATCH] mips: fix mips_get_syscall_arg o32 check Dmitry V. Levin
@ 2018-11-21 19:35           ` Dmitry V. Levin
  2018-11-21 19:45             ` Paul Burton
  1 sibling, 1 reply; 84+ messages in thread
From: Dmitry V. Levin @ 2018-11-21 19:35 UTC (permalink / raw)
  To: Andy Lutomirski, Eric Paris, Paul Moore
  Cc: Paul Burton, Elvira Khabirova, Eugene Syromyatnikov,
	Oleg Nesterov, linux-audit, linux-alpha, linux-arch,
	linux-arm-kernel, linux-c6x-dev, linux-hexagon, linux-ia64,
	linux-m68k, linux-mips, linux-parisc, linux-riscv, linux-s390,
	linux-sh, linux-snps-arc, linux-um, linux-xtensa, linuxppc-dev,
	nios2-dev, openrisc, sparclinux, uclinux-h8-devel, x86,
	linux-kernel

This argument is required to extend the generic ptrace API with
PTRACE_GET_SYSCALL_INFO request: syscall_get_arch() is going to be
called from ptrace_request() along with other syscall_get_* functions
with a tracee as their argument.

This change partially reverts commit 5e937a9ae913 ("syscall_get_arch:
remove useless function arguments").

Reviewed-by: Andy Lutomirski <luto@kernel.org> # for x86
Reviewed-by: Palmer Dabbelt <palmer@sifive.com>
Cc: linux-audit@redhat.com
Cc: linux-alpha@vger.kernel.org
Cc: linux-arch@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-c6x-dev@linux-c6x.org
Cc: linux-hexagon@vger.kernel.org
Cc: linux-ia64@vger.kernel.org
Cc: linux-m68k@lists.linux-m68k.org
Cc: linux-mips@linux-mips.org
Cc: linux-parisc@vger.kernel.org
Cc: linux-riscv@lists.infradead.org
Cc: linux-s390@vger.kernel.org
Cc: linux-sh@vger.kernel.org
Cc: linux-snps-arc@lists.infradead.org
Cc: linux-um@lists.infradead.org
Cc: linux-xtensa@linux-xtensa.org
Cc: linuxppc-dev@lists.ozlabs.org
Cc: nios2-dev@lists.rocketboards.org
Cc: openrisc@lists.librecores.org
Cc: sparclinux@vger.kernel.org
Cc: uclinux-h8-devel@lists.sourceforge.jp
Cc: x86@kernel.org
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
---

v2: cleaned up mips part, added Reviewed-by

 arch/alpha/include/asm/syscall.h      |  2 +-
 arch/arc/include/asm/syscall.h        |  2 +-
 arch/arm/include/asm/syscall.h        |  2 +-
 arch/arm64/include/asm/syscall.h      |  4 ++--
 arch/c6x/include/asm/syscall.h        |  2 +-
 arch/h8300/include/asm/syscall.h      |  2 +-
 arch/hexagon/include/asm/syscall.h    |  2 +-
 arch/ia64/include/asm/syscall.h       |  2 +-
 arch/m68k/include/asm/syscall.h       |  2 +-
 arch/microblaze/include/asm/syscall.h |  2 +-
 arch/mips/include/asm/syscall.h       |  6 +++---
 arch/mips/kernel/ptrace.c             |  2 +-
 arch/nds32/include/asm/syscall.h      |  2 +-
 arch/nios2/include/asm/syscall.h      |  2 +-
 arch/openrisc/include/asm/syscall.h   |  2 +-
 arch/parisc/include/asm/syscall.h     |  4 ++--
 arch/powerpc/include/asm/syscall.h    | 10 ++++++++--
 arch/riscv/include/asm/syscall.h      |  2 +-
 arch/s390/include/asm/syscall.h       |  4 ++--
 arch/sh/include/asm/syscall_32.h      |  2 +-
 arch/sh/include/asm/syscall_64.h      |  2 +-
 arch/sparc/include/asm/syscall.h      |  5 +++--
 arch/unicore32/include/asm/syscall.h  |  2 +-
 arch/x86/include/asm/syscall.h        |  8 +++++---
 arch/x86/um/asm/syscall.h             |  2 +-
 arch/xtensa/include/asm/syscall.h     |  2 +-
 include/asm-generic/syscall.h         |  3 ++-
 kernel/auditsc.c                      |  4 ++--
 kernel/seccomp.c                      |  4 ++--
 29 files changed, 50 insertions(+), 40 deletions(-)

diff --git a/arch/alpha/include/asm/syscall.h b/arch/alpha/include/asm/syscall.h
index d73a6fcb519c..11c688c1d7ec 100644
--- a/arch/alpha/include/asm/syscall.h
+++ b/arch/alpha/include/asm/syscall.h
@@ -4,7 +4,7 @@
 
 #include <uapi/linux/audit.h>
 
-static inline int syscall_get_arch(void)
+static inline int syscall_get_arch(struct task_struct *task)
 {
 	return AUDIT_ARCH_ALPHA;
 }
diff --git a/arch/arc/include/asm/syscall.h b/arch/arc/include/asm/syscall.h
index 10b2e7523bc8..7834baa61de8 100644
--- a/arch/arc/include/asm/syscall.h
+++ b/arch/arc/include/asm/syscall.h
@@ -69,7 +69,7 @@ syscall_get_arguments(struct task_struct *task, struct pt_regs *regs,
 	}
 }
 
-static inline int syscall_get_arch(void)
+static inline int syscall_get_arch(struct task_struct *task)
 {
 	return IS_ENABLED(CONFIG_ISA_ARCOMPACT)
 		? (IS_ENABLED(CONFIG_CPU_BIG_ENDIAN)
diff --git a/arch/arm/include/asm/syscall.h b/arch/arm/include/asm/syscall.h
index 06dea6bce293..3940ceac0bdc 100644
--- a/arch/arm/include/asm/syscall.h
+++ b/arch/arm/include/asm/syscall.h
@@ -104,7 +104,7 @@ static inline void syscall_set_arguments(struct task_struct *task,
 	memcpy(&regs->ARM_r0 + i, args, n * sizeof(args[0]));
 }
 
-static inline int syscall_get_arch(void)
+static inline int syscall_get_arch(struct task_struct *task)
 {
 	/* ARM tasks don't change audit architectures on the fly. */
 	return AUDIT_ARCH_ARM;
diff --git a/arch/arm64/include/asm/syscall.h b/arch/arm64/include/asm/syscall.h
index ad8be16a39c9..1870df03f774 100644
--- a/arch/arm64/include/asm/syscall.h
+++ b/arch/arm64/include/asm/syscall.h
@@ -117,9 +117,9 @@ static inline void syscall_set_arguments(struct task_struct *task,
  * We don't care about endianness (__AUDIT_ARCH_LE bit) here because
  * AArch64 has the same system calls both on little- and big- endian.
  */
-static inline int syscall_get_arch(void)
+static inline int syscall_get_arch(struct task_struct *task)
 {
-	if (is_compat_task())
+	if (is_compat_thread(task_thread_info(task)))
 		return AUDIT_ARCH_ARM;
 
 	return AUDIT_ARCH_AARCH64;
diff --git a/arch/c6x/include/asm/syscall.h b/arch/c6x/include/asm/syscall.h
index 39dbd1ef994c..595057191c9c 100644
--- a/arch/c6x/include/asm/syscall.h
+++ b/arch/c6x/include/asm/syscall.h
@@ -121,7 +121,7 @@ static inline void syscall_set_arguments(struct task_struct *task,
 	}
 }
 
-static inline int syscall_get_arch(void)
+static inline int syscall_get_arch(struct task_struct *task)
 {
 	return IS_ENABLED(CONFIG_CPU_BIG_ENDIAN)
 		? AUDIT_ARCH_C6XBE : AUDIT_ARCH_C6X;
diff --git a/arch/h8300/include/asm/syscall.h b/arch/h8300/include/asm/syscall.h
index 699664a0b1be..e54f2f209f0c 100644
--- a/arch/h8300/include/asm/syscall.h
+++ b/arch/h8300/include/asm/syscall.h
@@ -48,7 +48,7 @@ syscall_get_arguments(struct task_struct *task, struct pt_regs *regs,
 	}
 }
 
-static inline int syscall_get_arch(void)
+static inline int syscall_get_arch(struct task_struct *task)
 {
 	return AUDIT_ARCH_H8300;
 }
diff --git a/arch/hexagon/include/asm/syscall.h b/arch/hexagon/include/asm/syscall.h
index de3917aad3fd..47b0bc3f16be 100644
--- a/arch/hexagon/include/asm/syscall.h
+++ b/arch/hexagon/include/asm/syscall.h
@@ -46,7 +46,7 @@ static inline void syscall_get_arguments(struct task_struct *task,
 	memcpy(args, &(&regs->r00)[i], n * sizeof(args[0]));
 }
 
-static inline int syscall_get_arch(void)
+static inline int syscall_get_arch(struct task_struct *task)
 {
 	return AUDIT_ARCH_HEXAGON;
 }
diff --git a/arch/ia64/include/asm/syscall.h b/arch/ia64/include/asm/syscall.h
index 1d0b875fec44..47ab33f5448a 100644
--- a/arch/ia64/include/asm/syscall.h
+++ b/arch/ia64/include/asm/syscall.h
@@ -81,7 +81,7 @@ static inline void syscall_set_arguments(struct task_struct *task,
 	ia64_syscall_get_set_arguments(task, regs, i, n, args, 1);
 }
 
-static inline int syscall_get_arch(void)
+static inline int syscall_get_arch(struct task_struct *task)
 {
 	return AUDIT_ARCH_IA64;
 }
diff --git a/arch/m68k/include/asm/syscall.h b/arch/m68k/include/asm/syscall.h
index d4d7deda8d50..465ac039be09 100644
--- a/arch/m68k/include/asm/syscall.h
+++ b/arch/m68k/include/asm/syscall.h
@@ -4,7 +4,7 @@
 
 #include <uapi/linux/audit.h>
 
-static inline int syscall_get_arch(void)
+static inline int syscall_get_arch(struct task_struct *task)
 {
 	return AUDIT_ARCH_M68K;
 }
diff --git a/arch/microblaze/include/asm/syscall.h b/arch/microblaze/include/asm/syscall.h
index 220decd605a4..77a86fafa974 100644
--- a/arch/microblaze/include/asm/syscall.h
+++ b/arch/microblaze/include/asm/syscall.h
@@ -101,7 +101,7 @@ static inline void syscall_set_arguments(struct task_struct *task,
 asmlinkage unsigned long do_syscall_trace_enter(struct pt_regs *regs);
 asmlinkage void do_syscall_trace_leave(struct pt_regs *regs);
 
-static inline int syscall_get_arch(void)
+static inline int syscall_get_arch(struct task_struct *task)
 {
 	return AUDIT_ARCH_MICROBLAZE;
 }
diff --git a/arch/mips/include/asm/syscall.h b/arch/mips/include/asm/syscall.h
index 0170602a1e4e..c3d3afbb5973 100644
--- a/arch/mips/include/asm/syscall.h
+++ b/arch/mips/include/asm/syscall.h
@@ -140,14 +140,14 @@ extern const unsigned long sys_call_table[];
 extern const unsigned long sys32_call_table[];
 extern const unsigned long sysn32_call_table[];
 
-static inline int syscall_get_arch(void)
+static inline int syscall_get_arch(struct task_struct *task)
 {
 	int arch = AUDIT_ARCH_MIPS;
 #ifdef CONFIG_64BIT
-	if (!test_thread_flag(TIF_32BIT_REGS)) {
+	if (!test_tsk_thread_flag(task, TIF_32BIT_REGS)) {
 		arch |= __AUDIT_ARCH_64BIT;
 		/* N32 sets only TIF_32BIT_ADDR */
-		if (test_thread_flag(TIF_32BIT_ADDR))
+		if (test_tsk_thread_flag(task, TIF_32BIT_ADDR))
 			arch |= __AUDIT_ARCH_CONVENTION_MIPS64_N32;
 	}
 #endif
diff --git a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c
index e5ba56c01ee0..e112c525c3a7 100644
--- a/arch/mips/kernel/ptrace.c
+++ b/arch/mips/kernel/ptrace.c
@@ -1272,7 +1272,7 @@ asmlinkage long syscall_trace_enter(struct pt_regs *regs, long syscall)
 		unsigned long args[6];
 
 		sd.nr = syscall;
-		sd.arch = syscall_get_arch();
+		sd.arch = syscall_get_arch(current);
 		syscall_get_arguments(current, regs, 0, 6, args);
 		for (i = 0; i < 6; i++)
 			sd.args[i] = args[i];
diff --git a/arch/nds32/include/asm/syscall.h b/arch/nds32/include/asm/syscall.h
index 569149ca25da..e109acd225e6 100644
--- a/arch/nds32/include/asm/syscall.h
+++ b/arch/nds32/include/asm/syscall.h
@@ -187,7 +187,7 @@ void syscall_set_arguments(struct task_struct *task, struct pt_regs *regs,
 	memcpy(&regs->uregs[0] + i, args, n * sizeof(args[0]));
 }
 
-static inline int syscall_get_arch(void)
+static inline int syscall_get_arch(struct task_struct *task)
 {
 	return IS_ENABLED(CONFIG_CPU_BIG_ENDIAN)
 		? AUDIT_ARCH_NDS32BE : AUDIT_ARCH_NDS32;
diff --git a/arch/nios2/include/asm/syscall.h b/arch/nios2/include/asm/syscall.h
index cf35e210fc4d..f0f6ae208e78 100644
--- a/arch/nios2/include/asm/syscall.h
+++ b/arch/nios2/include/asm/syscall.h
@@ -136,7 +136,7 @@ static inline void syscall_set_arguments(struct task_struct *task,
 	}
 }
 
-static inline int syscall_get_arch(void)
+static inline int syscall_get_arch(struct task_struct *task)
 {
 	return AUDIT_ARCH_NIOS2;
 }
diff --git a/arch/openrisc/include/asm/syscall.h b/arch/openrisc/include/asm/syscall.h
index 2db9f1cf0694..46b10c674bd2 100644
--- a/arch/openrisc/include/asm/syscall.h
+++ b/arch/openrisc/include/asm/syscall.h
@@ -72,7 +72,7 @@ syscall_set_arguments(struct task_struct *task, struct pt_regs *regs,
 	memcpy(&regs->gpr[3 + i], args, n * sizeof(args[0]));
 }
 
-static inline int syscall_get_arch(void)
+static inline int syscall_get_arch(struct task_struct *task)
 {
 	return AUDIT_ARCH_OPENRISC;
 }
diff --git a/arch/parisc/include/asm/syscall.h b/arch/parisc/include/asm/syscall.h
index 8bff1a58c97f..c04ffc6ac928 100644
--- a/arch/parisc/include/asm/syscall.h
+++ b/arch/parisc/include/asm/syscall.h
@@ -62,11 +62,11 @@ static inline void syscall_rollback(struct task_struct *task,
 	/* do nothing */
 }
 
-static inline int syscall_get_arch(void)
+static inline int syscall_get_arch(struct task_struct *task)
 {
 	int arch = AUDIT_ARCH_PARISC;
 #ifdef CONFIG_64BIT
-	if (!is_compat_task())
+	if (!__is_compat_task(task))
 		arch = AUDIT_ARCH_PARISC64;
 #endif
 	return arch;
diff --git a/arch/powerpc/include/asm/syscall.h b/arch/powerpc/include/asm/syscall.h
index ab9f3f0a8637..d88b34179118 100644
--- a/arch/powerpc/include/asm/syscall.h
+++ b/arch/powerpc/include/asm/syscall.h
@@ -100,9 +100,15 @@ static inline void syscall_set_arguments(struct task_struct *task,
 		regs->orig_gpr3 = args[0];
 }
 
-static inline int syscall_get_arch(void)
+static inline int syscall_get_arch(struct task_struct *task)
 {
-	int arch = is_32bit_task() ? AUDIT_ARCH_PPC : AUDIT_ARCH_PPC64;
+	int arch;
+
+	if (IS_ENABLED(CONFIG_PPC64) && !test_tsk_thread_flag(task, TIF_32BIT))
+		arch = AUDIT_ARCH_PPC64;
+	else
+		arch = AUDIT_ARCH_PPC;
+
 #ifdef __LITTLE_ENDIAN__
 	arch |= __AUDIT_ARCH_LE;
 #endif
diff --git a/arch/riscv/include/asm/syscall.h b/arch/riscv/include/asm/syscall.h
index bba3da6ef157..ca120a36a037 100644
--- a/arch/riscv/include/asm/syscall.h
+++ b/arch/riscv/include/asm/syscall.h
@@ -100,7 +100,7 @@ static inline void syscall_set_arguments(struct task_struct *task,
 	memcpy(&regs->a1 + i * sizeof(regs->a1), args, n * sizeof(regs->a0));
 }
 
-static inline int syscall_get_arch(void)
+static inline int syscall_get_arch(struct task_struct *task)
 {
 #ifdef CONFIG_64BIT
 	return AUDIT_ARCH_RISCV64;
diff --git a/arch/s390/include/asm/syscall.h b/arch/s390/include/asm/syscall.h
index 96f9a9151fde..5a40ea8b90ea 100644
--- a/arch/s390/include/asm/syscall.h
+++ b/arch/s390/include/asm/syscall.h
@@ -92,10 +92,10 @@ static inline void syscall_set_arguments(struct task_struct *task,
 		regs->orig_gpr2 = args[0];
 }
 
-static inline int syscall_get_arch(void)
+static inline int syscall_get_arch(struct task_struct *task)
 {
 #ifdef CONFIG_COMPAT
-	if (test_tsk_thread_flag(current, TIF_31BIT))
+	if (test_tsk_thread_flag(task, TIF_31BIT))
 		return AUDIT_ARCH_S390;
 #endif
 	return AUDIT_ARCH_S390X;
diff --git a/arch/sh/include/asm/syscall_32.h b/arch/sh/include/asm/syscall_32.h
index 6e118799831c..08de429eccd4 100644
--- a/arch/sh/include/asm/syscall_32.h
+++ b/arch/sh/include/asm/syscall_32.h
@@ -95,7 +95,7 @@ static inline void syscall_set_arguments(struct task_struct *task,
 	}
 }
 
-static inline int syscall_get_arch(void)
+static inline int syscall_get_arch(struct task_struct *task)
 {
 	int arch = AUDIT_ARCH_SH;
 
diff --git a/arch/sh/include/asm/syscall_64.h b/arch/sh/include/asm/syscall_64.h
index 43882580c7f9..9b62a2404531 100644
--- a/arch/sh/include/asm/syscall_64.h
+++ b/arch/sh/include/asm/syscall_64.h
@@ -63,7 +63,7 @@ static inline void syscall_set_arguments(struct task_struct *task,
 	memcpy(&regs->regs[2 + i], args, n * sizeof(args[0]));
 }
 
-static inline int syscall_get_arch(void)
+static inline int syscall_get_arch(struct task_struct *task)
 {
 	int arch = AUDIT_ARCH_SH;
 
diff --git a/arch/sparc/include/asm/syscall.h b/arch/sparc/include/asm/syscall.h
index 053989e3f6a6..9ffb367c17fd 100644
--- a/arch/sparc/include/asm/syscall.h
+++ b/arch/sparc/include/asm/syscall.h
@@ -128,10 +128,11 @@ static inline void syscall_set_arguments(struct task_struct *task,
 		regs->u_regs[UREG_I0 + i + j] = args[j];
 }
 
-static inline int syscall_get_arch(void)
+static inline int syscall_get_arch(struct task_struct *task)
 {
 #if defined(CONFIG_SPARC64) && defined(CONFIG_COMPAT)
-	return in_compat_syscall() ? AUDIT_ARCH_SPARC : AUDIT_ARCH_SPARC64;
+	return test_tsk_thread_flag(task, TIF_32BIT)
+		? AUDIT_ARCH_SPARC : AUDIT_ARCH_SPARC64;
 #elif defined(CONFIG_SPARC64)
 	return AUDIT_ARCH_SPARC64;
 #else
diff --git a/arch/unicore32/include/asm/syscall.h b/arch/unicore32/include/asm/syscall.h
index 3a6b885476b4..607961797fff 100644
--- a/arch/unicore32/include/asm/syscall.h
+++ b/arch/unicore32/include/asm/syscall.h
@@ -4,7 +4,7 @@
 
 #include <uapi/linux/audit.h>
 
-static inline int syscall_get_arch(void)
+static inline int syscall_get_arch(struct task_struct *task)
 {
 	return AUDIT_ARCH_UNICORE;
 }
diff --git a/arch/x86/include/asm/syscall.h b/arch/x86/include/asm/syscall.h
index d653139857af..435f3f09279c 100644
--- a/arch/x86/include/asm/syscall.h
+++ b/arch/x86/include/asm/syscall.h
@@ -107,7 +107,7 @@ static inline void syscall_set_arguments(struct task_struct *task,
 	memcpy(&regs->bx + i, args, n * sizeof(args[0]));
 }
 
-static inline int syscall_get_arch(void)
+static inline int syscall_get_arch(struct task_struct *task)
 {
 	return AUDIT_ARCH_I386;
 }
@@ -236,10 +236,12 @@ static inline void syscall_set_arguments(struct task_struct *task,
 		}
 }
 
-static inline int syscall_get_arch(void)
+static inline int syscall_get_arch(struct task_struct *task)
 {
 	/* x32 tasks should be considered AUDIT_ARCH_X86_64. */
-	return in_ia32_syscall() ? AUDIT_ARCH_I386 : AUDIT_ARCH_X86_64;
+	return (IS_ENABLED(CONFIG_IA32_EMULATION) &&
+		task->thread_info.status & TS_COMPAT)
+		? AUDIT_ARCH_I386 : AUDIT_ARCH_X86_64;
 }
 #endif	/* CONFIG_X86_32 */
 
diff --git a/arch/x86/um/asm/syscall.h b/arch/x86/um/asm/syscall.h
index ef898af102d1..56a2f0913e3c 100644
--- a/arch/x86/um/asm/syscall.h
+++ b/arch/x86/um/asm/syscall.h
@@ -9,7 +9,7 @@ typedef asmlinkage long (*sys_call_ptr_t)(unsigned long, unsigned long,
 					  unsigned long, unsigned long,
 					  unsigned long, unsigned long);
 
-static inline int syscall_get_arch(void)
+static inline int syscall_get_arch(struct task_struct *task)
 {
 #ifdef CONFIG_X86_32
 	return AUDIT_ARCH_I386;
diff --git a/arch/xtensa/include/asm/syscall.h b/arch/xtensa/include/asm/syscall.h
index 84144567095a..cb5ebeb31e60 100644
--- a/arch/xtensa/include/asm/syscall.h
+++ b/arch/xtensa/include/asm/syscall.h
@@ -10,7 +10,7 @@
 
 #include <uapi/linux/audit.h>
 
-static inline int syscall_get_arch(void)
+static inline int syscall_get_arch(struct task_struct *task)
 {
 	return AUDIT_ARCH_XTENSA;
 }
diff --git a/include/asm-generic/syscall.h b/include/asm-generic/syscall.h
index 0c938a4354f6..18d7a742788a 100644
--- a/include/asm-generic/syscall.h
+++ b/include/asm-generic/syscall.h
@@ -144,6 +144,7 @@ void syscall_set_arguments(struct task_struct *task, struct pt_regs *regs,
 
 /**
  * syscall_get_arch - return the AUDIT_ARCH for the current system call
+ * @task:	task of interest, must be blocked
  *
  * Returns the AUDIT_ARCH_* based on the system call convention in use.
  *
@@ -153,5 +154,5 @@ void syscall_set_arguments(struct task_struct *task, struct pt_regs *regs,
  * Architectures which permit CONFIG_HAVE_ARCH_SECCOMP_FILTER must
  * provide an implementation of this.
  */
-int syscall_get_arch(void);
+int syscall_get_arch(struct task_struct *task);
 #endif	/* _ASM_SYSCALL_H */
diff --git a/kernel/auditsc.c b/kernel/auditsc.c
index b2d1f043f17f..1319e3e7b16c 100644
--- a/kernel/auditsc.c
+++ b/kernel/auditsc.c
@@ -1537,7 +1537,7 @@ void __audit_syscall_entry(int major, unsigned long a1, unsigned long a2,
 			return;
 	}
 
-	context->arch	    = syscall_get_arch();
+	context->arch	    = syscall_get_arch(current);
 	context->major      = major;
 	context->argv[0]    = a1;
 	context->argv[1]    = a2;
@@ -2495,7 +2495,7 @@ void audit_seccomp(unsigned long syscall, long signr, int code)
 		return;
 	audit_log_task(ab);
 	audit_log_format(ab, " sig=%ld arch=%x syscall=%ld compat=%d ip=0x%lx code=0x%x",
-			 signr, syscall_get_arch(), syscall,
+			 signr, syscall_get_arch(current), syscall,
 			 in_compat_syscall(), KSTK_EIP(current), code);
 	audit_log_end(ab);
 }
diff --git a/kernel/seccomp.c b/kernel/seccomp.c
index f2ae2324c232..77cb87bd2eae 100644
--- a/kernel/seccomp.c
+++ b/kernel/seccomp.c
@@ -82,7 +82,7 @@ static void populate_seccomp_data(struct seccomp_data *sd)
 	unsigned long args[6];
 
 	sd->nr = syscall_get_nr(task, regs);
-	sd->arch = syscall_get_arch();
+	sd->arch = syscall_get_arch(task);
 	syscall_get_arguments(task, regs, 0, 6, args);
 	sd->args[0] = args[0];
 	sd->args[1] = args[1];
@@ -529,7 +529,7 @@ static void seccomp_init_siginfo(kernel_siginfo_t *info, int syscall, int reason
 	info->si_code = SYS_SECCOMP;
 	info->si_call_addr = (void __user *)KSTK_EIP(current);
 	info->si_errno = reason;
-	info->si_arch = syscall_get_arch();
+	info->si_arch = syscall_get_arch(current);
 	info->si_syscall = syscall;
 }
 
-- 
ldv

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

* Re: [PATCH v2 16/15 v2] syscall_get_arch: add "struct task_struct *" argument
  2018-11-21 19:35           ` [PATCH v2 16/15 v2] syscall_get_arch: add "struct task_struct *" argument Dmitry V. Levin
@ 2018-11-21 19:45             ` Paul Burton
  0 siblings, 0 replies; 84+ messages in thread
From: Paul Burton @ 2018-11-21 19:45 UTC (permalink / raw)
  To: Dmitry V. Levin
  Cc: Andy Lutomirski, Eric Paris, Paul Moore, Elvira Khabirova,
	Eugene Syromyatnikov, Oleg Nesterov, linux-audit, linux-alpha,
	linux-arch, linux-arm-kernel, linux-c6x-dev, linux-hexagon,
	linux-ia64, linux-m68k, linux-mips, linux-parisc, linux-riscv,
	linux-s390, linux-sh, linux-snps-arc, linux-um, linux-xtensa,
	linuxppc-dev, nios2-dev, openrisc, sparclinux, uclinux-h8-devel,
	x86, linux-kernel

Hi Dmitry,

On Wed, Nov 21, 2018 at 10:35:12PM +0300, Dmitry V. Levin wrote:
> This argument is required to extend the generic ptrace API with
> PTRACE_GET_SYSCALL_INFO request: syscall_get_arch() is going to be
> called from ptrace_request() along with other syscall_get_* functions
> with a tracee as their argument.
> 
> This change partially reverts commit 5e937a9ae913 ("syscall_get_arch:
> remove useless function arguments").
> 
> Reviewed-by: Andy Lutomirski <luto@kernel.org> # for x86
> Reviewed-by: Palmer Dabbelt <palmer@sifive.com>
> Cc: linux-audit@redhat.com
> Cc: linux-alpha@vger.kernel.org
> Cc: linux-arch@vger.kernel.org
> Cc: linux-arm-kernel@lists.infradead.org
> Cc: linux-c6x-dev@linux-c6x.org
> Cc: linux-hexagon@vger.kernel.org
> Cc: linux-ia64@vger.kernel.org
> Cc: linux-m68k@lists.linux-m68k.org
> Cc: linux-mips@linux-mips.org
> Cc: linux-parisc@vger.kernel.org
> Cc: linux-riscv@lists.infradead.org
> Cc: linux-s390@vger.kernel.org
> Cc: linux-sh@vger.kernel.org
> Cc: linux-snps-arc@lists.infradead.org
> Cc: linux-um@lists.infradead.org
> Cc: linux-xtensa@linux-xtensa.org
> Cc: linuxppc-dev@lists.ozlabs.org
> Cc: nios2-dev@lists.rocketboards.org
> Cc: openrisc@lists.librecores.org
> Cc: sparclinux@vger.kernel.org
> Cc: uclinux-h8-devel@lists.sourceforge.jp
> Cc: x86@kernel.org
> Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
> ---
> 
> v2: cleaned up mips part, added Reviewed-by

I thought the last one was v2? :)

Anyway, this looks fine to me now:

    Acked-by: Paul Burton <paul.burton@mips.com> # MIPS parts

Thanks,
    Paul

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

* Re: [PATCH v2 06/15] m68k: define syscall_get_arch()
  2018-11-20  0:15     ` [PATCH v2 06/15] m68k: define syscall_get_arch() Dmitry V. Levin
@ 2018-12-02 10:29       ` Geert Uytterhoeven
  2018-12-03  0:24         ` Dmitry V. Levin
  0 siblings, 1 reply; 84+ messages in thread
From: Geert Uytterhoeven @ 2018-12-02 10:29 UTC (permalink / raw)
  To: Dmitry V. Levin
  Cc: Andy Lutomirski, lineprinter, linux-m68k, Linux Kernel Mailing List

Hi Dmitry,

On Tue, Nov 20, 2018 at 1:15 AM Dmitry V. Levin <ldv@altlinux.org> wrote:
> syscall_get_arch() is required to be implemented on all architectures
> in order to extend the generic ptrace API with PTRACE_GET_SYSCALL_INFO
> request.
>
> Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>

Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>

What's your plan w.r.t. the upstreaming strategy?
Do you plan to get this series in as a whole, or through individual architecture
maintainers?

Thanks!

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: [PATCH v2 06/15] m68k: define syscall_get_arch()
  2018-12-02 10:29       ` Geert Uytterhoeven
@ 2018-12-03  0:24         ` Dmitry V. Levin
  2018-12-03  7:36           ` Geert Uytterhoeven
  0 siblings, 1 reply; 84+ messages in thread
From: Dmitry V. Levin @ 2018-12-03  0:24 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Andy Lutomirski, Elvira Khabirova, linux-m68k, Linux Kernel Mailing List

[-- Attachment #1: Type: text/plain, Size: 808 bytes --]

Hi Geert,

On Sun, Dec 02, 2018 at 11:29:10AM +0100, Geert Uytterhoeven wrote:
> Hi Dmitry,
> 
> On Tue, Nov 20, 2018 at 1:15 AM Dmitry V. Levin <ldv@altlinux.org> wrote:
> > syscall_get_arch() is required to be implemented on all architectures
> > in order to extend the generic ptrace API with PTRACE_GET_SYSCALL_INFO
> > request.
> >
> > Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
> 
> Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>
> 
> What's your plan w.r.t. the upstreaming strategy?
> Do you plan to get this series in as a whole, or through individual architecture
> maintainers?

Given that the last patch in this series adds an argument
to syscall_get_arch(), my plan is to get this series in
as a whole along with PTRACE_GET_SYSCALL_INFO series.


-- 
ldv

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

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

* Re: [PATCH v2 06/15] m68k: define syscall_get_arch()
  2018-12-03  0:24         ` Dmitry V. Levin
@ 2018-12-03  7:36           ` Geert Uytterhoeven
  0 siblings, 0 replies; 84+ messages in thread
From: Geert Uytterhoeven @ 2018-12-03  7:36 UTC (permalink / raw)
  To: Dmitry V. Levin
  Cc: Andy Lutomirski, lineprinter, linux-m68k, Linux Kernel Mailing List

Hi Dmitry,

On Mon, Dec 3, 2018 at 1:24 AM Dmitry V. Levin <ldv@altlinux.org> wrote:
> On Sun, Dec 02, 2018 at 11:29:10AM +0100, Geert Uytterhoeven wrote:
> > On Tue, Nov 20, 2018 at 1:15 AM Dmitry V. Levin <ldv@altlinux.org> wrote:
> > > syscall_get_arch() is required to be implemented on all architectures
> > > in order to extend the generic ptrace API with PTRACE_GET_SYSCALL_INFO
> > > request.
> > >
> > > Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
> >
> > Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>
> >
> > What's your plan w.r.t. the upstreaming strategy?
> > Do you plan to get this series in as a whole, or through individual architecture
> > maintainers?
>
> Given that the last patch in this series adds an argument
> to syscall_get_arch(), my plan is to get this series in
> as a whole along with PTRACE_GET_SYSCALL_INFO series.

Cool, thanks!

Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

end of thread, other threads:[~2018-12-03  7:36 UTC | newest]

Thread overview: 84+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-07  3:27 [RFC PATCH] ptrace: add PTRACE_GET_SYSCALL_INFO request Elvira Khabirova
2018-11-07 11:21 ` Oleg Nesterov
2018-11-07 14:06   ` Andy Lutomirski
2018-11-07 16:44     ` Oleg Nesterov
2018-11-07 20:02       ` Elvira Khabirova
2018-11-08  9:16         ` Oleg Nesterov
2018-11-07 20:20       ` Andy Lutomirski
2018-11-08 14:33         ` Oleg Nesterov
2018-11-07 16:12   ` Dmitry V. Levin
2018-11-07 15:50 ` Dmitry V. Levin
2018-11-07 20:44 ` Andy Lutomirski
2018-11-09  3:13   ` [PATCH 00/13] Prepare for PTRACE_GET_SYSCALL_INFO Dmitry V. Levin
2018-11-09  3:15     ` [PATCH 01/13] Move EM_HEXAGON to uapi/linux/elf-em.h Dmitry V. Levin
2018-11-09  3:15     ` [PATCH 02/13] elf-em.h: add EM_ARC Dmitry V. Levin
2018-11-09 14:20       ` Alexey Brodkin
2018-11-09 16:41       ` Vineet Gupta
2018-11-09 21:44         ` Dmitry V. Levin
2018-11-09 23:33           ` [PATCH 02/13 v2] Move EM_ARCOMPACT and EM_ARCV2 to uapi/linux/elf-em.h Dmitry V. Levin
2018-11-09 23:42             ` Vineet Gupta
2018-11-09  3:15     ` [PATCH 03/13] elf-em.h: add EM_NDS32 Dmitry V. Levin
2018-11-09  3:15     ` [PATCH 04/13] elf-em.h: add EM_XTENSA Dmitry V. Levin
2018-11-09  6:45       ` Max Filippov
2018-11-09  3:15     ` [PATCH 05/13] m68k: define syscall_get_arch() Dmitry V. Levin
2018-11-09  3:16     ` [PATCH 06/13] arc: " Dmitry V. Levin
2018-11-09 14:22       ` Alexey Brodkin
2018-11-09 15:17         ` Andy Lutomirski
2018-11-09 15:27           ` Alexey Brodkin
2018-11-09 15:56             ` Andy Lutomirski
2018-11-09 16:11               ` Alexey Brodkin
2018-11-09 16:35                 ` Andy Lutomirski
2018-11-09 23:33                   ` [PATCH 06/13 v2] " Dmitry V. Levin
2018-11-09 23:39                     ` Vineet Gupta
2018-11-09 23:54                       ` [PATCH 06/13 v3] " Dmitry V. Levin
2018-11-10  0:06                         ` Vineet Gupta
2018-11-09 16:50       ` [PATCH 06/13] " Vineet Gupta
2018-11-09 19:03         ` Andy Lutomirski
2018-11-09 19:13           ` Vineet Gupta
2018-11-09  3:16     ` [PATCH 07/13] c6x: " Dmitry V. Levin
2018-11-10  2:01       ` [PATCH 07/13 v2] " Dmitry V. Levin
2018-11-09  3:16     ` [PATCH 08/13] h8300: " Dmitry V. Levin
2018-11-09  3:16     ` [PATCH 09/13] hexagon: " Dmitry V. Levin
2018-11-09  3:16     ` [PATCH 10/13] nds32: " Dmitry V. Levin
2018-11-10  2:01       ` [PATCH 10/13 v2] " Dmitry V. Levin
2018-11-09  3:17     ` [PATCH 11/13] nios2: " Dmitry V. Levin
2018-11-09  3:17     ` [PATCH 12/13] riscv: " Dmitry V. Levin
2018-11-09  6:59       ` David Abdurachmanov
2018-11-09 22:28         ` Dmitry V. Levin
2018-11-10  5:12           ` David Abdurachmanov
2018-11-10  9:27           ` Andreas Schwab
2018-11-09 18:45       ` Palmer Dabbelt
2018-11-09 21:31         ` Dmitry V. Levin
2018-11-09 22:48           ` [PATCH 12/13 v2] " Dmitry V. Levin
2018-11-11 21:21             ` Palmer Dabbelt
2018-11-09  3:17     ` [PATCH 13/13] xtensa: " Dmitry V. Levin
2018-11-09  6:48       ` Max Filippov
2018-11-09  6:06     ` [PATCH 00/13] Prepare for PTRACE_GET_SYSCALL_INFO Andy Lutomirski
2018-11-10 14:09     ` [PATCH 14/13] Move EM_UNICORE to uapi/linux/elf-em.h Dmitry V. Levin
2018-11-10 14:10     ` [PATCH 15/13] unicore32: define syscall_get_arch() Dmitry V. Levin
2018-11-13  3:38   ` [RFC PATCH] ptrace: add PTRACE_GET_SYSCALL_INFO request Dmitry V. Levin
2018-11-20  0:11   ` [PATCH v2 00/15] Prepare for PTRACE_GET_SYSCALL_INFO Dmitry V. Levin
2018-11-20  0:14     ` [PATCH v2 01/15] Move EM_HEXAGON to uapi/linux/elf-em.h Dmitry V. Levin
2018-11-20  0:14     ` [PATCH v2 02/15] Move EM_ARCOMPACT and EM_ARCV2 " Dmitry V. Levin
2018-11-20  0:14     ` [PATCH v2 03/15] Move EM_UNICORE " Dmitry V. Levin
2018-11-20  0:15     ` [PATCH v2 04/15] elf-em.h: add EM_NDS32 Dmitry V. Levin
2018-11-20  0:15     ` [PATCH v2 05/15] elf-em.h: add EM_XTENSA Dmitry V. Levin
2018-11-20  0:15     ` [PATCH v2 06/15] m68k: define syscall_get_arch() Dmitry V. Levin
2018-12-02 10:29       ` Geert Uytterhoeven
2018-12-03  0:24         ` Dmitry V. Levin
2018-12-03  7:36           ` Geert Uytterhoeven
2018-11-20  0:15     ` [PATCH v2 07/15] arc: " Dmitry V. Levin
2018-11-20  0:15     ` [PATCH v2 08/15] c6x: " Dmitry V. Levin
2018-11-20  0:16     ` [PATCH v2 09/15] h8300: " Dmitry V. Levin
2018-11-20  0:16     ` [PATCH v2 10/15] hexagon: " Dmitry V. Levin
2018-11-20  0:16     ` [PATCH v2 11/15] nds32: " Dmitry V. Levin
2018-11-20  0:16     ` [PATCH v2 12/15] nios2: " Dmitry V. Levin
2018-11-20  0:16     ` [PATCH v2 13/15] riscv: " Dmitry V. Levin
2018-11-20  0:16     ` [PATCH v2 14/15] unicore32: " Dmitry V. Levin
2018-11-20  0:17     ` [PATCH v2 15/15] xtensa: " Dmitry V. Levin
2018-11-20 20:26     ` [PATCH v2 00/15] Prepare for PTRACE_GET_SYSCALL_INFO Paul Moore
     [not found]     ` <20181121004422.GA29053@altlinux.org>
     [not found]       ` <20181121184004.jro532jopnbmru2m@pburton-laptop>
2018-11-21 19:00         ` [PATCH v2 16/15] syscall_get_arch: add "struct task_struct *" argument Dmitry V. Levin
2018-11-21 19:14           ` [PATCH] mips: fix mips_get_syscall_arg o32 check Dmitry V. Levin
2018-11-21 19:23             ` Paul Burton
2018-11-21 19:35           ` [PATCH v2 16/15 v2] syscall_get_arch: add "struct task_struct *" argument Dmitry V. Levin
2018-11-21 19:45             ` Paul Burton

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