diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c index 03dc39f9..1795eb5f 100644 --- a/arch/arm64/kernel/ptrace.c +++ b/arch/arm64/kernel/ptrace.c @@ -965,7 +965,7 @@ void ptrace_report_signal(struct thread *thread, int sig) proc->status = PS_TRACED; #endif /* POSTK_DEBUG_TEMP_FIX_41 */ thread->status = PS_TRACED; - proc->ptrace &= ~PT_TRACE_SYSCALL_MASK; + proc->ptrace &= ~PT_TRACE_SYSCALL; if (sig == SIGSTOP || sig == SIGTSTP || sig == SIGTTIN || sig == SIGTTOU) { proc->signal_flags |= SIGNAL_STOP_STOPPED; diff --git a/arch/x86/kernel/syscall.c b/arch/x86/kernel/syscall.c index aa4d8e52..f36a681e 100644 --- a/arch/x86/kernel/syscall.c +++ b/arch/x86/kernel/syscall.c @@ -537,7 +537,7 @@ void ptrace_report_signal(struct thread *thread, int sig) /* Transition thread state */ proc->status = PS_TRACED; thread->status = PS_TRACED; - proc->ptrace &= ~PT_TRACE_SYSCALL_MASK; + proc->ptrace &= ~PT_TRACE_SYSCALL; if (sig == SIGSTOP || sig == SIGTSTP || sig == SIGTTIN || sig == SIGTTOU) { proc->signal_flags |= SIGNAL_STOP_STOPPED; diff --git a/kernel/include/process.h b/kernel/include/process.h index 349827ed..445031ce 100644 --- a/kernel/include/process.h +++ b/kernel/include/process.h @@ -78,9 +78,7 @@ // struct process.ptrace #define PT_TRACED 0x80 /* The process is ptraced */ #define PT_TRACE_EXEC 0x100 /* Trace execve(2) */ -#define PT_TRACE_SYSCALL_ENTER 0x200 /* Trace syscall enter */ -#define PT_TRACE_SYSCALL_EXIT 0x400 /* Trace syscall exit */ -#define PT_TRACE_SYSCALL_MASK (PT_TRACE_SYSCALL_ENTER | PT_TRACE_SYSCALL_EXIT) +#define PT_TRACE_SYSCALL 0x200 /* Trace syscall enter */ // ptrace(2) request #define PTRACE_TRACEME 0 diff --git a/kernel/syscall.c b/kernel/syscall.c index 489229f3..4a7dcd9a 100644 --- a/kernel/syscall.c +++ b/kernel/syscall.c @@ -2005,28 +2005,11 @@ static int ptrace_report_exec(struct thread *thread) return 0; } - -static void ptrace_syscall_enter(struct thread *thread) -{ - int ptrace = thread->proc->ptrace; - struct mcs_rwlock_node_irqsave lock; - - if (ptrace & PT_TRACE_SYSCALL_ENTER) { - int sig = (SIGTRAP | ((ptrace & PTRACE_O_TRACESYSGOOD) ? 0x80 : 0)); - ptrace_report_signal(thread, sig); - mcs_rwlock_writer_lock(&thread->proc->update_lock, &lock); - if (thread->proc->ptrace & PT_TRACE_SYSCALL_ENTER) { - thread->proc->ptrace |= PT_TRACE_SYSCALL_EXIT; - } - mcs_rwlock_writer_unlock(&thread->proc->update_lock, &lock); - } -} - -static void ptrace_syscall_exit(struct thread *thread) +static void ptrace_syscall_event(struct thread *thread) { int ptrace = thread->proc->ptrace; - if (ptrace & PT_TRACE_SYSCALL_EXIT) { + if (ptrace & PT_TRACE_SYSCALL) { int sig = (SIGTRAP | ((ptrace & PTRACE_O_TRACESYSGOOD) ? 0x80 : 0)); ptrace_report_signal(thread, sig); } @@ -2076,7 +2059,7 @@ static int ptrace_report_clone(struct thread *thread, struct thread *new, int ev thread->proc->status = PS_TRACED; thread->status = PS_TRACED; thread->proc->ptrace_eventmsg = new->tid; - thread->proc->ptrace &= ~PT_TRACE_SYSCALL_MASK; + thread->proc->ptrace &= ~PT_TRACE_SYSCALL; /** ??? **/ parent_pid = thread->proc->parent->pid; mcs_rwlock_writer_unlock_noirq(&thread->proc->update_lock, &lock); @@ -2275,7 +2258,7 @@ SYSCALL_DECLARE(execve) if (cpu_local_var(current)->proc->ptrace) { ihk_mc_syscall_ret(ctx) = 0; - ptrace_syscall_exit(cpu_local_var(current)); + ptrace_syscall_event(cpu_local_var(current)); } /* Unmap all memory areas of the process, userspace will be gone */ @@ -5682,9 +5665,9 @@ static int ptrace_wakeup_sig(int pid, long request, long data) { set_single_step(child); } mcs_rwlock_writer_lock(&child->proc->update_lock, &lock); - child->proc->ptrace &= ~PT_TRACE_SYSCALL_MASK; + child->proc->ptrace &= ~PT_TRACE_SYSCALL; if (request == PTRACE_SYSCALL) { - child->proc->ptrace |= PT_TRACE_SYSCALL_ENTER; + child->proc->ptrace |= PT_TRACE_SYSCALL; } mcs_rwlock_writer_unlock(&child->proc->update_lock, &lock); if(data != 0 && data != SIGSTOP) { @@ -9985,7 +9968,7 @@ long syscall(int num, ihk_mc_user_context_t *ctx) if (cpu_local_var(current)->proc->ptrace) { ihk_mc_syscall_ret(ctx) = -ENOSYS; - ptrace_syscall_enter(cpu_local_var(current)); + ptrace_syscall_event(cpu_local_var(current)); num = ihk_mc_syscall_number(ctx); } @@ -10032,7 +10015,7 @@ long syscall(int num, ihk_mc_user_context_t *ctx) if (cpu_local_var(current)->proc->ptrace && l != -ENOSYS) { ihk_mc_syscall_ret(ctx) = l; - ptrace_syscall_exit(cpu_local_var(current)); + ptrace_syscall_event(cpu_local_var(current)); l = ihk_mc_syscall_ret(ctx); }