[PATCH 35] convert ptrace_report_syscall_entry()

Oleg Nesterov oleg at redhat.com
Tue Sep 15 18:48:54 UTC 2009


Change ptrace_report_syscall_entry() to use ptrace_event.

I am worried about PTRACE_SYSEMU, I continue to ignore this magic
which I don't understand yet... Hopefully I will be able to add the
necessary changes later.

---

 kernel/ptrace.c |   57 ++++++++++++++++++--------------------------------------
 1 file changed, 19 insertions(+), 38 deletions(-)

--- PU/kernel/ptrace.c~35_SYSCALL_ENTRY	2009-09-15 14:49:47.000000000 +0200
+++ PU/kernel/ptrace.c	2009-09-15 15:45:47.000000000 +0200
@@ -141,12 +141,6 @@ static enum utrace_resume_action ptrace_
 	return UTRACE_RESUME - ((task->ptrace >> 16) & UTRACE_RESUME_MASK);
 }
 
-static enum utrace_syscall_action ptrace_syscall_action(
-	struct task_struct *task)
-{
-	return (task->ptrace >> 16) & UTRACE_SYSCALL_MASK;
-}
-
 /*
  * Remember which event stop this was.  We have to keep a record that
  * won't be wiped by ptrace_do_wait() when @task->exit_code is cleared.
@@ -314,31 +308,6 @@ static u32 ptrace_report_clone(enum utra
 	return ret;
 }
 
-static u32 ptrace_report_syscall(u32 action, struct utrace_engine *engine,
-					struct task_struct *task)
-{
-	struct ptrace_context *context = ptrace_context(engine);
-	int code = SIGTRAP;
-	if (context->options & PTRACE_O_TRACESYSGOOD)
-		code |= 0x80;
-	return utrace_ptrace_report(action, task, PTRACE_EVENT_SYSCALL, code);
-}
-
-static u32 ptrace_report_syscall_entry(u32 action,
-				       struct utrace_engine *engine,
-				       struct task_struct *task,
-				       struct pt_regs *regs)
-{
-	/*
-	 * If we're doing PTRACE_SYSEMU, just punt here and report
-	 * at the exit stop instead.
-	 */
-	if (ptrace_syscall_action(task))
-		return UTRACE_SYSCALL_ABORT | UTRACE_RESUME;
-
-	return ptrace_report_syscall(UTRACE_SYSCALL_RUN, engine, task);
-}
-
 static void ptrace_resume_syscall(struct utrace_engine *engine,
 				struct task_struct *tracee, long data)
 {
@@ -351,18 +320,30 @@ static void ptrace_resume_syscall(struct
 	}
 }
 
-static u32 ptrace_report_syscall_exit(enum utrace_resume_action action,
-				      struct utrace_engine *engine,
-				      struct task_struct *task,
-				      struct pt_regs *regs)
+static void push_syscall_event(struct ptrace_context *context)
 {
-	struct ptrace_context *context = ptrace_context(engine);
-	struct ptrace_event *ev;
+	struct ptrace_event *ev = ev_push(context);
 
-	ev = ev_push(context);
 	ev->ev_resume = ptrace_resume_syscall;
 	ev->ev_code = (context->options & PTRACE_O_TRACESYSGOOD) ?
 			(SIGTRAP | 0x80) : SIGTRAP;
+}
+
+static u32 ptrace_report_syscall_entry(u32 action,
+				       struct utrace_engine *engine,
+				       struct task_struct *task,
+				       struct pt_regs *regs)
+{
+	push_syscall_event(ptrace_context(engine));
+	return UTRACE_SYSCALL_RUN | UTRACE_STOP;
+}
+
+static u32 ptrace_report_syscall_exit(enum utrace_resume_action action,
+				      struct utrace_engine *engine,
+				      struct task_struct *task,
+				      struct pt_regs *regs)
+{
+	push_syscall_event(ptrace_context(engine));
 	return UTRACE_STOP;
 }
 




More information about the utrace-devel mailing list