2018-11-07 03:52:14

by Elvira Khabirova

[permalink] [raw]
Subject: [RFC PATCH] ptrace: add PTRACE_GET_SYSCALL_INFO request

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 <[email protected]>
---
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



2018-11-07 11:23:45

by Oleg Nesterov

[permalink] [raw]
Subject: Re: [RFC PATCH] ptrace: add PTRACE_GET_SYSCALL_INFO request

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.


2018-11-07 14:08:14

by Andy Lutomirski

[permalink] [raw]
Subject: Re: [RFC PATCH] ptrace: add PTRACE_GET_SYSCALL_INFO request



> On Nov 7, 2018, at 3:21 AM, Oleg Nesterov <[email protected]> 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.)

>

2018-11-07 16:45:54

by Oleg Nesterov

[permalink] [raw]
Subject: Re: [RFC PATCH] ptrace: add PTRACE_GET_SYSCALL_INFO request

On 11/07, Andy Lutomirski wrote:
>
>
> > On Nov 7, 2018, at 3:21 AM, Oleg Nesterov <[email protected]> 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.


2018-11-07 18:01:59

by Dmitry V. Levin

[permalink] [raw]
Subject: Re: [RFC PATCH] ptrace: add PTRACE_GET_SYSCALL_INFO request

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

2018-11-07 18:05:11

by Dmitry V. Levin

[permalink] [raw]
Subject: Re: [RFC PATCH] ptrace: add PTRACE_GET_SYSCALL_INFO request

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

2018-11-07 20:04:26

by Elvira Khabirova

[permalink] [raw]
Subject: Re: [RFC PATCH] ptrace: add PTRACE_GET_SYSCALL_INFO request

On Wed, 7 Nov 2018 17:44:44 +0100
Oleg Nesterov <[email protected]> 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.

2018-11-07 20:23:18

by Andy Lutomirski

[permalink] [raw]
Subject: Re: [RFC PATCH] ptrace: add PTRACE_GET_SYSCALL_INFO request



> On Nov 7, 2018, at 8:44 AM, Oleg Nesterov <[email protected]> wrote:
>
>> On 11/07, Andy Lutomirski wrote:
>>
>>
>>>> On Nov 7, 2018, at 3:21 AM, Oleg Nesterov <[email protected]> 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.


2018-11-07 20:46:28

by Andy Lutomirski

[permalink] [raw]
Subject: Re: [RFC PATCH] ptrace: add PTRACE_GET_SYSCALL_INFO request

> On Nov 6, 2018, at 7:27 PM, Elvira Khabirova <[email protected]> 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.

2018-11-08 09:18:10

by Oleg Nesterov

[permalink] [raw]
Subject: Re: [RFC PATCH] ptrace: add PTRACE_GET_SYSCALL_INFO request

On 11/07, Elvira Khabirova wrote:
>
> On Wed, 7 Nov 2018 17:44:44 +0100
> Oleg Nesterov <[email protected]> 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.


2018-11-08 14:34:31

by Oleg Nesterov

[permalink] [raw]
Subject: Re: [RFC PATCH] ptrace: add PTRACE_GET_SYSCALL_INFO request

On 11/07, Andy Lutomirski wrote:
>
> > On Nov 7, 2018, at 8:44 AM, Oleg Nesterov <[email protected]> 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.


2018-11-09 03:13:52

by Dmitry V. Levin

[permalink] [raw]
Subject: [PATCH 00/13] Prepare for PTRACE_GET_SYSCALL_INFO

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

2018-11-09 03:16:23

by Dmitry V. Levin

[permalink] [raw]
Subject: [PATCH 02/13] elf-em.h: add EM_ARC

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 <[email protected]>
---
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

2018-11-09 03:16:45

by Dmitry V. Levin

[permalink] [raw]
Subject: [PATCH 04/13] elf-em.h: add EM_XTENSA

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 <[email protected]>
---
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

2018-11-09 03:17:03

by Dmitry V. Levin

[permalink] [raw]
Subject: [PATCH 05/13] m68k: define syscall_get_arch()

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 <[email protected]>
---
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

2018-11-09 03:17:06

by Dmitry V. Levin

[permalink] [raw]
Subject: [PATCH 01/13] Move EM_HEXAGON to uapi/linux/elf-em.h

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 <[email protected]>
---
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

2018-11-09 03:17:33

by Dmitry V. Levin

[permalink] [raw]
Subject: [PATCH 07/13] c6x: define syscall_get_arch()

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 <[email protected]>
---
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

2018-11-09 03:17:41

by Dmitry V. Levin

[permalink] [raw]
Subject: [PATCH 08/13] h8300: define syscall_get_arch()

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 <[email protected]>
---
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

2018-11-09 03:17:43

by Dmitry V. Levin

[permalink] [raw]
Subject: [PATCH 03/13] elf-em.h: add EM_NDS32

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 <[email protected]>
---
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

2018-11-09 03:17:55

by Dmitry V. Levin

[permalink] [raw]
Subject: [PATCH 10/13] nds32: define syscall_get_arch()

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 <[email protected]>
---
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

2018-11-09 03:18:13

by Dmitry V. Levin

[permalink] [raw]
Subject: [PATCH 11/13] nios2: define syscall_get_arch()

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 <[email protected]>
---
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

2018-11-09 03:18:17

by Dmitry V. Levin

[permalink] [raw]
Subject: [PATCH 12/13] riscv: define syscall_get_arch()

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 <[email protected]>
---
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

2018-11-09 03:18:23

by Dmitry V. Levin

[permalink] [raw]
Subject: [PATCH 06/13] arc: define syscall_get_arch()

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 <[email protected]>
---
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

2018-11-09 03:19:04

by Dmitry V. Levin

[permalink] [raw]
Subject: [PATCH 09/13] hexagon: define syscall_get_arch()

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 <[email protected]>
---
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

2018-11-09 03:19:59

by Dmitry V. Levin

[permalink] [raw]
Subject: [PATCH 13/13] xtensa: define syscall_get_arch()

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 <[email protected]>
---
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

2018-11-09 06:07:09

by Andy Lutomirski

[permalink] [raw]
Subject: Re: [PATCH 00/13] Prepare for PTRACE_GET_SYSCALL_INFO

On Thu, Nov 8, 2018 at 7:13 PM Dmitry V. Levin <[email protected]> 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

2018-11-09 06:46:44

by Max Filippov

[permalink] [raw]
Subject: Re: [PATCH 04/13] elf-em.h: add EM_XTENSA

On Thu, Nov 8, 2018 at 7:15 PM Dmitry V. Levin <[email protected]> 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 <[email protected]>
> ---
> include/uapi/linux/elf-em.h | 1 +
> 1 file changed, 1 insertion(+)

Reviewed-by: Max Filippov <[email protected]>

--
Thanks.
-- Max

2018-11-09 06:50:40

by Max Filippov

[permalink] [raw]
Subject: Re: [PATCH 13/13] xtensa: define syscall_get_arch()

On Thu, Nov 8, 2018 at 7:17 PM Dmitry V. Levin <[email protected]> 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 <[email protected]>
> ---
> arch/xtensa/include/asm/syscall.h | 7 +++++++
> include/uapi/linux/audit.h | 1 +
> 2 files changed, 8 insertions(+)

Acked-by: Max Filippov <[email protected]>

--
Thanks.
-- Max

2018-11-09 07:00:03

by David Abdurachmanov

[permalink] [raw]
Subject: Re: [PATCH 12/13] riscv: define syscall_get_arch()

On Fri, Nov 9, 2018 at 4:17 AM Dmitry V. Levin <[email protected]> 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

2018-11-09 14:23:24

by Alexey Brodkin

[permalink] [raw]
Subject: Re: [PATCH 02/13] elf-em.h: add EM_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 <[email protected]>
> ---
> 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

2018-11-09 14:26:44

by Alexey Brodkin

[permalink] [raw]
Subject: Re: [PATCH 06/13] arc: define syscall_get_arch()

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 <[email protected]>
> ---
> 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

2018-11-09 15:20:20

by Andy Lutomirski

[permalink] [raw]
Subject: Re: [PATCH 06/13] arc: define syscall_get_arch()

On Fri, Nov 9, 2018 at 6:22 AM Alexey Brodkin
<[email protected]> 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 <[email protected]>
> > ---
> > 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?

2018-11-09 15:33:08

by Alexey Brodkin

[permalink] [raw]
Subject: Re: [PATCH 06/13] arc: define syscall_get_arch()

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
> <[email protected]> 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 <[email protected]>
> > > ---
> > > 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

2018-11-09 15:57:37

by Andy Lutomirski

[permalink] [raw]
Subject: Re: [PATCH 06/13] arc: define syscall_get_arch()



> On Nov 9, 2018, at 7:27 AM, Alexey Brodkin <[email protected]> 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
>> <[email protected]> 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 <[email protected]>
>>>> ---
>>>> 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?

2018-11-09 16:14:21

by Alexey Brodkin

[permalink] [raw]
Subject: Re: [PATCH 06/13] arc: define syscall_get_arch()

Hi Andy,

On Fri, 2018-11-09 at 07:56 -0800, Andy Lutomirski wrote:
> > On Nov 9, 2018, at 7:27 AM, Alexey Brodkin <[email protected]> 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
> > > <[email protected]> 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 <[email protected]>
> > > > > ---
> > > > > 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

2018-11-09 16:36:59

by Andy Lutomirski

[permalink] [raw]
Subject: Re: [PATCH 06/13] arc: define syscall_get_arch()

On Fri, Nov 9, 2018 at 8:11 AM Alexey Brodkin
<[email protected]> 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 <[email protected]> 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
> > > > <[email protected]> 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 <[email protected]>
> > > > > > ---
> > > > > > 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

2018-11-09 16:44:14

by Vineet Gupta

[permalink] [raw]
Subject: Re: [PATCH 02/13] elf-em.h: add EM_ARC

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 <[email protected]>
> ---
> 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 */


2018-11-09 16:51:07

by Vineet Gupta

[permalink] [raw]
Subject: Re: [PATCH 06/13] arc: define syscall_get_arch()

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 <[email protected]>
> ---
> 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 ?

2018-11-09 18:47:22

by Palmer Dabbelt

[permalink] [raw]
Subject: Re: [PATCH 12/13] riscv: define syscall_get_arch()

On Thu, 08 Nov 2018 19:17:13 PST (-0800), [email protected] 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 <[email protected]>
> ---
> 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.

2018-11-09 19:07:58

by Andy Lutomirski

[permalink] [raw]
Subject: Re: [PATCH 06/13] arc: define syscall_get_arch()



> On Nov 9, 2018, at 8:50 AM, Vineet Gupta <[email protected]> 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 <[email protected]>
>> ---
>> 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.

2018-11-09 19:15:46

by Vineet Gupta

[permalink] [raw]
Subject: Re: [PATCH 06/13] arc: define syscall_get_arch()

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.


2018-11-09 21:33:55

by Dmitry V. Levin

[permalink] [raw]
Subject: Re: [PATCH 12/13] riscv: define syscall_get_arch()

On Fri, Nov 09, 2018 at 10:45:54AM -0800, Palmer Dabbelt wrote:
> On Thu, 08 Nov 2018 19:17:13 PST (-0800), [email protected] 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 <[email protected]>
> > ---
> > 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


Attachments:
(No filename) (2.54 kB)
signature.asc (817.00 B)
Download all attachments

2018-11-09 21:45:07

by Dmitry V. Levin

[permalink] [raw]
Subject: Re: [PATCH 02/13] elf-em.h: add EM_ARC

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 <[email protected]>
> > ---
> > 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


Attachments:
(No filename) (1.55 kB)
signature.asc (817.00 B)
Download all attachments

2018-11-09 22:29:24

by Dmitry V. Levin

[permalink] [raw]
Subject: Re: [PATCH 12/13] riscv: define syscall_get_arch()

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 <[email protected]> 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


Attachments:
(No filename) (769.00 B)
signature.asc (817.00 B)
Download all attachments

2018-11-09 22:49:13

by Dmitry V. Levin

[permalink] [raw]
Subject: [PATCH 12/13 v2] riscv: define syscall_get_arch()

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 <[email protected]>
Signed-off-by: Dmitry V. Levin <[email protected]>
---
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

2018-11-09 23:35:23

by Dmitry V. Levin

[permalink] [raw]
Subject: [PATCH 02/13 v2] Move EM_ARCOMPACT and EM_ARCV2 to uapi/linux/elf-em.h

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 <[email protected]>
---
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

2018-11-09 23:36:09

by Dmitry V. Levin

[permalink] [raw]
Subject: [PATCH 06/13 v2] arc: define syscall_get_arch()

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 <[email protected]>
---
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

2018-11-09 23:39:47

by Vineet Gupta

[permalink] [raw]
Subject: Re: [PATCH 06/13 v2] arc: define syscall_get_arch()

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 <[email protected]>
> ---
> 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.

2018-11-09 23:43:24

by Vineet Gupta

[permalink] [raw]
Subject: Re: [PATCH 02/13 v2] Move EM_ARCOMPACT and EM_ARCV2 to uapi/linux/elf-em.h

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 <[email protected]>
> ---
> 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 <[email protected]>




2018-11-09 23:55:09

by Dmitry V. Levin

[permalink] [raw]
Subject: [PATCH 06/13 v3] arc: define syscall_get_arch()

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 <[email protected]>
---
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

2018-11-10 00:08:37

by Vineet Gupta

[permalink] [raw]
Subject: Re: [PATCH 06/13 v3] arc: define syscall_get_arch()

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 <[email protected]>

Acked-by: Vineet Gupta <[email protected]>

2018-11-10 02:02:07

by Dmitry V. Levin

[permalink] [raw]
Subject: [PATCH 07/13 v2] c6x: define syscall_get_arch()

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 <[email protected]>
---
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

2018-11-10 02:02:41

by Dmitry V. Levin

[permalink] [raw]
Subject: [PATCH 10/13 v2] nds32: define syscall_get_arch()

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 <[email protected]>
---
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

2018-11-10 05:42:52

by David Abdurachmanov

[permalink] [raw]
Subject: Re: [PATCH 12/13] riscv: define syscall_get_arch()

On Fri, Nov 9, 2018 at 11:28 PM Dmitry V. Levin <[email protected]> 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 :/

2018-11-10 09:29:20

by Andreas Schwab

[permalink] [raw]
Subject: Re: [PATCH 12/13] riscv: define syscall_get_arch()

On Nov 10 2018, "Dmitry V. Levin" <[email protected]> wrote:

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

You are explicitly forbidding that.

Andreas.

--
Andreas Schwab, [email protected]
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1
"And now for something completely different."

2018-11-10 14:10:27

by Dmitry V. Levin

[permalink] [raw]
Subject: [PATCH 14/13] Move EM_UNICORE to uapi/linux/elf-em.h

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 <[email protected]>
---
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

2018-11-10 14:11:26

by Dmitry V. Levin

[permalink] [raw]
Subject: [PATCH 15/13] unicore32: define syscall_get_arch()

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 <[email protected]>
---
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

2018-11-11 21:22:02

by Palmer Dabbelt

[permalink] [raw]
Subject: Re: [PATCH 12/13 v2] riscv: define syscall_get_arch()

On Fri, 09 Nov 2018 14:48:33 PST (-0800), [email protected] 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 <[email protected]>
> Signed-off-by: Dmitry V. Levin <[email protected]>
> ---
> 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 <[email protected]>

Thanks!

2018-11-13 03:38:41

by Dmitry V. Levin

[permalink] [raw]
Subject: Re: [RFC PATCH] ptrace: add PTRACE_GET_SYSCALL_INFO request

On Wed, Nov 07, 2018 at 12:44:58PM -0800, Andy Lutomirski wrote:
> > On Nov 6, 2018, at 7:27 PM, Elvira Khabirova <[email protected]> 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

2018-11-20 00:15:24

by Dmitry V. Levin

[permalink] [raw]
Subject: [PATCH v2 00/15] Prepare for PTRACE_GET_SYSCALL_INFO

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

2018-11-20 00:17:22

by Dmitry V. Levin

[permalink] [raw]
Subject: [PATCH v2 09/15] h8300: define syscall_get_arch()

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 <[email protected]>
---
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

2018-11-20 00:17:31

by Dmitry V. Levin

[permalink] [raw]
Subject: [PATCH v2 10/15] hexagon: define syscall_get_arch()

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 <[email protected]>
---
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

2018-11-20 00:17:52

by Dmitry V. Levin

[permalink] [raw]
Subject: [PATCH v2 12/15] nios2: define syscall_get_arch()

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 <[email protected]>
---
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

2018-11-20 00:50:36

by Dmitry V. Levin

[permalink] [raw]
Subject: [PATCH v2 02/15] Move EM_ARCOMPACT and EM_ARCV2 to uapi/linux/elf-em.h

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 <[email protected]>
Acked-by: Vineet Gupta <[email protected]>
---
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

2018-11-20 00:50:38

by Dmitry V. Levin

[permalink] [raw]
Subject: [PATCH v2 03/15] Move EM_UNICORE to uapi/linux/elf-em.h

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 <[email protected]>
---
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

2018-11-20 00:50:44

by Dmitry V. Levin

[permalink] [raw]
Subject: [PATCH v2 05/15] elf-em.h: add EM_XTENSA

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 <[email protected]>
Reviewed-by: Max Filippov <[email protected]>
---
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

2018-11-20 00:50:45

by Dmitry V. Levin

[permalink] [raw]
Subject: [PATCH v2 06/15] m68k: define syscall_get_arch()

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 <[email protected]>
---
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

2018-11-20 00:50:46

by Dmitry V. Levin

[permalink] [raw]
Subject: [PATCH v2 11/15] nds32: define syscall_get_arch()

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 <[email protected]>
---
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

2018-11-20 00:50:47

by Dmitry V. Levin

[permalink] [raw]
Subject: [PATCH v2 07/15] arc: define syscall_get_arch()

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 <[email protected]>
Acked-by: Vineet Gupta <[email protected]>
---
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

2018-11-20 00:50:48

by Dmitry V. Levin

[permalink] [raw]
Subject: [PATCH v2 13/15] riscv: define syscall_get_arch()

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 <[email protected]>
Signed-off-by: Dmitry V. Levin <[email protected]>
Reviewed-by: Palmer Dabbelt <[email protected]>
---
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

2018-11-20 00:50:58

by Dmitry V. Levin

[permalink] [raw]
Subject: [PATCH v2 14/15] unicore32: define syscall_get_arch()

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 <[email protected]>
---
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

2018-11-20 00:51:02

by Dmitry V. Levin

[permalink] [raw]
Subject: [PATCH v2 15/15] xtensa: define syscall_get_arch()

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 <[email protected]>
Acked-by: Max Filippov <[email protected]>
---
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

2018-11-20 02:04:57

by Dmitry V. Levin

[permalink] [raw]
Subject: [PATCH v2 01/15] Move EM_HEXAGON to uapi/linux/elf-em.h

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 <[email protected]>
---
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

2018-11-20 02:04:58

by Dmitry V. Levin

[permalink] [raw]
Subject: [PATCH v2 04/15] elf-em.h: add EM_NDS32

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 <[email protected]>
---
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

2018-11-20 02:05:00

by Dmitry V. Levin

[permalink] [raw]
Subject: [PATCH v2 08/15] c6x: define syscall_get_arch()

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 <[email protected]>
---
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

2018-11-20 21:08:24

by Paul Moore

[permalink] [raw]
Subject: Re: [PATCH v2 00/15] Prepare for PTRACE_GET_SYSCALL_INFO

On Mon, Nov 19, 2018 at 7:11 PM Dmitry V. Levin <[email protected]> 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
http://www.paul-moore.com

2018-12-02 10:31:57

by Geert Uytterhoeven

[permalink] [raw]
Subject: Re: [PATCH v2 06/15] m68k: define syscall_get_arch()

Hi Dmitry,

On Tue, Nov 20, 2018 at 1:15 AM Dmitry V. Levin <[email protected]> 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 <[email protected]>

Reviewed-by: Geert Uytterhoeven <[email protected]>

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 -- [email protected]

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

2018-12-03 00:26:17

by Dmitry V. Levin

[permalink] [raw]
Subject: Re: [PATCH v2 06/15] m68k: define syscall_get_arch()

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 <[email protected]> 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 <[email protected]>
>
> Reviewed-by: Geert Uytterhoeven <[email protected]>
>
> 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


Attachments:
(No filename) (808.00 B)
signature.asc (817.00 B)
Download all attachments

2018-12-03 07:39:03

by Geert Uytterhoeven

[permalink] [raw]
Subject: Re: [PATCH v2 06/15] m68k: define syscall_get_arch()

Hi Dmitry,

On Mon, Dec 3, 2018 at 1:24 AM Dmitry V. Levin <[email protected]> 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 <[email protected]> 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 <[email protected]>
> >
> > Reviewed-by: Geert Uytterhoeven <[email protected]>
> >
> > 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 <[email protected]>

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

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