[PATCH 21] use context->options instead of "->ptrace & PT_"

Oleg Nesterov oleg at redhat.com
Fri Sep 4 18:39:12 UTC 2009


Convert ptrace.c to use context->options.

I guess ptrace_report_clone() still needs changes... bbut hopefully
ptrace_clone_attach() is fine.

---

--- PU/kernel/ptrace.c~21_USE_CTX_OPTS	2009-09-04 18:01:09.000000000 +0200
+++ PU/kernel/ptrace.c	2009-09-04 18:33:03.000000000 +0200
@@ -204,7 +204,9 @@ static u32 ptrace_report_exec(enum utrac
 			      const struct linux_binprm *bprm,
 			      struct pt_regs *regs)
 {
-	if (task->ptrace & PT_TRACE_EXEC)
+	struct ptrace_context *context = ptrace_context(engine);
+
+	if (context->options & PTRACE_O_TRACEEXEC)
 		return utrace_ptrace_event(task, PTRACE_EVENT_EXEC, 0);
 
 	/*
@@ -264,7 +266,7 @@ static u32 ptrace_report_clone(enum utra
 	int event;
 
 	if ((clone_flags & CLONE_VFORK) &&
-	    (parent->ptrace & PT_TRACE_VFORK_DONE)) {
+	    (context->options & PTRACE_O_TRACEVFORKDONE)) {
 		/*
 		 * Stash the child PID for a PTRACE_EVENT_VFORK_DONE report,
 		 * even if we don't report this clone event itself.  Mark
@@ -284,12 +286,12 @@ static u32 ptrace_report_clone(enum utra
 
 	event = 0;
 	if (clone_flags & CLONE_VFORK) {
-		if (parent->ptrace & PT_TRACE_VFORK)
+		if (context->options & PTRACE_O_TRACEVFORK)
 			event = PTRACE_EVENT_VFORK;
 	} else if ((clone_flags & CSIGNAL) != SIGCHLD) {
-		if (parent->ptrace & PT_TRACE_CLONE)
+		if (context->options & PTRACE_O_TRACECLONE)
 			event = PTRACE_EVENT_CLONE;
-	} else if (parent->ptrace & PT_TRACE_FORK) {
+	} else if (context->options & PTRACE_O_TRACEFORK) {
 		event = PTRACE_EVENT_FORK;
 	}
 
@@ -306,10 +308,12 @@ static u32 ptrace_report_clone(enum utra
 	return UTRACE_RESUME;
 }
 
-static u32 ptrace_report_syscall(u32 action, struct task_struct *task)
+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 (task->ptrace & PT_TRACESYSGOOD)
+	if (context->options & PTRACE_O_TRACESYSGOOD)
 		code |= 0x80;
 	return utrace_ptrace_report(action, task, PTRACE_EVENT_SYSCALL, code);
 }
@@ -326,7 +330,7 @@ static u32 ptrace_report_syscall_entry(u
 	if (ptrace_syscall_action(task))
 		return UTRACE_SYSCALL_ABORT | UTRACE_RESUME;
 
-	return ptrace_report_syscall(UTRACE_SYSCALL_RUN, task);
+	return ptrace_report_syscall(UTRACE_SYSCALL_RUN, engine, task);
 }
 
 /*
@@ -364,7 +368,7 @@ static u32 ptrace_report_syscall_exit(en
 		 */
 		user_disable_single_step(task);
 
-	return ptrace_report_syscall(0, task);
+	return ptrace_report_syscall(0, engine, task);
 }
 
 static u32 ptrace_resumed(struct task_struct *task,
@@ -970,6 +974,7 @@ static int ptrace_setsiginfo(struct task
 static int ptrace_resume(struct task_struct *child, long request, long data)
 {
 	struct utrace_engine *engine;
+	struct ptrace_context *context;
 	enum utrace_resume_action action;
 	enum utrace_syscall_action syscall;
 	int ret = 0;
@@ -982,6 +987,8 @@ static int ptrace_resume(struct task_str
 	if (IS_ERR(engine))
 		return -ESRCH;
 
+	context = ptrace_context(engine);
+
 	syscall = UTRACE_SYSCALL_RUN;
 #ifdef PTRACE_SYSEMU
 	if (request == PTRACE_SYSEMU || request == PTRACE_SYSEMU_SINGLESTEP)
@@ -1040,7 +1047,7 @@ static int ptrace_resume(struct task_str
 			 */
 			if (request == PTRACE_SYSCALL) {
 				data = SIGTRAP;
-				if (child->ptrace & PT_TRACESYSGOOD)
+				if (context->options & PTRACE_O_TRACESYSGOOD)
 					data |= 0x80;
 				ptrace_set_stop_event(child,
 						      PTRACE_EVENT_SYSCALL);
@@ -1076,7 +1083,7 @@ static int ptrace_resume(struct task_str
 			 */
 			data = 0;
 			event = 0;
-			if (child->ptrace & PT_TRACE_VFORK_DONE) {
+			if (context->options & PTRACE_O_TRACEVFORKDONE) {
 				ptrace_set_stop_event(child,
 						      PTRACE_EVENT_VFORK);
 				action = UTRACE_REPORT;




More information about the utrace-devel mailing list