ptrace: add PTRACE_GET_SYSCALL_INFO request
Subsystems (26)
RFC PATCH 1/1 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
--- 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(-)
arch/alpha/kernel/ptrace.c +1 -1
@@ -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;
arch/arc/kernel/ptrace.c +1 -1
@@ -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;
arch/arm/kernel/ptrace.c +1 -1
@@ -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;
arch/arm64/kernel/ptrace.c +1 -1
@@ -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;
arch/c6x/kernel/ptrace.c +1 -1
@@ -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
arch/h8300/kernel/ptrace.c +1 -1
@@ -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
arch/hexagon/kernel/traps.c +1 -1
@@ -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 */
arch/ia64/kernel/ptrace.c +1 -1
@@ -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 (®s)) +if (tracehook_report_syscall_entry (®s, false))return -ENOSYS ;/* copy user rbs to kernel rbs */
arch/m68k/kernel/ptrace.c +2 -1
@@ -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; }
arch/microblaze/kernel/ptrace.c +1 -1
@@ -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
arch/mips/kernel/ptrace.c +1 -1
@@ -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; }
arch/nds32/kernel/ptrace.c +1 -1
@@ -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;
arch/nios2/kernel/ptrace.c +2 -1
@@ -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; }
arch/openrisc/kernel/ptrace.c +1 -1
@@ -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
arch/parisc/kernel/ptrace.c +1 -1
@@ -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
arch/powerpc/kernel/ptrace.c +1 -1
@@ -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]. */
arch/riscv/kernel/ptrace.c +1 -1
@@ -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
arch/s390/kernel/ptrace.c +1 -1
@@ -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
arch/sh/kernel/ptrace_32.c +1 -1
@@ -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
arch/sh/kernel/ptrace_64.c +1 -1
@@ -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
arch/sparc/kernel/ptrace_32.c +1 -1
@@ -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;
arch/sparc/kernel/ptrace_64.c +1 -1
@@ -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 ]);
arch/um/kernel/ptrace.c +1 -1
@@ -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)
arch/x86/entry/common.c +1 -1
@@ -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)
arch/xtensa/kernel/ptrace.c +1 -1
@@ -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 ];
include/linux/ptrace.h +13 -3
@@ -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);
include/linux/tracehook.h +9 -4
@@ -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 ); }/**
include/uapi/linux/ptrace.h +22 -0
@@ -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)
kernel/ptrace.c +42 -0
60 lines not on this page · raw message
Signature · 1 line
2.19.1
Oleg Nesterov
maintainerQuoted 5 lines · Elvira Khabirova
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.
Quoted 4 lines
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.
Quoted 1 line
+#define
PT_IN_SYSCALL_STOP0x00000004/* task is in a syscall-stop */
...
Quoted 20 lines
include/linux/tracehook.h +5
-1-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);
...
kernel/ptrace.c int ptrace_request(struct task_struct *child, long request, · line 1147
Quoted 4 lines
kernel/ptrace.c +4
-0+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.
Andy Lutomirski
reviewerQuoted 11 lines · Oleg Nesterov
Quoted 7 lines · Elvira Khabirova
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.
Quoted 4 lines
Yes, this was discussed many times...
So perhaps it makes sense to encode compat/is_enter in ->ptrace_message, debugger can use
PTRACE_GETEVENTMSGto 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.
Quoted 8 lines
Quoted 5 lines
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.
Quoted 25 lines
Quoted 2 lines
+#define
PT_IN_SYSCALL_STOP0x00000004/* task is in a syscall-stop */...
Quoted 20 lines
include/linux/tracehook.h +2
-1-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;include/linux/tracehook.h +3
-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);...
Quoted 10 lines
kernel/ptrace.c int ptrace_request(struct task_struct *child, long request, · line 1147
Quoted 4 lines
kernel/ptrace.c +4
-0+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_TRACESYSGOODit can know if the tracee reported syscall entry/exit or not.PTRACE_GET_SYSCALL_INFOis 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.)
Quoted 1 line
Oleg Nesterov
maintainerQuoted 11 lines · Andy Lutomirski
Quoted 11 lines · Oleg Nesterov
Quoted 7 lines · Elvira Khabirova
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.
Quoted 6 lines
Quoted 4 lines
Yes, this was discussed many times...
So perhaps it makes sense to encode compat/is_enter in ->ptrace_message, debugger can use
PTRACE_GETEVENTMSGto 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.
Quoted 9 lines
Quoted 7 lines
Quoted 4 lines
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.
Quoted 1 line
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.
Quoted 29 lines
Quoted 29 lines
Quoted 1 line
+#define
PT_IN_SYSCALL_STOP0x00000004/* task is in a syscall-stop */...
Quoted 20 lines
include/linux/tracehook.h +2
-1-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;include/linux/tracehook.h +3
-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);...
Quoted 4 lines
kernel/ptrace.c +4
-0+case PTRACE_GET_SYSCALL_INFO : +if (child->ptrace &PT_IN_SYSCALL_STOP ) + ret =ptrace_get_syscall (child, datavp); +break ;
Quoted 5 lines
Quoted 3 lines
Why? If debugger uses
PTRACE_O_TRACESYSGOODit can know if the tracee reported syscall entry/exit or not.PTRACE_GET_SYSCALL_INFOis 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.
Quoted 5 lines · On Wed, 7 Nov 2018 17:44:44 +0100 Oleg Nesterov <[email protected]> wrote:
To me
PT_IN_SYSCALL_STOPmakes 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 wantPTRACE_GET_SYSCALL_INFOto fail after that.
I really would not like to rely on ->ptrace_message remaining empty; this looks too fragile.
Oleg Nesterov
maintainerQuoted 4 lines · Elvira Khabirova
On Wed, 7 Nov 2018 17:44:44 +0100
Oleg Nesterov <[email protected]> wrote:
Quoted 8 lines
Quoted 5 lines
To me
PT_IN_SYSCALL_STOPmakes 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 wantPTRACE_GET_SYSCALL_INFOto 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.
Andy Lutomirski
reviewerQuoted 18 lines · Oleg Nesterov
Quoted 15 lines · Andy Lutomirski
Quoted 13 lines
Quoted 10 lines · Oleg Nesterov
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...
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
So perhaps it makes sense to encode compat/is_enter in ->ptrace_message, debugger can use
PTRACE_GETEVENTMSGto 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.
Oleg Nesterov
maintainerQuoted 6 lines · Andy Lutomirski
Quoted 5 lines · Oleg Nesterov
Not sure I understand you... I do not like "compat" too, but this patch uses is_compat/etc and I agree with any naming.
Quoted 8 lines
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 ILP32Is not a good design. And 32-bit builds of strace will not appreciate it.
Sure, I agree.
Quoted 2 lines
While oddly named,
audit_archfits 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.
Quoted 11 lines · Oleg Nesterov
Quoted 5 lines · Elvira Khabirova
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_GETEVENTMSGto 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.
Signature · 1 line
ldv
On Wed, Nov 07, 2018 at 04:27:51AM +0100, Elvira Khabirova wrote:
[...]
Quoted 4 lines
The structure was chosen according to [2], except for two changes.
First: instead of an arch field with a value of AUDIT_ARCH_*, a booleanis_compatvalue 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/arcarch/c6xarch/h8300arch/hexagonarch/m68karch/nds32arch/nios2arch/riscvarch/umarch/xtensa
Among these trees only m68k has its AUDIT_ARCH_M68K constant defined.
Signature · 1 line
ldv
Andy Lutomirski
maintainerQuoted 31 lines · Elvira Khabirova
PTRACE_GET_SYSCALL_INFOlets 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 int0x80, 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 commit84d77d3f06e7e8dea057d10e8ec77ad71f721be3("ptrace: Don't allow accessing an undumpable mm"), bothPTRACE_PEEKDATAandprocess_vm_readvbecome 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.
Quoted 4 lines
PTRACE_GET_SYSCALL_INFOreturns the following structure:struct ptrace_syscall_info { __u8 op; /* 0 for entry, 1 for exit */
Please consider adding another op for a seccomp stop.
Quoted 17 lines
__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;
};
};Quoted 5 lines
The structure was chosen according to [2], except for two changes.
First: instead of an arch field with a value of AUDIT_ARCH_*, a booleanis_compatvalue 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.
Quoted 2 lines
Second: a boolean
is_errorvalue 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.
cover 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
Signature · 1 line
ldv
PATCH 1/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.
--- arch/hexagon/include/asm/elf.h | 6 +----- include/uapi/linux/elf-em.h | 1 + 2 files changed, 2 insertions(+), 5 deletions(-)
arch/hexagon/include/asm/elf.h +1 -5
@@ -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 ;
include/uapi/linux/elf-em.h +1 -0
@@ -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 */
Signature · 1 line
ldv
PATCH 2/13 elf-em.h: add EM_ARC
In reply to Dmitry V. LevinThe 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
--- include/uapi/linux/elf-em.h | 1 + 1 file changed, 1 insertion(+)
include/uapi/linux/elf-em.h +1 -0
@@ -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 */
Signature · 1 line
ldv
Re: [PATCH 02/13] elf-em.h: add EM_ARC
Hi Dmitry,
Quoted 18 lines · Dmitry V. Levin
The
uapi/linux/audit.hheader is going to useEM_ARCin order to defineAUDIT_ARCH_ARCwhich is needed to implementsyscall_get_arch()which in turn is required to extend the generic ptrace API withPTRACE_GET_SYSCALL_INFOrequest.The value for
EM_ARChas been taken from
https://urldefense.proofpoint.com/v2/url?u=http-3A__www.sco.com_developers_gabi_2012-2D12-2D31_ch4.eheader.html&d=DwICAg&c=DPL6_X_6JkXFx7AXWqB0tg&r=lqdeeSSEes0GFDDl656eViXO7breS55ytWkhpk5R81I&m=Xh7PO9ZcwtbHwzwugwhu0NZypO9ObM5zMkXiQ2ja-QI&s=23pqjp37UXKSxQC0AFzqBjPquJdrh_4FjSW00FLRf4k&e=Signed-off-by Dmitry V. Levin <ldv at altlinux.org>--- include/uapi/linux/elf-em.h | 1 + 1 file changed, 1 insertion(+)b/ renamed from include/uapi/linux/elf-em.h +0
-0
b/ line 32
Quoted 7 lines
b/ renamed from include/uapi/linux/elf-em.h +1
-0@@ -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-----------------------
include/uapi/linux/elf-em.h +1 -1
@@ -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
Re: [PATCH 02/13] elf-em.h: add EM_ARC
In reply to Dmitry V. LevinQuoted 18 lines · Dmitry V. Levin
The
uapi/linux/audit.hheader is going to useEM_ARCin order to defineAUDIT_ARCH_ARCwhich is needed to implementsyscall_get_arch()which in turn is required to extend the generic ptrace API withPTRACE_GET_SYSCALL_INFOrequest.The value for
EM_ARChas been taken from
https://urldefense.proofpoint.com/v2/url?u=http-3A__www.sco.com_developers_gabi_2012-2D12-2D31_ch4.eheader.html&d=DwIBAg&c=DPL6_X_6JkXFx7AXWqB0tg&r=c14YS-cH-kdhTOW89KozFhBtBJgs1zXscZojEZQ0THs&m=UCr-dDO1BWV4K-CXhpcDRnN4Urr4_UgSKBeEaczUAmE&s=XmSWUKeqq324aU46NSTbHc12dH-1vVnA4G3Rm-01WD4&e=Signed-off-by Dmitry V. Levin <ldv at altlinux.org>--- include/uapi/linux/elf-em.h | 1 + 1 file changed, 1 insertion(+)include/uapi/linux/elf-em.h +0
-0
include/uapi/linux/elf-em.h line 29
Quoted 4 lines
include/uapi/linux/elf-em.h +1
-0@@ -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
Quoted 3 lines
include/uapi/linux/elf-em.h +0
-0#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 */
Re: [PATCH 02/13] elf-em.h: add EM_ARC
Quoted 14 lines · Vineet Gupta
Quoted 13 lines · Dmitry V. Levin
The
uapi/linux/audit.hheader is going to useEM_ARCin order to defineAUDIT_ARCH_ARCwhich is needed to implementsyscall_get_arch()which in turn is required to extend the generic ptrace API withPTRACE_GET_SYSCALL_INFOrequest.The value for
EM_ARChas been taken from
https://urldefense.proofpoint.com/v2/url?u=http-3A__www.sco.com_developers_gabi_2012-2D12-2D31_ch4.eheader.html&d=DwIBAg&c=DPL6_X_6JkXFx7AXWqB0tg&r=c14YS-cH-kdhTOW89KozFhBtBJgs1zXscZojEZQ0THs&m=UCr-dDO1BWV4K-CXhpcDRnN4Urr4_UgSKBeEaczUAmE&s=XmSWUKeqq324aU46NSTbHc12dH-1vVnA4G3Rm-01WD4&e=Signed-off-by Dmitry V. Levin <ldv at altlinux.org>--- include/uapi/linux/elf-em.h | 1 + 1 file changed, 1 insertion(+)
Quoted 12 lines
include/uapi/linux/elf-em.h line 29
Quoted 9 lines
include/uapi/linux/elf-em.h +1
-0@@ -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) andEM_ARCV2- both defined inarch/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.
Signature · 8 lines
ldv -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 801 bytes Desc: not available URL: <http://lists.infradead.org/pipermail/linux-snps-arc/attachments/20181110/eadacd51/attachment.sig>
PATCH v2 2/13 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.
---
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(-)
arch/arc/include/asm/elf.h +1 -5
@@ -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)
include/uapi/linux/elf-em.h +2 -0
@@ -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 */
Signature · 1 line
ldv
Re: [PATCH 02/13 v2] Move EM_ARCOMPACT and EM_ARCV2 to uapi/linux/elf-em.h
Quoted 46 lines · Dmitry V. Levin
These should never have been defined in the arch tree to begin with, and now
uapi/linux/audit.hheader is going to useEM_ARCOMPACTandEM_ARCV2in order to defineAUDIT_ARCH_ARCOMPACTandAUDIT_ARCH_ARCV2which are needed to implementsyscall_get_arch()which in turn is required to extend the generic ptrace API withPTRACE_GET_SYSCALL_INFOrequest.Signed-off-by Dmitry V. Levin <ldv at altlinux.org>---
v2: do not addEM_ARC, moveEM_ARCOMPACTandEM_ARCV2instead.arch/arc/include/asm/elf.h | 6 +----- include/uapi/linux/elf-em.h | 2 ++ 2 files changed, 3 insertions(+), 5 deletions(-)arch/arc/include/asm/elf.h +1
-5@@ -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)include/uapi/linux/elf-em.h +1
-0@@ -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 */
include/uapi/linux/elf-em.h line 49
Quoted 7 lines
include/uapi/linux/elf-em.h +1
-0@@ -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 !
PATCH 3/13 elf-em.h: add EM_NDS32
In reply to Dmitry V. LevinThe 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
--- include/uapi/linux/elf-em.h | 2 ++ 1 file changed, 2 insertions(+)
include/uapi/linux/elf-em.h +2 -0
@@ -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 */
Signature · 1 line
ldv
PATCH 4/13 elf-em.h: add EM_XTENSA
In reply to Dmitry V. LevinThe 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
--- include/uapi/linux/elf-em.h | 1 + 1 file changed, 1 insertion(+)
include/uapi/linux/elf-em.h +1 -0
@@ -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 */
Signature · 1 line
ldv
Re: [PATCH 04/13] elf-em.h: add EM_XTENSA
Quoted 5 lines · Dmitry V. Levin
The
uapi/linux/audit.hheader is going to useEM_XTENSAin order to defineAUDIT_ARCH_XTENSAwhich is needed to implementsyscall_get_arch()which in turn is required to extend the generic ptrace API withPTRACE_GET_SYSCALL_INFOrequest.
Quoted 7 lines
The value for
EM_XTENSAhas been taken from
http://www.sco.com/developers/gabi/2012-12-31/ch4.eheader.htmlSigned-off-by Dmitry V. Levin <[email protected]>--- include/uapi/linux/elf-em.h | 1 + 1 file changed, 1 insertion(+)
Signature · 2 lines
Thanks. -- Max
PATCH 5/13 m68k: define syscall_get_arch()
In reply to Dmitry V. Levinsyscall_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.
--- arch/m68k/include/asm/syscall.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 arch/m68k/include/asm/syscall.h
arch/m68k/include/asm/syscall.h new file +12 -0
@@ -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 */
Signature · 1 line
ldv
PATCH 6/13 arc: define syscall_get_arch()
In reply to Dmitry V. Levinsyscall_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.
--- arch/arc/include/asm/syscall.h | 6 ++++++ include/uapi/linux/audit.h | 1 + 2 files changed, 7 insertions(+)
arch/arc/include/asm/syscall.h +6 -0
@@ -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
include/uapi/linux/audit.h +1 -0
@@ -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)
Signature · 1 line
ldv
Re: [PATCH 06/13] arc: define syscall_get_arch()
Hi Dmitry,
Quoted 9 lines · Dmitry V. Levin
syscall_get_arch()is required to be implemented on all architectures that usetracehook_report_syscall_entry()in order to extend the generic ptrace API withPTRACE_GET_SYSCALL_INFOrequest.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]
include/uapi/linux/audit.h enum { · line 378
Quoted 9 lines
include/uapi/linux/audit.h +1
-0@@ -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
Andy Lutomirski
maintainerRe: [PATCH 06/13] arc: define syscall_get_arch()
Quoted 22 lines · Alexey Brodkin
Hi Dmitry,
Quoted 9 lines · Dmitry V. Levin
syscall_get_arch()is required to be implemented on all architectures that usetracehook_report_syscall_entry()in order to extend the generic ptrace API withPTRACE_GET_SYSCALL_INFOrequest.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]
Quoted 6 lines
include/uapi/linux/audit.h +0
-0@@ -375,6 +375,7 @@ enum {
Quoted 9 lines
include/uapi/linux/audit.h enum { · line 378
Quoted 3 lines
include/uapi/linux/audit.h +1
-0#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-----------------------------
+#defineAUDIT_ARCH_ARC(EM_ARC|EM_ARCV2)
---------------------------->8-----------------------------
Huh? How does the bitwise or of two ELF machine codes make any sense?
Re: [PATCH 06/13] arc: define syscall_get_arch()
Hi Andy,
Quoted 33 lines · Andy Lutomirski
Quoted 21 lines · Alexey Brodkin
Hi Dmitry,
Quoted 9 lines · Dmitry V. Levin
syscall_get_arch()is required to be implemented on all architectures that usetracehook_report_syscall_entry()in order to extend the generic ptrace API withPTRACE_GET_SYSCALL_INFOrequest.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]
Quoted 6 lines
include/uapi/linux/audit.h +0
-0@@ -375,6 +375,7 @@ enum {Quoted 9 lines
include/uapi/linux/audit.h enum { · line 378
Quoted 3 lines
include/uapi/linux/audit.h +1
-0#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-----------------------------
+#defineAUDIT_ARCH_ARC(EM_ARC|EM_ARCV2)
---------------------------->8-----------------------------
Quoted 1 line
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
Andy Lutomirski
reviewerRe: [PATCH 06/13] arc: define syscall_get_arch()
Quoted 55 lines · Alexey Brodkin
Hi Andy,
Quoted 34 lines · Andy Lutomirski
Quoted 21 lines · Alexey Brodkin
Hi Dmitry,
Quoted 10 lines · Dmitry V. Levin
syscall_get_arch()is required to be implemented on all architectures that usetracehook_report_syscall_entry()in order to extend the generic ptrace API withPTRACE_GET_SYSCALL_INFOrequest.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]
Quoted 6 lines
include/uapi/linux/audit.h +0
-0@@ -375,6 +375,7 @@ enum {Quoted 9 lines
include/uapi/linux/audit.h enum { · line 378
Quoted 3 lines
include/uapi/linux/audit.h +1
-0#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-----------------------------
+#defineAUDIT_ARCH_ARC(EM_ARC|EM_ARCV2)
---------------------------->8-----------------------------Quoted 1 line
Huh? How does the bitwise or of two ELF machine codes make any sense?
Oops... I didn't read examples of
AUDIT_ARCH_ALPHAabove :( Indeed that was stupid.But what would be a proper fix then?
Something like that? ---------------------------->8-----------------------------
#defineAUDIT_ARCH_ARC(EM_ARC)
#defineAUDIT_ARCH_ARCV2(EM_ARCV2)static inline int
syscall_get_arch(void)
{
Quoted 8 lines
#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?
Re: [PATCH 06/13] arc: define syscall_get_arch()
Hi Andy,
Quoted 62 lines · Andy Lutomirski
Quoted 53 lines · Alexey Brodkin
Hi Andy,
Quoted 34 lines · Andy Lutomirski
Quoted 21 lines · Alexey Brodkin
Hi Dmitry,
Quoted 10 lines · Dmitry V. Levin
syscall_get_arch()is required to be implemented on all architectures that usetracehook_report_syscall_entry()in order to extend the generic ptrace API withPTRACE_GET_SYSCALL_INFOrequest.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]
Quoted 6 lines
include/uapi/linux/audit.h +0
-0@@ -375,6 +375,7 @@ enum {Quoted 9 lines
include/uapi/linux/audit.h enum { · line 378
Quoted 3 lines
include/uapi/linux/audit.h +1
-0#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-----------------------------
+#defineAUDIT_ARCH_ARC(EM_ARC|EM_ARCV2)
---------------------------->8-----------------------------Quoted 1 line
Huh? How does the bitwise or of two ELF machine codes make any sense?
Oops... I didn't read examples of
AUDIT_ARCH_ALPHAabove :( Indeed that was stupid.But what would be a proper fix then?
Something like that? ---------------------------->8-----------------------------
#defineAUDIT_ARCH_ARC(EM_ARC)
#defineAUDIT_ARCH_ARCV2(EM_ARCV2)static inline int
syscall_get_arch(void)
{Quoted 8 lines
#ifdef __ARC700__ return AUDIT_ARCH_ARC; #else return AUDIT_ARCH_ARCV2;#endif
} ---------------------------->8-----------------------------
Quoted 1 line
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
Andy Lutomirski
reviewerRe: [PATCH 06/13] arc: define syscall_get_arch()
Quoted 71 lines · Alexey Brodkin
Hi Andy,
Quoted 62 lines · Andy Lutomirski
Quoted 53 lines · Alexey Brodkin
Hi Andy,
Quoted 34 lines · Andy Lutomirski
Quoted 21 lines · Alexey Brodkin
Hi Dmitry,
Quoted 10 lines · Dmitry V. Levin
syscall_get_arch()is required to be implemented on all architectures that usetracehook_report_syscall_entry()in order to extend the generic ptrace API withPTRACE_GET_SYSCALL_INFOrequest.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]
Quoted 6 lines
include/uapi/linux/audit.h +0
-0@@ -375,6 +375,7 @@ enum {Quoted 9 lines
include/uapi/linux/audit.h enum { · line 378
Quoted 3 lines
include/uapi/linux/audit.h +1
-0#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-----------------------------
+#defineAUDIT_ARCH_ARC(EM_ARC|EM_ARCV2)
---------------------------->8-----------------------------Quoted 1 line
Huh? How does the bitwise or of two ELF machine codes make any sense?
Oops... I didn't read examples of
AUDIT_ARCH_ALPHAabove :( Indeed that was stupid.But what would be a proper fix then?
Something like that? ---------------------------->8-----------------------------
#defineAUDIT_ARCH_ARC(EM_ARC)
#defineAUDIT_ARCH_ARCV2(EM_ARCV2)static inline int
syscall_get_arch(void)
{Quoted 8 lines
#ifdef __ARC700__ return AUDIT_ARCH_ARC; #else return AUDIT_ARCH_ARCV2;#endif
} ---------------------------->8-----------------------------Quoted 1 line
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.
Quoted 7 lines
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.
Quoted 6 lines
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
Signature · 2 lines
Andy Lutomirski AMA Capital Management, LLC
PATCH v2 6/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.
---
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(+)
arch/arc/include/asm/syscall.h +18 -0
@@ -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
include/uapi/linux/audit.h +4 -0
@@ -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)
Signature · 1 line
ldv
Re: [PATCH 06/13 v2] arc: define syscall_get_arch()
Quoted 36 lines · Dmitry V. Levin
syscall_get_arch()is required to be implemented on all architectures that usetracehook_report_syscall_entry()in order to extend the generic ptrace API withPTRACE_GET_SYSCALL_INFOrequest.Signed-off-by Dmitry V. Levin <[email protected]>---
v2: defineAUDIT_ARCH_ARCOMPACT,AUDIT_ARCH_ARCOMPACTLE,AUDIT_ARCH_ARCV2, andAUDIT_ARCH_ARCV2LEinstead ofAUDIT_ARCH_ARC, updatesyscall_get_arch()implementation accordingly.arch/arc/include/asm/syscall.h | 18 ++++++++++++++++++ include/uapi/linux/audit.h | 4 ++++ 2 files changed, 22 insertions(+)arch/arc/include/asm/syscall.h +7
-0@@ -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
arch/arc/include/asm/syscall.h syscall_get_arguments(struct task_struct *task, struct pt_regs *regs, · line 87
Quoted 10 lines
arch/arc/include/asm/syscall.h +10
-0+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.
Quoted 7 lines
arch/arc/include/asm/syscall.h +1
-0+#endif include/uapi/linux/audit.h +0
-0
include/uapi/linux/audit.h enum { · line 381
Quoted 7 lines
include/uapi/linux/audit.h +4
-0@@ -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.
PATCH v3 6/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.
---
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(+)
arch/arc/include/asm/syscall.h +10 -0
@@ -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
include/uapi/linux/audit.h +4 -0
@@ -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)
Signature · 1 line
ldv
Re: [PATCH 06/13 v3] arc: define syscall_get_arch()
Quoted 5 lines · Dmitry V. Levin
syscall_get_arch()is required to be implemented on all architectures that usetracehook_report_syscall_entry()in order to extend the generic ptrace API withPTRACE_GET_SYSCALL_INFOrequest.Signed-off-by Dmitry V. Levin <[email protected]>
Re: [PATCH 06/13] arc: define syscall_get_arch()
In reply to Dmitry V. LevinQuoted 23 lines · Dmitry V. Levin
syscall_get_arch()is required to be implemented on all architectures that usetracehook_report_syscall_entry()in order to extend the generic ptrace API withPTRACE_GET_SYSCALL_INFOrequest.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(+)arch/arc/include/asm/syscall.h +1
-0@@ -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>
arch/arc/include/asm/syscall.h syscall_get_arguments(struct task_struct *task, struct pt_regs *regs, · line 76
Quoted 8 lines
arch/arc/include/asm/syscall.h +5
-0@@ -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.
include/uapi/linux/audit.h enum { · line 381
Quoted 13 lines
arch/arc/include/asm/syscall.h +0
-0#endif include/uapi/linux/audit.h +1
-0@@ -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 ?
Andy Lutomirski
reviewerRe: [PATCH 06/13] arc: define syscall_get_arch()
Quoted 31 lines · Vineet Gupta
Quoted 28 lines · Dmitry V. Levin
syscall_get_arch()is required to be implemented on all architectures that usetracehook_report_syscall_entry()in order to extend the generic ptrace API withPTRACE_GET_SYSCALL_INFOrequest.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(+)arch/arc/include/asm/syscall.h +1
-0@@ -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, } }
Quoted 10 lines
arch/arc/include/asm/syscall.h syscall_get_arguments(struct task_struct *task, struct pt_regs *regs, · line 76
Quoted 5 lines
arch/arc/include/asm/syscall.h +5
-0+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_ARCHand common code could return it. Also theEM_xxxare not there ininclude/uapi/linux/elf.hto begin with since libcelf.halready 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.
Quoted 7 lines
Quoted 7 lines
arch/arc/include/asm/syscall.h +0
-0#endif include/uapi/linux/audit.h +0
-0@@ -375,6 +375,7 @@ enum {
Quoted 10 lines
include/uapi/linux/audit.h enum { · line 381
Quoted 6 lines
include/uapi/linux/audit.h +1
-0#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.
Re: [PATCH 06/13] arc: define syscall_get_arch()
Quoted 7 lines · Andy Lutomirski
Quoted 5 lines
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_ARCHand common code could return it. Also theEM_xxxare not there ininclude/uapi/linux/elf.hto begin with since libcelf.halready defines them.A lot of architectures allow multiple
audit_archesat 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.
PATCH 7/13 c6x: define syscall_get_arch()
In reply to Dmitry V. Levinsyscall_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.
--- arch/c6x/include/asm/syscall.h | 6 ++++++ include/uapi/linux/audit.h | 1 + 2 files changed, 7 insertions(+)
arch/c6x/include/asm/syscall.h +6 -0
@@ -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 */
include/uapi/linux/audit.h +1 -0
@@ -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)
Signature · 1 line
ldv
PATCH v2 7/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.
---
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(+)
arch/c6x/include/asm/syscall.h +7 -0
@@ -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 */
include/uapi/linux/audit.h +2 -0
@@ -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)
Signature · 1 line
ldv
PATCH 8/13 h8300: define syscall_get_arch()
In reply to Dmitry V. Levinsyscall_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.
--- arch/h8300/include/asm/syscall.h | 5 +++++ include/uapi/linux/audit.h | 1 + 2 files changed, 6 insertions(+)
arch/h8300/include/asm/syscall.h +5 -0
@@ -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 */
include/uapi/linux/audit.h +1 -0
@@ -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)
Signature · 1 line
ldv
PATCH 9/13 hexagon: define syscall_get_arch()
In reply to Dmitry V. Levinsyscall_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.
--- arch/hexagon/include/asm/syscall.h | 8 ++++++++ include/uapi/linux/audit.h | 1 + 2 files changed, 9 insertions(+)
arch/hexagon/include/asm/syscall.h +8 -0
@@ -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, &(®s->r00)[i], n * sizeof(args[0])); } + +static inline int syscall_get_arch (void ) +{ +return AUDIT_ARCH_HEXAGON ; +} +#endif
include/uapi/linux/audit.h +1 -0
@@ -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)
Signature · 1 line
ldv
PATCH 10/13 nds32: define syscall_get_arch()
In reply to Dmitry V. Levinsyscall_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.
--- arch/nds32/include/asm/syscall.h | 7 +++++++ include/uapi/linux/audit.h | 1 + 2 files changed, 8 insertions(+)
arch/nds32/include/asm/syscall.h +7 -0
@@ -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(®s->uregs[0] + i, args, n * sizeof(args[0])); } + +static inline int syscall_get_arch (void ) +{ +return AUDIT_ARCH_NDS32 ; +} +#endif /* _ASM_NDS32_SYSCALL_H */
include/uapi/linux/audit.h +1 -0
@@ -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)
Signature · 1 line
ldv
PATCH v2 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.
---
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(+)
arch/nds32/include/asm/syscall.h +8 -0
@@ -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(®s->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 */
include/uapi/linux/audit.h +2 -0
@@ -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)
Signature · 1 line
ldv
PATCH 11/13 nios2: define syscall_get_arch()
In reply to Dmitry V. Levinsyscall_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.
--- arch/nios2/include/asm/syscall.h | 6 ++++++ include/uapi/linux/audit.h | 1 + 2 files changed, 7 insertions(+)
arch/nios2/include/asm/syscall.h +6 -0
@@ -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
include/uapi/linux/audit.h +1 -0
@@ -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)
Signature · 1 line
ldv
PATCH 12/13 riscv: define syscall_get_arch()
In reply to Dmitry V. Levinsyscall_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.
--- arch/riscv/include/asm/syscall.h | 6 ++++++ include/uapi/linux/audit.h | 1 + 2 files changed, 7 insertions(+)
arch/riscv/include/asm/syscall.h +6 -0
@@ -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(®s->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 */
include/uapi/linux/audit.h +1 -0
@@ -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)
Signature · 1 line
ldv
Re: [PATCH 12/13] riscv: define syscall_get_arch()
Quoted 5 lines · Dmitry V. Levin
syscall_get_arch()is required to be implemented on all architectures that usetracehook_report_syscall_entry()in order to extend the generic ptrace API withPTRACE_GET_SYSCALL_INFOrequest.
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
Re: [PATCH 12/13] riscv: define syscall_get_arch()
Quoted 10 lines · David Abdurachmanov
Quoted 4 lines · Dmitry V. Levin
syscall_get_arch()is required to be implemented on all architectures that usetracehook_report_syscall_entry()in order to extend the generic ptrace API withPTRACE_GET_SYSCALL_INFOrequest.I have posted audit support patch for RISC-V in October. Pending review. It defines both
AUDIT_ARCH_RISCV32andAUDIT_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.
Signature · 1 line
ldv
Re: [PATCH 12/13] riscv: define syscall_get_arch()
Quoted 3 lines · Dmitry V. Levin
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 :/
Re: [PATCH 12/13] riscv: define syscall_get_arch()
In reply to Dmitry V. LevinQuoted 1 line · Dmitry V. Levin
P.S. It would be great if you replied to me as well.
You are explicitly forbidding that.
Andreas.
Signature · 3 lines
Andreas Schwab, [email protected] GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1 "And now for something completely different."
Re: [PATCH 12/13] riscv: define syscall_get_arch()
In reply to Dmitry V. LevinQuoted 37 lines · 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 usetracehook_report_syscall_entry()in order to extend the generic ptrace API withPTRACE_GET_SYSCALL_INFOrequest.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(+)arch/riscv/include/asm/syscall.h +6
-0@@ -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(®s->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 */ include/uapi/linux/audit.h +0
-0
include/uapi/linux/audit.h enum { · line 411
Quoted 7 lines
include/uapi/linux/audit.h +1
-0@@ -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.
Re: [PATCH 12/13] riscv: define syscall_get_arch()
Quoted 44 lines · Palmer Dabbelt
Quoted 43 lines · 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 usetracehook_report_syscall_entry()in order to extend the generic ptrace API withPTRACE_GET_SYSCALL_INFOrequest.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(+)arch/riscv/include/asm/syscall.h +6
-0@@ -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(®s->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 */ include/uapi/linux/audit.h +1
-0@@ -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)
Quoted 8 lines
include/uapi/linux/audit.h enum { · line 411
Quoted 1 line
include/uapi/linux/audit.h +0
-0#define AUDIT_ARCH_SH (EM_SH)I think this is incorrect:
EM_RISCVhas 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?
Signature · 1 line
ldv
PATCH v2 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.
--- arch/riscv/include/asm/syscall.h | 10 ++++++++++ include/uapi/linux/audit.h | 2 ++ 2 files changed, 12 insertions(+)
arch/riscv/include/asm/syscall.h +10 -0
@@ -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(®s->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 */
include/uapi/linux/audit.h +2 -0
@@ -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)
Signature · 1 line
ldv
Re: [PATCH 12/13 v2] riscv: define syscall_get_arch()
Quoted 42 lines · 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 usetracehook_report_syscall_entry()in order to extend the generic ptrace API withPTRACE_GET_SYSCALL_INFOrequest.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(+)arch/riscv/include/asm/syscall.h +10
-0@@ -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(®s->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 */ include/uapi/linux/audit.h +0
-0
include/uapi/linux/audit.h enum { · line 412
Quoted 8 lines
include/uapi/linux/audit.h +2
-0@@ -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)
Thanks!
PATCH 13/13 xtensa: define syscall_get_arch()
In reply to Dmitry V. Levinsyscall_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.
--- arch/xtensa/include/asm/syscall.h | 7 +++++++ include/uapi/linux/audit.h | 1 + 2 files changed, 8 insertions(+)
arch/xtensa/include/asm/syscall.h +7 -0
@@ -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 *);
include/uapi/linux/audit.h +1 -0
@@ -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
Signature · 1 line
ldv
Re: [PATCH 13/13] xtensa: define syscall_get_arch()
Quoted 9 lines · Dmitry V. Levin
syscall_get_arch()is required to be implemented on all architectures that usetracehook_report_syscall_entry()in order to extend the generic ptrace API withPTRACE_GET_SYSCALL_INFOrequest.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(+)
Signature · 2 lines
Thanks. -- Max
Andy Lutomirski
maintainerRe: [PATCH 00/13] Prepare for PTRACE_GET_SYSCALL_INFO
In reply to Dmitry V. LevinQuoted 4 lines · Dmitry V. Levin
syscall_get_arch()is required to be implemented on all architectures that usetracehook_report_syscall_entry()in order to extend the generic ptrace API withPTRACE_GET_SYSCALL_INFOrequest.
Nice!
I'm pretty sure you have vastly more changelog than code here :)
--Andy
[PATCH 14/13] Move EM_UNICORE to uapi/linux/elf-em.h
In reply to Dmitry V. LevinThis 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.
---
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(-)
arch/unicore32/include/asm/elf.h +1 -2
@@ -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
include/uapi/linux/elf-em.h +1 -0
@@ -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 */
Signature · 1 line
ldv
[PATCH 15/13] unicore32: define syscall_get_arch()
In reply to Dmitry V. Levinsyscall_get_arch() is required to be implemented on all architectures in order to extend the generic ptrace API with PTRACE_GET_SYSCALL_INFO request.
---
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
arch/unicore32/include/asm/syscall.h new file +12 -0
@@ -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 */
include/uapi/linux/audit.h +1 -0
@@ -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)
Signature · 1 line
ldv
Quoted 31 lines · Andy Lutomirski
Quoted 31 lines · Elvira Khabirova
PTRACE_GET_SYSCALL_INFOlets 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 int0x80, 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 commit84d77d3f06e7e8dea057d10e8ec77ad71f721be3("ptrace: Don't allow accessing an undumpable mm"), bothPTRACE_PEEKDATAandprocess_vm_readvbecome 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.
Quoted 6 lines
Quoted 4 lines
PTRACE_GET_SYSCALL_INFOreturns 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?
Signature · 1 line
ldv
v2 cover Prepare for PTRACE_GET_SYSCALL_INFO
In reply to Andy Lutomirskisyscall_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
Signature · 1 line
ldv
PATCH v2 1/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.
---
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(-)
arch/hexagon/include/asm/elf.h +1 -5
@@ -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 ;
include/uapi/linux/elf-em.h +1 -0
@@ -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 */
Signature · 1 line
ldv
PATCH v2 2/15 Move EM_ARCOMPACT and EM_ARCV2 to uapi/linux/elf-em.h
In reply to Dmitry V. LevinThese 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.
---
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(-)
arch/arc/include/asm/elf.h +1 -5
@@ -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)
include/uapi/linux/elf-em.h +2 -0
@@ -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 */
Signature · 1 line
ldv
PATCH v2 3/15 Move EM_UNICORE to uapi/linux/elf-em.h
In reply to Dmitry V. LevinThis 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.
---
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(-)
arch/unicore32/include/asm/elf.h +1 -2
@@ -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
include/uapi/linux/elf-em.h +1 -0
@@ -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 */
Signature · 1 line
ldv
PATCH v2 4/15 elf-em.h: add EM_NDS32
In reply to Dmitry V. LevinThe 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
---
v2: unchanged since v1
include/uapi/linux/elf-em.h | 2 ++ 1 file changed, 2 insertions(+)
include/uapi/linux/elf-em.h +2 -0
@@ -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 */
Signature · 1 line
ldv
PATCH v2 5/15 elf-em.h: add EM_XTENSA
In reply to Dmitry V. LevinThe 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
---
v2: added Reviewed-by to v1
include/uapi/linux/elf-em.h | 1 + 1 file changed, 1 insertion(+)
include/uapi/linux/elf-em.h +1 -0
@@ -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 */
Signature · 1 line
ldv
PATCH v2 6/15 m68k: define syscall_get_arch()
In reply to Dmitry V. Levinsyscall_get_arch() is required to be implemented on all architectures in order to extend the generic ptrace API with PTRACE_GET_SYSCALL_INFO request.
---
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
arch/m68k/include/asm/syscall.h new file +12 -0
@@ -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 */
Signature · 1 line
ldv
Re: [PATCH v2 06/15] m68k: define syscall_get_arch()
Hi Dmitry,
Quoted 5 lines · Dmitry V. Levin
syscall_get_arch()is required to be implemented on all architectures in order to extend the generic ptrace API withPTRACE_GET_SYSCALL_INFOrequest.Signed-off-by Dmitry V. Levin <[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
Signature · 5 lines
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
Re: [PATCH v2 06/15] m68k: define syscall_get_arch()
Hi Geert,
Quoted 7 lines · Geert Uytterhoeven
Hi Dmitry,
Quoted 4 lines · Dmitry V. Levin
syscall_get_arch()is required to be implemented on all architectures in order to extend the generic ptrace API withPTRACE_GET_SYSCALL_INFOrequest.
Quoted 7 lines
Quoted 1 line
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.
Signature · 1 line
ldv
Re: [PATCH v2 06/15] m68k: define syscall_get_arch()
Hi Dmitry,
Quoted 10 lines · Dmitry V. Levin
Quoted 9 lines · Geert Uytterhoeven
Quoted 5 lines · Dmitry V. Levin
syscall_get_arch()is required to be implemented on all architectures in order to extend the generic ptrace API withPTRACE_GET_SYSCALL_INFOrequest.Signed-off-by Dmitry V. Levin <[email protected]>Reviewed-by Geert Uytterhoeven <[email protected]>
Quoted 7 lines
Quoted 3 lines
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 withPTRACE_GET_SYSCALL_INFOseries.
Cool, thanks!
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
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
PATCH v2 7/15 arc: define syscall_get_arch()
In reply to Dmitry V. Levinsyscall_get_arch() is required to be implemented on all architectures in order to extend the generic ptrace API with PTRACE_GET_SYSCALL_INFO request.
---
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(+)
arch/arc/include/asm/syscall.h +10 -0
@@ -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
include/uapi/linux/audit.h +4 -0
@@ -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)
Signature · 1 line
ldv
PATCH v2 8/15 c6x: define syscall_get_arch()
In reply to Dmitry V. Levinsyscall_get_arch() is required to be implemented on all architectures in order to extend the generic ptrace API with PTRACE_GET_SYSCALL_INFO request.
---
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(+)
arch/c6x/include/asm/syscall.h +7 -0
@@ -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 */
include/uapi/linux/audit.h +2 -0
@@ -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)
Signature · 1 line
ldv
PATCH v2 9/15 h8300: define syscall_get_arch()
In reply to Dmitry V. Levinsyscall_get_arch() is required to be implemented on all architectures in order to extend the generic ptrace API with PTRACE_GET_SYSCALL_INFO request.
---
v2: unchanged since v1
arch/h8300/include/asm/syscall.h | 5 +++++ include/uapi/linux/audit.h | 1 + 2 files changed, 6 insertions(+)
arch/h8300/include/asm/syscall.h +5 -0
@@ -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 */
include/uapi/linux/audit.h +1 -0
@@ -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)
Signature · 1 line
ldv
PATCH v2 10/15 hexagon: define syscall_get_arch()
In reply to Dmitry V. Levinsyscall_get_arch() is required to be implemented on all architectures in order to extend the generic ptrace API with PTRACE_GET_SYSCALL_INFO request.
---
v2: unchanged since v1
arch/hexagon/include/asm/syscall.h | 8 ++++++++ include/uapi/linux/audit.h | 1 + 2 files changed, 9 insertions(+)
arch/hexagon/include/asm/syscall.h +8 -0
@@ -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, &(®s->r00)[i], n * sizeof(args[0])); } + +static inline int syscall_get_arch (void ) +{ +return AUDIT_ARCH_HEXAGON ; +} +#endif
include/uapi/linux/audit.h +1 -0
@@ -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)
Signature · 1 line
ldv
PATCH v2 11/15 nds32: define syscall_get_arch()
In reply to Dmitry V. Levinsyscall_get_arch() is required to be implemented on all architectures in order to extend the generic ptrace API with PTRACE_GET_SYSCALL_INFO request.
---
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(+)
arch/nds32/include/asm/syscall.h +8 -0
@@ -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(®s->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 */
include/uapi/linux/audit.h +2 -0
@@ -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)
Signature · 1 line
ldv
PATCH v2 12/15 nios2: define syscall_get_arch()
In reply to Dmitry V. Levinsyscall_get_arch() is required to be implemented on all architectures in order to extend the generic ptrace API with PTRACE_GET_SYSCALL_INFO request.
---
v2: unchanged since v1
arch/nios2/include/asm/syscall.h | 6 ++++++ include/uapi/linux/audit.h | 1 + 2 files changed, 7 insertions(+)
arch/nios2/include/asm/syscall.h +6 -0
@@ -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
include/uapi/linux/audit.h +1 -0
@@ -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)
Signature · 1 line
ldv
PATCH v2 13/15 riscv: define syscall_get_arch()
In reply to Dmitry V. Levinsyscall_get_arch() is required to be implemented on all architectures in order to extend the generic ptrace API with PTRACE_GET_SYSCALL_INFO request.
---
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(+)
arch/riscv/include/asm/syscall.h +10 -0
@@ -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(®s->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 */
include/uapi/linux/audit.h +2 -0
@@ -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)
Signature · 1 line
ldv
PATCH v2 14/15 unicore32: define syscall_get_arch()
In reply to Dmitry V. Levinsyscall_get_arch() is required to be implemented on all architectures in order to extend the generic ptrace API with PTRACE_GET_SYSCALL_INFO request.
---
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
arch/unicore32/include/asm/syscall.h new file +12 -0
@@ -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 */
include/uapi/linux/audit.h +1 -0
@@ -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
Signature · 1 line
ldv
PATCH v2 15/15 xtensa: define syscall_get_arch()
In reply to Dmitry V. Levinsyscall_get_arch() is required to be implemented on all architectures in order to extend the generic ptrace API with PTRACE_GET_SYSCALL_INFO request.
---
v2: added Acked-by to v1
arch/xtensa/include/asm/syscall.h | 7 +++++++ include/uapi/linux/audit.h | 1 + 2 files changed, 8 insertions(+)
arch/xtensa/include/asm/syscall.h +7 -0
@@ -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 *);
include/uapi/linux/audit.h +1 -0
@@ -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
Signature · 1 line
ldv
Paul Moore
maintainerRe: [PATCH v2 00/15] Prepare for PTRACE_GET_SYSCALL_INFO
In reply to Dmitry V. LevinQuoted 7 lines · Dmitry V. Levin
syscall_get_arch()is required to be implemented on all architectures in order to extend the generic ptrace API withPTRACE_GET_SYSCALL_INFOrequest.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!
Quoted 35 lines
Dmitry V. Levin (15):
MoveEM_HEXAGONtouapi/linux/elf-em.h
MoveEM_ARCOMPACTandEM_ARCV2touapi/linux/elf-em.hMoveEM_UNICOREtouapi/linux/elf-em.helf-em.h: addEM_NDS32
elf-em.h: addEM_XTENSA
m68k: definesyscall_get_arch()
arc: definesyscall_get_arch()
c6x: definesyscall_get_arch()
h8300: definesyscall_get_arch()
hexagon: definesyscall_get_arch()
nds32: definesyscall_get_arch()
nios2: definesyscall_get_arch()
riscv: definesyscall_get_arch()
unicore32: definesyscall_get_arch()
xtensa: definesyscall_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
Signature · 2 lines
paul moore www.paul-moore.com
[PATCH v2 16/15] syscall_get_arch: add "struct task_struct *" argument
In reply to Dmitry V. LevinThis argument is required to extend the generic ptrace API with PTRACE_GET_SYSCALL_INFO request: syscall_get_arch() is going to be called from ptrace_request() along with other syscall_get_* functions with a tracee as their argument.
This change partially reverts commit 5e937a9ae913 ("syscall_get_arch:
remove useless function arguments").
--- arch/alpha/include/asm/syscall.h | 2 +- arch/arc/include/asm/syscall.h | 2 +- arch/arm/include/asm/syscall.h | 2 +- arch/arm64/include/asm/syscall.h | 4 ++-- arch/c6x/include/asm/syscall.h | 2 +- arch/h8300/include/asm/syscall.h | 2 +- arch/hexagon/include/asm/syscall.h | 2 +- arch/ia64/include/asm/syscall.h | 2 +- arch/m68k/include/asm/syscall.h | 2 +- arch/microblaze/include/asm/syscall.h | 2 +- arch/mips/include/asm/syscall.h | 8 ++++---- arch/mips/kernel/ptrace.c | 2 +- arch/nds32/include/asm/syscall.h | 2 +- arch/nios2/include/asm/syscall.h | 2 +- arch/openrisc/include/asm/syscall.h | 2 +- arch/parisc/include/asm/syscall.h | 4 ++-- arch/powerpc/include/asm/syscall.h | 10 ++++++++-- arch/riscv/include/asm/syscall.h | 2 +- arch/s390/include/asm/syscall.h | 4 ++-- arch/sh/include/asm/syscall_32.h | 2 +- arch/sh/include/asm/syscall_64.h | 2 +- arch/sparc/include/asm/syscall.h | 5 +++-- arch/unicore32/include/asm/syscall.h | 2 +- arch/x86/include/asm/syscall.h | 8 +++++--- arch/x86/um/asm/syscall.h | 2 +- arch/xtensa/include/asm/syscall.h | 2 +- include/asm-generic/syscall.h | 3 ++- kernel/auditsc.c | 4 ++-- kernel/seccomp.c | 4 ++-- 29 files changed, 51 insertions(+), 41 deletions(-)
arch/alpha/include/asm/syscall.h +1 -1
@@ -4,7 +4,7 @@#include <uapi/linux/audit.h> -static inline int syscall_get_arch (void ) +static inline int syscall_get_arch (struct task_struct *task) {return AUDIT_ARCH_ALPHA ; }
arch/arc/include/asm/syscall.h +1 -1
@@ -69,7 +69,7 @@ syscall_get_arguments(struct task_struct *task, struct pt_regs *regs, } } -static inline int syscall_get_arch (void ) +static inline int syscall_get_arch (struct task_struct *task) {return IS_ENABLED (CONFIG_ISA_ARCOMPACT ) ? (IS_ENABLED(CONFIG_CPU_BIG_ENDIAN)
arch/arm/include/asm/syscall.h +1 -1
@@ -104,7 +104,7 @@ static inline void syscall_set_arguments(struct task_struct *task,memcpy (®s->ARM_r0 + i, args, n *sizeof (args[0 ])); } -static inline int syscall_get_arch (void ) +static inline int syscall_get_arch (struct task_struct *task) {/* ARM tasks don't change audit architectures on the fly. */ return AUDIT_ARCH_ARM ;
arch/arm64/include/asm/syscall.h +2 -2
@@ -117,9 +117,9 @@ static inline void syscall_set_arguments(struct task_struct *task,* We don't care about endianness (__AUDIT_ARCH_LE bit) here because * AArch64 has the same system calls both on little- and big- endian. */ -static inline int syscall_get_arch (void ) +static inline int syscall_get_arch (struct task_struct *task) { -if (is_compat_task ()) +if (is_compat_thread (task_thread_info (task)))return AUDIT_ARCH_ARM ;return AUDIT_ARCH_AARCH64 ;
arch/c6x/include/asm/syscall.h +1 -1
@@ -121,7 +121,7 @@ static inline void syscall_set_arguments(struct task_struct *task, } } -static inline int syscall_get_arch (void ) +static inline int syscall_get_arch (struct task_struct *task) {return IS_ENABLED (CONFIG_CPU_BIG_ENDIAN ) ?AUDIT_ARCH_C6XBE :AUDIT_ARCH_C6X ;
arch/h8300/include/asm/syscall.h +1 -1
@@ -48,7 +48,7 @@ syscall_get_arguments(struct task_struct *task, struct pt_regs *regs, } } -static inline int syscall_get_arch (void ) +static inline int syscall_get_arch (struct task_struct *task) {return AUDIT_ARCH_H8300 ; }
arch/hexagon/include/asm/syscall.h +1 -1
@@ -46,7 +46,7 @@ static inline void syscall_get_arguments(struct task_struct *task,memcpy (args, &(®s->r00)[i], n *sizeof (args[0 ])); } -static inline int syscall_get_arch (void ) +static inline int syscall_get_arch (struct task_struct *task) {return AUDIT_ARCH_HEXAGON ; }
arch/ia64/include/asm/syscall.h +1 -1
@@ -81,7 +81,7 @@ static inline void syscall_set_arguments(struct task_struct *task,ia64_syscall_get_set_arguments (task, regs, i, n, args,1 ); } -static inline int syscall_get_arch (void ) +static inline int syscall_get_arch (struct task_struct *task) {return AUDIT_ARCH_IA64 ; }
arch/m68k/include/asm/syscall.h +1 -1
@@ -4,7 +4,7 @@#include <uapi/linux/audit.h> -static inline int syscall_get_arch (void ) +static inline int syscall_get_arch (struct task_struct *task) {return AUDIT_ARCH_M68K ; }
arch/microblaze/include/asm/syscall.h +1 -1
@@ -101,7 +101,7 @@ static inline void syscall_set_arguments(struct task_struct *task,asmlinkage unsigned long do_syscall_trace_enter (struct pt_regs *regs); asmlinkage void do_syscall_trace_leave(struct pt_regs *regs); -static inline int syscall_get_arch (void ) +static inline int syscall_get_arch (struct task_struct *task) {return AUDIT_ARCH_MICROBLAZE ; }
arch/mips/include/asm/syscall.h +4 -4
@@ -73,7 +73,7 @@ static inline unsigned long mips_get_syscall_arg(unsigned long *arg,#ifdef CONFIG_64BIT case 4 :case 5 :case 6 :case 7 :#ifdef CONFIG_MIPS32_O32 -if (test_thread_flag (TIF_32BIT_REGS )) +if (test_ti_thread_flag (task_thread_info (task),TIF_32BIT_REGS ))return get_user (*arg, (int *)usp + n); else#endif
@@ -140,14 +140,14 @@ extern const unsigned long sys_call_table[];extern const unsigned long sys32_call_table[];extern const unsigned long sysn32_call_table[]; -static inline int syscall_get_arch (void ) +static inline int syscall_get_arch (struct task_struct *task) {int arch =AUDIT_ARCH_MIPS ;#ifdef CONFIG_64BIT -if (!test_thread_flag (TIF_32BIT_REGS )) { +if (!test_ti_thread_flag (task_thread_info (task),TIF_32BIT_REGS )) { arch |= __AUDIT_ARCH_64BIT;/* N32 sets only TIF_32BIT_ADDR */ -if (test_thread_flag (TIF_32BIT_ADDR )) +if (test_ti_thread_flag (task_thread_info (task),TIF_32BIT_ADDR )) arch |= __AUDIT_ARCH_CONVENTION_MIPS64_N32; }#endif
arch/mips/kernel/ptrace.c +1 -1
@@ -1272,7 +1272,7 @@ asmlinkage long syscall_trace_enter(struct pt_regs *regs, long syscall)unsigned long args[6 ]; sd.nr = syscall; - sd.arch =syscall_get_arch (); + sd.arch =syscall_get_arch (current);syscall_get_arguments (current, regs,0 ,6 , args);for (i =0 ; i <6 ; i++) sd.args[i] = args[i];
arch/nds32/include/asm/syscall.h +1 -1
@@ -187,7 +187,7 @@ void syscall_set_arguments(struct task_struct *task, struct pt_regs *regs,memcpy (®s->uregs[0 ] + i, args, n *sizeof (args[0 ])); } -static inline int syscall_get_arch (void ) +static inline int syscall_get_arch (struct task_struct *task) {return IS_ENABLED (CONFIG_CPU_BIG_ENDIAN ) ?AUDIT_ARCH_NDS32BE :AUDIT_ARCH_NDS32 ;
arch/nios2/include/asm/syscall.h +1 -1
@@ -136,7 +136,7 @@ static inline void syscall_set_arguments(struct task_struct *task, } } -static inline int syscall_get_arch (void ) +static inline int syscall_get_arch (struct task_struct *task) {return AUDIT_ARCH_NIOS2 ; }
arch/openrisc/include/asm/syscall.h +1 -1
@@ -72,7 +72,7 @@ syscall_set_arguments(struct task_struct *task, struct pt_regs *regs,memcpy (®s->gpr[3 + i], args, n *sizeof (args[0 ])); } -static inline int syscall_get_arch (void ) +static inline int syscall_get_arch (struct task_struct *task) {return AUDIT_ARCH_OPENRISC ; }
arch/parisc/include/asm/syscall.h +2 -2
@@ -62,11 +62,11 @@ static inline void syscall_rollback(struct task_struct *task,/* do nothing */ } -static inline int syscall_get_arch (void ) +static inline int syscall_get_arch (struct task_struct *task) {int arch =AUDIT_ARCH_PARISC ;#ifdef CONFIG_64BIT -if (!is_compat_task ()) +if (!__is_compat_task (task)) arch =AUDIT_ARCH_PARISC64 ;#endif return arch;
arch/powerpc/include/asm/syscall.h +8 -2
@@ -100,9 +100,15 @@ static inline void syscall_set_arguments(struct task_struct *task, regs->orig_gpr3 = args[0 ]; } -static inline int syscall_get_arch (void ) +static inline int syscall_get_arch (struct task_struct *task) { -int arch =is_32bit_task () ?AUDIT_ARCH_PPC :AUDIT_ARCH_PPC64 ; +int arch; + +if (IS_ENABLED (CONFIG_PPC64 ) && !test_tsk_thread_flag (task,TIF_32BIT )) + arch =AUDIT_ARCH_PPC64 ; +else + arch =AUDIT_ARCH_PPC ; +#ifdef __LITTLE_ENDIAN__ arch |= __AUDIT_ARCH_LE;#endif
arch/riscv/include/asm/syscall.h +1 -1
@@ -100,7 +100,7 @@ static inline void syscall_set_arguments(struct task_struct *task,memcpy (®s->a1 + i *sizeof (regs->a1), args, n *sizeof (regs->a0)); } -static inline int syscall_get_arch (void ) +static inline int syscall_get_arch (struct task_struct *task) {#ifdef CONFIG_64BIT return AUDIT_ARCH_RISCV64 ;
arch/s390/include/asm/syscall.h +2 -2
@@ -92,10 +92,10 @@ static inline void syscall_set_arguments(struct task_struct *task, regs->orig_gpr2 = args[0 ]; } -static inline int syscall_get_arch (void ) +static inline int syscall_get_arch (struct task_struct *task) {#ifdef CONFIG_COMPAT -if (test_tsk_thread_flag (current,TIF_31BIT )) +if (test_tsk_thread_flag (task,TIF_31BIT ))return AUDIT_ARCH_S390 ;#endif return AUDIT_ARCH_S390X ;
arch/sh/include/asm/syscall_32.h +1 -1
@@ -95,7 +95,7 @@ static inline void syscall_set_arguments(struct task_struct *task, } } -static inline int syscall_get_arch (void ) +static inline int syscall_get_arch (struct task_struct *task) {int arch =AUDIT_ARCH_SH ;
arch/sh/include/asm/syscall_64.h +1 -1
@@ -63,7 +63,7 @@ static inline void syscall_set_arguments(struct task_struct *task,memcpy (®s->regs[2 + i], args, n *sizeof (args[0 ])); } -static inline int syscall_get_arch (void ) +static inline int syscall_get_arch (struct task_struct *task) {int arch =AUDIT_ARCH_SH ;
arch/sparc/include/asm/syscall.h +3 -2
@@ -128,10 +128,11 @@ static inline void syscall_set_arguments(struct task_struct *task, regs->u_regs[UREG_I0 + i + j] = args[j]; } -static inline int syscall_get_arch (void ) +static inline int syscall_get_arch (struct task_struct *task) {#if defined(CONFIG_SPARC64 ) && defined(CONFIG_COMPAT ) -return in_compat_syscall () ?AUDIT_ARCH_SPARC :AUDIT_ARCH_SPARC64 ; +return test_tsk_thread_flag (task,TIF_32BIT ) + ?AUDIT_ARCH_SPARC :AUDIT_ARCH_SPARC64 ;#elif defined(CONFIG_SPARC64 )return AUDIT_ARCH_SPARC64 ;#else
arch/unicore32/include/asm/syscall.h +1 -1
@@ -4,7 +4,7 @@#include <uapi/linux/audit.h> -static inline int syscall_get_arch (void ) +static inline int syscall_get_arch (struct task_struct *task) {return AUDIT_ARCH_UNICORE ; }
arch/x86/include/asm/syscall.h +5 -3
@@ -107,7 +107,7 @@ static inline void syscall_set_arguments(struct task_struct *task,memcpy (®s->bx + i, args, n *sizeof (args[0 ])); } -static inline int syscall_get_arch (void ) +static inline int syscall_get_arch (struct task_struct *task) {return AUDIT_ARCH_I386 ; }
@@ -236,10 +236,12 @@ static inline void syscall_set_arguments(struct task_struct *task, } } -static inline int syscall_get_arch (void ) +static inline int syscall_get_arch (struct task_struct *task) {/* x32 tasks should be considered AUDIT_ARCH_X86_64. */ -return in_ia32_syscall () ?AUDIT_ARCH_I386 :AUDIT_ARCH_X86_64 ; +return (IS_ENABLED (CONFIG_IA32_EMULATION ) && + task->thread_info.status &TS_COMPAT ) + ?AUDIT_ARCH_I386 :AUDIT_ARCH_X86_64 ; }#endif /* CONFIG_X86_32 */
arch/x86/um/asm/syscall.h +1 -1
@@ -9,7 +9,7 @@ typedef asmlinkage long (*sys_call_ptr_t)(unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long); -static inline int syscall_get_arch (void ) +static inline int syscall_get_arch (struct task_struct *task) {#ifdef CONFIG_X86_32 return AUDIT_ARCH_I386 ;
arch/xtensa/include/asm/syscall.h +1 -1
@@ -10,7 +10,7 @@#include <uapi/linux/audit.h> -static inline int syscall_get_arch (void ) +static inline int syscall_get_arch (struct task_struct *task) {return AUDIT_ARCH_XTENSA ; }
include/asm-generic/syscall.h +2 -1
@@ -144,6 +144,7 @@ void syscall_set_arguments(struct task_struct *task, struct pt_regs *regs,/** * syscall_get_arch - return the AUDIT_ARCH for the current system call +* @task: task of interest, must be blocked * * Returns the AUDIT_ARCH_* based on the system call convention in use. *
@@ -153,5 +154,5 @@ void syscall_set_arguments(struct task_struct *task, struct pt_regs *regs,* Architectures which permit CONFIG_HAVE_ARCH_SECCOMP_FILTER must * provide an implementation of this. */ -int syscall_get_arch (void ); +int syscall_get_arch (struct task_struct *task);#endif /* _ASM_SYSCALL_H */
kernel/auditsc.c +2 -2
@@ -1537,7 +1537,7 @@ void __audit_syscall_entry(int major, unsigned long a1, unsigned long a2,return ; } - context->arch =syscall_get_arch (); + context->arch =syscall_get_arch (current); context->major = major; context->argv[0 ] = a1; context->argv[1 ] = a2;
@@ -2495,7 +2495,7 @@ void audit_seccomp(unsigned long syscall, long signr, int code)return ;audit_log_task (ab);audit_log_format (ab," sig=%ld arch=%x syscall=%ld compat=%d ip=0x%lx code=0x%x" , - signr,syscall_get_arch (), syscall, + signr,syscall_get_arch (current), syscall,in_compat_syscall (),KSTK_EIP (current), code);audit_log_end (ab); }
kernel/seccomp.c +2 -2
@@ -82,7 +82,7 @@ static void populate_seccomp_data(struct seccomp_data *sd)unsigned long args[6 ]; sd->nr =syscall_get_nr (task, regs); - sd->arch =syscall_get_arch (); + sd->arch =syscall_get_arch (task);syscall_get_arguments (task, regs,0 ,6 , args); sd->args[0 ] = args[0 ]; sd->args[1 ] = args[1 ];
@@ -529,7 +529,7 @@ static void seccomp_init_siginfo(kernel_siginfo_t *info, int syscall, int reason info->si_code =SYS_SECCOMP ; info->si_call_addr = (void __user *)KSTK_EIP (current); info->si_errno = reason; - info->si_arch =syscall_get_arch (); + info->si_arch =syscall_get_arch (current); info->si_syscall = syscall; }
Signature · 1 line
ldv
Re: [PATCH v2 16/15] syscall_get_arch: add "struct task_struct *" argument
Quoted 9 lines · Dmitry V. Levin
This argument is required to extend the generic ptrace API with
PTRACE_GET_SYSCALL_INFOrequest:syscall_get_arch()is going to be called fromptrace_request()along with other syscall_get_* functions with a tracee as their argument.This change partially reverts commit
5e937a9ae913("syscall_get_arch:
remove useless function arguments").
Palmer Dabbelt
Reviewed-byRe: [PATCH v2 16/15] syscall_get_arch: add "struct task_struct *" argument
In reply to Dmitry V. LevinQuoted 23 lines · On Tue, 20 Nov 2018 16:44:22 PST (-0800), [email protected] wrote:
This argument is required to extend the generic ptrace API with
PTRACE_GET_SYSCALL_INFOrequest:syscall_get_arch()is going to be called fromptrace_request()along with other syscall_get_* functions with a tracee as their argument.This change partially reverts commit
5e937a9ae913("syscall_get_arch:
remove useless function arguments").
Quoted 8 lines
Re: [PATCH v2 16/15] syscall_get_arch: add "struct task_struct *" argument
In reply to Dmitry V. LevinHi Dmitry,
Quoted 15 lines · Dmitry V. Levin
This argument is required to extend the generic ptrace API with
PTRACE_GET_SYSCALL_INFOrequest:syscall_get_arch()is going to be called fromptrace_request()along with other syscall_get_* functions with a tracee as their argument.This change partially reverts commit
5e937a9ae913("syscall_get_arch:
remove useless function arguments").%
arch/mips/include/asm/syscall.h +0
-0
arch/mips/include/asm/syscall.h static inline unsigned long mips_get_syscall_arg(unsigned long *arg, · line 79
Quoted 8 lines
arch/mips/include/asm/syscall.h +1
-1@@ -73,7 +73,7 @@ static inline unsigned long mips_get_syscall_arg(unsigned long *arg,#ifdef CONFIG_64BIT case 4 :case 5 :case 6 :case 7 :#ifdef CONFIG_MIPS32_O32 -if (test_thread_flag (TIF_32BIT_REGS )) +if (test_ti_thread_flag (task_thread_info (task),TIF_32BIT_REGS ))return get_user (*arg, (int *)usp + n); else#endif
This ought to be test_tsk_thread_flag(task, TIF_32BIT_REGS) instead of open-coding test_tsk_thread_flag.
More fundamentally though, this change doesn't seem to be (directly) related to the change you describe in the commit message - it's not syscall_get_arch being modified here. I suspect this should be a separate commit, or if not please explain in the commit message why this change is included.
Compounding the lack of clarity is the fact that I only received this patch, not the whole series, so I can't view the change in the context of the rest of the series.
Quoted 8 lines
arch/mips/include/asm/syscall.h +1
-1@@ -140,14 +140,14 @@ extern const unsigned long sys_call_table[];extern const unsigned long sys32_call_table[];extern const unsigned long sysn32_call_table[]; -static inline int syscall_get_arch (void ) +static inline int syscall_get_arch (struct task_struct *task) {int arch =AUDIT_ARCH_MIPS ;
arch/mips/include/asm/syscall.h extern const unsigned long sys_call_table[]; · line 153
Quoted 10 lines
arch/mips/include/asm/syscall.h +2
-2#ifdef CONFIG_64BIT -if (!test_thread_flag (TIF_32BIT_REGS )) { +if (!test_ti_thread_flag (task_thread_info (task),TIF_32BIT_REGS )) { arch |= __AUDIT_ARCH_64BIT;/* N32 sets only TIF_32BIT_ADDR */ -if (test_thread_flag (TIF_32BIT_ADDR )) +if (test_ti_thread_flag (task_thread_info (task),TIF_32BIT_ADDR )) arch |= __AUDIT_ARCH_CONVENTION_MIPS64_N32; }#endif
This does seem like the described change, but there are 2 more instances of open-coding test_tsk_thread_flag which ought to be cleaned up.
Thanks,
Paul
Re: [PATCH v2 16/15] syscall_get_arch: add "struct task_struct *" argument
Hi Paul,
Quoted 13 lines · Paul Burton
Hi Dmitry,
Quoted 10 lines · Dmitry V. Levin
This argument is required to extend the generic ptrace API with
PTRACE_GET_SYSCALL_INFOrequest:syscall_get_arch()is going to be called fromptrace_request()along with other syscall_get_* functions with a tracee as their argument.This change partially reverts commit
5e937a9ae913("syscall_get_arch:
remove useless function arguments").%
Quoted 16 lines
arch/mips/include/asm/syscall.h static inline unsigned long mips_get_syscall_arg(unsigned long *arg, · line 79
Quoted 13 lines
arch/mips/include/asm/syscall.h +1
-1@@ -73,7 +73,7 @@ static inline unsigned long mips_get_syscall_arg(unsigned long *arg,#ifdef CONFIG_64BIT case 4 :case 5 :case 6 :case 7 :#ifdef CONFIG_MIPS32_O32 -if (test_thread_flag (TIF_32BIT_REGS )) +if (test_ti_thread_flag (task_thread_info (task),TIF_32BIT_REGS ))return get_user (*arg, (int *)usp + n); else#endif This ought to be
test_tsk_thread_flag(task, TIF_32BIT_REGS)instead of open-codingtest_tsk_thread_flag.
This will be corrected, thanks for letting me know.
Quoted 5 lines
More fundamentally though, this change doesn't seem to be (directly) related to the change you describe in the commit message - it's not
syscall_get_archbeing modified here. I suspect this should be a separate commit, or if not please explain in the commit message why this change is included.
Good point, this is a fix that should not have been included into this commit. The bug was found while preparing the syscall_get_arch change, and this hunk just slipped in. I'll send it as a separate commit.
Quoted 17 lines
Compounding the lack of clarity is the fact that I only received this patch, not the whole series, so I can't view the change in the context of the rest of the series.
Quoted 13 lines
arch/mips/include/asm/syscall.h +2
-2@@ -140,14 +140,14 @@ extern const unsigned long sys_call_table[];extern const unsigned long sys32_call_table[];extern const unsigned long sysn32_call_table[]; -static inline int syscall_get_arch (void ) +static inline int syscall_get_arch (struct task_struct *task) {int arch =AUDIT_ARCH_MIPS ;#ifdef CONFIG_64BIT -if (!test_thread_flag (TIF_32BIT_REGS )) { +if (!test_ti_thread_flag (task_thread_info (task),TIF_32BIT_REGS )) { arch |= __AUDIT_ARCH_64BIT;/* N32 sets only TIF_32BIT_ADDR */
Quoted 8 lines
arch/mips/include/asm/syscall.h extern const unsigned long sys_call_table[]; · line 153
Quoted 5 lines
arch/mips/include/asm/syscall.h +1
-1-if (test_thread_flag (TIF_32BIT_ADDR )) +if (test_ti_thread_flag (task_thread_info (task),TIF_32BIT_ADDR )) arch |= __AUDIT_ARCH_CONVENTION_MIPS64_N32; }#endif This does seem like the described change, but there are 2 more instances of open-coding
test_tsk_thread_flagwhich ought to be cleaned up.
This will be cleaned up, thanks for letting me know.
Signature · 1 line
ldv
PATCH 1/1 mips: fix mips_get_syscall_arg o32 check
When checking for TIF_32BIT_REGS flag, mips_get_syscall_arg() should use the task specified as its argument instead of the current task.
This potentially affects all syscall_get_arguments() users who specify tasks different from the current.
--- arch/mips/include/asm/syscall.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/include/asm/syscall.h +1 -1
@@ -73,7 +73,7 @@ static inline unsigned long mips_get_syscall_arg(unsigned long *arg,#ifdef CONFIG_64BIT case 4 :case 5 :case 6 :case 7 :#ifdef CONFIG_MIPS32_O32 -if (test_thread_flag (TIF_32BIT_REGS )) +if (test_tsk_thread_flag (task,TIF_32BIT_REGS ))return get_user (*arg, (int *)usp + n); else#endif
Signature · 1 line
ldv
Paul Burton
AppliedRe: [PATCH] mips: fix mips_get_syscall_arg o32 check
Hello,
Quoted 8 lines · Dmitry V. Levin
When checking for
TIF_32BIT_REGSflag,mips_get_syscall_arg()should use the task specified as its argument instead of the current task.This potentially affects all
syscall_get_arguments()users who specify tasks different from the current.Fixes c0ff3c53d4f99 ("MIPS: Enable HAVE_ARCH_TRACEHOOK.")Signed-off-by Dmitry V. Levin <[email protected]>
Applied to mips-fixes.
Thanks,
Paul
[ This message was auto-generated; if you believe anything is incorrect
then please email [email protected] to report it. ]
[PATCH v2 16/15 v2] syscall_get_arch: add "struct task_struct *" argument
In reply to Dmitry V. LevinThis argument is required to extend the generic ptrace API with PTRACE_GET_SYSCALL_INFO request: syscall_get_arch() is going to be called from ptrace_request() along with other syscall_get_* functions with a tracee as their argument.
This change partially reverts commit 5e937a9ae913 ("syscall_get_arch:
remove useless function arguments").
---
v2: cleaned up mips part, added Reviewed-by
arch/alpha/include/asm/syscall.h | 2 +- arch/arc/include/asm/syscall.h | 2 +- arch/arm/include/asm/syscall.h | 2 +- arch/arm64/include/asm/syscall.h | 4 ++-- arch/c6x/include/asm/syscall.h | 2 +- arch/h8300/include/asm/syscall.h | 2 +- arch/hexagon/include/asm/syscall.h | 2 +- arch/ia64/include/asm/syscall.h | 2 +- arch/m68k/include/asm/syscall.h | 2 +- arch/microblaze/include/asm/syscall.h | 2 +- arch/mips/include/asm/syscall.h | 6 +++--- arch/mips/kernel/ptrace.c | 2 +- arch/nds32/include/asm/syscall.h | 2 +- arch/nios2/include/asm/syscall.h | 2 +- arch/openrisc/include/asm/syscall.h | 2 +- arch/parisc/include/asm/syscall.h | 4 ++-- arch/powerpc/include/asm/syscall.h | 10 ++++++++-- arch/riscv/include/asm/syscall.h | 2 +- arch/s390/include/asm/syscall.h | 4 ++-- arch/sh/include/asm/syscall_32.h | 2 +- arch/sh/include/asm/syscall_64.h | 2 +- arch/sparc/include/asm/syscall.h | 5 +++-- arch/unicore32/include/asm/syscall.h | 2 +- arch/x86/include/asm/syscall.h | 8 +++++--- arch/x86/um/asm/syscall.h | 2 +- arch/xtensa/include/asm/syscall.h | 2 +- include/asm-generic/syscall.h | 3 ++- kernel/auditsc.c | 4 ++-- kernel/seccomp.c | 4 ++-- 29 files changed, 50 insertions(+), 40 deletions(-)
arch/alpha/include/asm/syscall.h +1 -1
@@ -4,7 +4,7 @@#include <uapi/linux/audit.h> -static inline int syscall_get_arch (void ) +static inline int syscall_get_arch (struct task_struct *task) {return AUDIT_ARCH_ALPHA ; }
arch/arc/include/asm/syscall.h +1 -1
@@ -69,7 +69,7 @@ syscall_get_arguments(struct task_struct *task, struct pt_regs *regs, } } -static inline int syscall_get_arch (void ) +static inline int syscall_get_arch (struct task_struct *task) {return IS_ENABLED (CONFIG_ISA_ARCOMPACT ) ? (IS_ENABLED(CONFIG_CPU_BIG_ENDIAN)
arch/arm/include/asm/syscall.h +1 -1
@@ -104,7 +104,7 @@ static inline void syscall_set_arguments(struct task_struct *task,memcpy (®s->ARM_r0 + i, args, n *sizeof (args[0 ])); } -static inline int syscall_get_arch (void ) +static inline int syscall_get_arch (struct task_struct *task) {/* ARM tasks don't change audit architectures on the fly. */ return AUDIT_ARCH_ARM ;
arch/arm64/include/asm/syscall.h +2 -2
@@ -117,9 +117,9 @@ static inline void syscall_set_arguments(struct task_struct *task,* We don't care about endianness (__AUDIT_ARCH_LE bit) here because * AArch64 has the same system calls both on little- and big- endian. */ -static inline int syscall_get_arch (void ) +static inline int syscall_get_arch (struct task_struct *task) { -if (is_compat_task ()) +if (is_compat_thread (task_thread_info (task)))return AUDIT_ARCH_ARM ;return AUDIT_ARCH_AARCH64 ;
arch/c6x/include/asm/syscall.h +1 -1
@@ -121,7 +121,7 @@ static inline void syscall_set_arguments(struct task_struct *task, } } -static inline int syscall_get_arch (void ) +static inline int syscall_get_arch (struct task_struct *task) {return IS_ENABLED (CONFIG_CPU_BIG_ENDIAN ) ?AUDIT_ARCH_C6XBE :AUDIT_ARCH_C6X ;
arch/h8300/include/asm/syscall.h +1 -1
@@ -48,7 +48,7 @@ syscall_get_arguments(struct task_struct *task, struct pt_regs *regs, } } -static inline int syscall_get_arch (void ) +static inline int syscall_get_arch (struct task_struct *task) {return AUDIT_ARCH_H8300 ; }
arch/hexagon/include/asm/syscall.h +1 -1
@@ -46,7 +46,7 @@ static inline void syscall_get_arguments(struct task_struct *task,memcpy (args, &(®s->r00)[i], n *sizeof (args[0 ])); } -static inline int syscall_get_arch (void ) +static inline int syscall_get_arch (struct task_struct *task) {return AUDIT_ARCH_HEXAGON ; }
arch/ia64/include/asm/syscall.h +1 -1
@@ -81,7 +81,7 @@ static inline void syscall_set_arguments(struct task_struct *task,ia64_syscall_get_set_arguments (task, regs, i, n, args,1 ); } -static inline int syscall_get_arch (void ) +static inline int syscall_get_arch (struct task_struct *task) {return AUDIT_ARCH_IA64 ; }
arch/m68k/include/asm/syscall.h +1 -1
@@ -4,7 +4,7 @@#include <uapi/linux/audit.h> -static inline int syscall_get_arch (void ) +static inline int syscall_get_arch (struct task_struct *task) {return AUDIT_ARCH_M68K ; }
arch/microblaze/include/asm/syscall.h +1 -1
@@ -101,7 +101,7 @@ static inline void syscall_set_arguments(struct task_struct *task,asmlinkage unsigned long do_syscall_trace_enter (struct pt_regs *regs); asmlinkage void do_syscall_trace_leave(struct pt_regs *regs); -static inline int syscall_get_arch (void ) +static inline int syscall_get_arch (struct task_struct *task) {return AUDIT_ARCH_MICROBLAZE ; }
arch/mips/include/asm/syscall.h +3 -3
@@ -140,14 +140,14 @@ extern const unsigned long sys_call_table[];extern const unsigned long sys32_call_table[];extern const unsigned long sysn32_call_table[]; -static inline int syscall_get_arch (void ) +static inline int syscall_get_arch (struct task_struct *task) {int arch =AUDIT_ARCH_MIPS ;#ifdef CONFIG_64BIT -if (!test_thread_flag (TIF_32BIT_REGS )) { +if (!test_tsk_thread_flag (task,TIF_32BIT_REGS )) { arch |= __AUDIT_ARCH_64BIT;/* N32 sets only TIF_32BIT_ADDR */ -if (test_thread_flag (TIF_32BIT_ADDR )) +if (test_tsk_thread_flag (task,TIF_32BIT_ADDR )) arch |= __AUDIT_ARCH_CONVENTION_MIPS64_N32; }#endif
arch/mips/kernel/ptrace.c +1 -1
@@ -1272,7 +1272,7 @@ asmlinkage long syscall_trace_enter(struct pt_regs *regs, long syscall)unsigned long args[6 ]; sd.nr = syscall; - sd.arch =syscall_get_arch (); + sd.arch =syscall_get_arch (current);syscall_get_arguments (current, regs,0 ,6 , args);for (i =0 ; i <6 ; i++) sd.args[i] = args[i];
arch/nds32/include/asm/syscall.h +1 -1
@@ -187,7 +187,7 @@ void syscall_set_arguments(struct task_struct *task, struct pt_regs *regs,memcpy (®s->uregs[0 ] + i, args, n *sizeof (args[0 ])); } -static inline int syscall_get_arch (void ) +static inline int syscall_get_arch (struct task_struct *task) {return IS_ENABLED (CONFIG_CPU_BIG_ENDIAN ) ?AUDIT_ARCH_NDS32BE :AUDIT_ARCH_NDS32 ;
arch/nios2/include/asm/syscall.h +1 -1
@@ -136,7 +136,7 @@ static inline void syscall_set_arguments(struct task_struct *task, } } -static inline int syscall_get_arch (void ) +static inline int syscall_get_arch (struct task_struct *task) {return AUDIT_ARCH_NIOS2 ; }
arch/openrisc/include/asm/syscall.h +1 -1
@@ -72,7 +72,7 @@ syscall_set_arguments(struct task_struct *task, struct pt_regs *regs,memcpy (®s->gpr[3 + i], args, n *sizeof (args[0 ])); } -static inline int syscall_get_arch (void ) +static inline int syscall_get_arch (struct task_struct *task) {return AUDIT_ARCH_OPENRISC ; }
arch/parisc/include/asm/syscall.h +2 -2
@@ -62,11 +62,11 @@ static inline void syscall_rollback(struct task_struct *task,/* do nothing */ } -static inline int syscall_get_arch (void ) +static inline int syscall_get_arch (struct task_struct *task) {int arch =AUDIT_ARCH_PARISC ;#ifdef CONFIG_64BIT -if (!is_compat_task ()) +if (!__is_compat_task (task)) arch =AUDIT_ARCH_PARISC64 ;#endif return arch;
arch/powerpc/include/asm/syscall.h +8 -2
@@ -100,9 +100,15 @@ static inline void syscall_set_arguments(struct task_struct *task, regs->orig_gpr3 = args[0 ]; } -static inline int syscall_get_arch (void ) +static inline int syscall_get_arch (struct task_struct *task) { -int arch =is_32bit_task () ?AUDIT_ARCH_PPC :AUDIT_ARCH_PPC64 ; +int arch; + +if (IS_ENABLED (CONFIG_PPC64 ) && !test_tsk_thread_flag (task,TIF_32BIT )) + arch =AUDIT_ARCH_PPC64 ; +else + arch =AUDIT_ARCH_PPC ; +#ifdef __LITTLE_ENDIAN__ arch |= __AUDIT_ARCH_LE;#endif
arch/riscv/include/asm/syscall.h +1 -1
@@ -100,7 +100,7 @@ static inline void syscall_set_arguments(struct task_struct *task,memcpy (®s->a1 + i *sizeof (regs->a1), args, n *sizeof (regs->a0)); } -static inline int syscall_get_arch (void ) +static inline int syscall_get_arch (struct task_struct *task) {#ifdef CONFIG_64BIT return AUDIT_ARCH_RISCV64 ;
arch/s390/include/asm/syscall.h +2 -2
@@ -92,10 +92,10 @@ static inline void syscall_set_arguments(struct task_struct *task, regs->orig_gpr2 = args[0 ]; } -static inline int syscall_get_arch (void ) +static inline int syscall_get_arch (struct task_struct *task) {#ifdef CONFIG_COMPAT -if (test_tsk_thread_flag (current,TIF_31BIT )) +if (test_tsk_thread_flag (task,TIF_31BIT ))return AUDIT_ARCH_S390 ;#endif return AUDIT_ARCH_S390X ;
arch/sh/include/asm/syscall_32.h +1 -1
@@ -95,7 +95,7 @@ static inline void syscall_set_arguments(struct task_struct *task, } } -static inline int syscall_get_arch (void ) +static inline int syscall_get_arch (struct task_struct *task) {int arch =AUDIT_ARCH_SH ;
arch/sh/include/asm/syscall_64.h +1 -1
@@ -63,7 +63,7 @@ static inline void syscall_set_arguments(struct task_struct *task,memcpy (®s->regs[2 + i], args, n *sizeof (args[0 ])); } -static inline int syscall_get_arch (void ) +static inline int syscall_get_arch (struct task_struct *task) {int arch =AUDIT_ARCH_SH ;
arch/sparc/include/asm/syscall.h +3 -2
@@ -128,10 +128,11 @@ static inline void syscall_set_arguments(struct task_struct *task, regs->u_regs[UREG_I0 + i + j] = args[j]; } -static inline int syscall_get_arch (void ) +static inline int syscall_get_arch (struct task_struct *task) {#if defined(CONFIG_SPARC64 ) && defined(CONFIG_COMPAT ) -return in_compat_syscall () ?AUDIT_ARCH_SPARC :AUDIT_ARCH_SPARC64 ; +return test_tsk_thread_flag (task,TIF_32BIT ) + ?AUDIT_ARCH_SPARC :AUDIT_ARCH_SPARC64 ;#elif defined(CONFIG_SPARC64 )return AUDIT_ARCH_SPARC64 ;#else
arch/unicore32/include/asm/syscall.h +1 -1
@@ -4,7 +4,7 @@#include <uapi/linux/audit.h> -static inline int syscall_get_arch (void ) +static inline int syscall_get_arch (struct task_struct *task) {return AUDIT_ARCH_UNICORE ; }
arch/x86/include/asm/syscall.h +5 -3
@@ -107,7 +107,7 @@ static inline void syscall_set_arguments(struct task_struct *task,memcpy (®s->bx + i, args, n *sizeof (args[0 ])); } -static inline int syscall_get_arch (void ) +static inline int syscall_get_arch (struct task_struct *task) {return AUDIT_ARCH_I386 ; }
@@ -236,10 +236,12 @@ static inline void syscall_set_arguments(struct task_struct *task, } } -static inline int syscall_get_arch (void ) +static inline int syscall_get_arch (struct task_struct *task) {/* x32 tasks should be considered AUDIT_ARCH_X86_64. */ -return in_ia32_syscall () ?AUDIT_ARCH_I386 :AUDIT_ARCH_X86_64 ; +return (IS_ENABLED (CONFIG_IA32_EMULATION ) && + task->thread_info.status &TS_COMPAT ) + ?AUDIT_ARCH_I386 :AUDIT_ARCH_X86_64 ; }#endif /* CONFIG_X86_32 */
arch/x86/um/asm/syscall.h +1 -1
@@ -9,7 +9,7 @@ typedef asmlinkage long (*sys_call_ptr_t)(unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long); -static inline int syscall_get_arch (void ) +static inline int syscall_get_arch (struct task_struct *task) {#ifdef CONFIG_X86_32 return AUDIT_ARCH_I386 ;
arch/xtensa/include/asm/syscall.h +1 -1
@@ -10,7 +10,7 @@#include <uapi/linux/audit.h> -static inline int syscall_get_arch (void ) +static inline int syscall_get_arch (struct task_struct *task) {return AUDIT_ARCH_XTENSA ; }
include/asm-generic/syscall.h +2 -1
@@ -144,6 +144,7 @@ void syscall_set_arguments(struct task_struct *task, struct pt_regs *regs,/** * syscall_get_arch - return the AUDIT_ARCH for the current system call +* @task: task of interest, must be blocked * * Returns the AUDIT_ARCH_* based on the system call convention in use. *
@@ -153,5 +154,5 @@ void syscall_set_arguments(struct task_struct *task, struct pt_regs *regs,* Architectures which permit CONFIG_HAVE_ARCH_SECCOMP_FILTER must * provide an implementation of this. */ -int syscall_get_arch (void ); +int syscall_get_arch (struct task_struct *task);#endif /* _ASM_SYSCALL_H */
kernel/auditsc.c +2 -2
@@ -1537,7 +1537,7 @@ void __audit_syscall_entry(int major, unsigned long a1, unsigned long a2,return ; } - context->arch =syscall_get_arch (); + context->arch =syscall_get_arch (current); context->major = major; context->argv[0 ] = a1; context->argv[1 ] = a2;
@@ -2495,7 +2495,7 @@ void audit_seccomp(unsigned long syscall, long signr, int code)return ;audit_log_task (ab);audit_log_format (ab," sig=%ld arch=%x syscall=%ld compat=%d ip=0x%lx code=0x%x" , - signr,syscall_get_arch (), syscall, + signr,syscall_get_arch (current), syscall,in_compat_syscall (),KSTK_EIP (current), code);audit_log_end (ab); }
kernel/seccomp.c +2 -2
@@ -82,7 +82,7 @@ static void populate_seccomp_data(struct seccomp_data *sd)unsigned long args[6 ]; sd->nr =syscall_get_nr (task, regs); - sd->arch =syscall_get_arch (); + sd->arch =syscall_get_arch (task);syscall_get_arguments (task, regs,0 ,6 , args); sd->args[0 ] = args[0 ]; sd->args[1 ] = args[1 ];
@@ -529,7 +529,7 @@ static void seccomp_init_siginfo(kernel_siginfo_t *info, int syscall, int reason info->si_code =SYS_SECCOMP ; info->si_call_addr = (void __user *)KSTK_EIP (current); info->si_errno = reason; - info->si_arch =syscall_get_arch (); + info->si_arch =syscall_get_arch (current); info->si_syscall = syscall; }
Signature · 1 line
ldv
Paul Burton
Acked-byRe: [PATCH v2 16/15 v2] syscall_get_arch: add "struct task_struct *" argument
Hi Dmitry,
Quoted 33 lines · Dmitry V. Levin
This argument is required to extend the generic ptrace API with
PTRACE_GET_SYSCALL_INFOrequest:syscall_get_arch()is going to be called fromptrace_request()along with other syscall_get_* functions with a tracee as their argument.This change partially reverts commit
5e937a9ae913("syscall_get_arch:
remove useless function arguments").Reviewed-by Andy Lutomirski <[email protected]> # for x86Reviewed-by Palmer Dabbelt <[email protected]>Signed-off-by Dmitry V. Levin <[email protected]>
Quoted 3 lines
---
v2: cleaned up mips part, added Reviewed-by
I thought the last one was v2? :)
Anyway, this looks fine to me now:
Thanks,
Paul
Re: [PATCH v2 16/15] syscall_get_arch: add "struct task_struct *" argument
In reply to Dmitry V. LevinQuoted 12 lines · Dmitry V. Levin
arch/powerpc/include/asm/syscall.h +1
-2@@ -100,9 +100,15 @@ static inline void syscall_set_arguments(struct task_struct *task, regs->orig_gpr3 = args[0 ]; } -static inline int syscall_get_arch (void ) +static inline int syscall_get_arch (struct task_struct *task) { -int arch =is_32bit_task () ?AUDIT_ARCH_PPC :AUDIT_ARCH_PPC64 ;
arch/powerpc/include/asm/syscall.h static inline void syscall_set_arguments(struct task_struct *task, · line 114
Quoted 10 lines
arch/powerpc/include/asm/syscall.h +7
-0+int arch; + +if (IS_ENABLED (CONFIG_PPC64 ) && !test_tsk_thread_flag (task,TIF_32BIT )) + arch =AUDIT_ARCH_PPC64 ; +else + arch =AUDIT_ARCH_PPC ; +#ifdef __LITTLE_ENDIAN__ arch |= __AUDIT_ARCH_LE;#endif
LGTM.
cheers