mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-05 18:39:59 +00:00
xtensa: use generic tracehooks
Use tracehook_report_syscall_{entry,exit} instead of a local copy of it in do_syscall_trace. Allow tracehook to cancel syscall by returning invalid syscall number to the system_call function. Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
This commit is contained in:
parent
0700ed072f
commit
f984409a00
2 changed files with 14 additions and 27 deletions
|
@ -1899,10 +1899,11 @@ ENTRY(system_call)
|
||||||
movi a4, do_syscall_trace_enter
|
movi a4, do_syscall_trace_enter
|
||||||
s32i a3, a2, PT_SYSCALL
|
s32i a3, a2, PT_SYSCALL
|
||||||
callx4 a4
|
callx4 a4
|
||||||
|
mov a3, a6
|
||||||
|
|
||||||
/* syscall = sys_call_table[syscall_nr] */
|
/* syscall = sys_call_table[syscall_nr] */
|
||||||
|
|
||||||
movi a4, sys_call_table;
|
movi a4, sys_call_table
|
||||||
movi a5, __NR_syscall_count
|
movi a5, __NR_syscall_count
|
||||||
movi a6, -ENOSYS
|
movi a6, -ENOSYS
|
||||||
bgeu a3, a5, 1f
|
bgeu a3, a5, 1f
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#include <linux/security.h>
|
#include <linux/security.h>
|
||||||
#include <linux/signal.h>
|
#include <linux/signal.h>
|
||||||
#include <linux/smp.h>
|
#include <linux/smp.h>
|
||||||
|
#include <linux/tracehook.h>
|
||||||
#include <linux/uaccess.h>
|
#include <linux/uaccess.h>
|
||||||
|
|
||||||
#include <asm/coprocessor.h>
|
#include <asm/coprocessor.h>
|
||||||
|
@ -468,36 +469,21 @@ long arch_ptrace(struct task_struct *child, long request,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void do_syscall_trace(void)
|
unsigned long do_syscall_trace_enter(struct pt_regs *regs)
|
||||||
{
|
|
||||||
/*
|
|
||||||
* The 0x80 provides a way for the tracing parent to distinguish
|
|
||||||
* between a syscall stop and SIGTRAP delivery
|
|
||||||
*/
|
|
||||||
ptrace_notify(SIGTRAP |
|
|
||||||
((current->ptrace & PT_TRACESYSGOOD) ? 0x80 : 0));
|
|
||||||
|
|
||||||
/*
|
|
||||||
* this isn't the same as continuing with a signal, but it will do
|
|
||||||
* for normal use. strace only continues with a signal if the
|
|
||||||
* stopping signal is not SIGTRAP. -brl
|
|
||||||
*/
|
|
||||||
if (current->exit_code) {
|
|
||||||
send_sig(current->exit_code, current, 1);
|
|
||||||
current->exit_code = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void do_syscall_trace_enter(struct pt_regs *regs)
|
|
||||||
{
|
{
|
||||||
if (test_thread_flag(TIF_SYSCALL_TRACE) &&
|
if (test_thread_flag(TIF_SYSCALL_TRACE) &&
|
||||||
(current->ptrace & PT_PTRACED))
|
tracehook_report_syscall_entry(regs))
|
||||||
do_syscall_trace();
|
return -1;
|
||||||
|
|
||||||
|
return regs->areg[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
void do_syscall_trace_leave(struct pt_regs *regs)
|
void do_syscall_trace_leave(struct pt_regs *regs)
|
||||||
{
|
{
|
||||||
if (test_thread_flag(TIF_SYSCALL_TRACE) &&
|
int step;
|
||||||
(current->ptrace & PT_PTRACED))
|
|
||||||
do_syscall_trace();
|
step = test_thread_flag(TIF_SINGLESTEP);
|
||||||
|
|
||||||
|
if (step || test_thread_flag(TIF_SYSCALL_TRACE))
|
||||||
|
tracehook_report_syscall_exit(regs, step);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue