No changes in ptrace.o

- s/context/ctx/

- line up ptrace_context->resume decl

- remove kerneldoc bits from ptrace_traceme(). The comment is
  not very nice, I'd better remove it completely.

---

 kernel/ptrace.c |  192 +++++++++++++++++++++++++++-----------------------------
 1 file changed, 95 insertions(+), 97 deletions(-)

--- PU/kernel/ptrace.c~124_S_CONTEXT_CTX        2009-10-30 04:01:41.000000000 
+0100
+++ PU/kernel/ptrace.c  2009-10-30 04:25:53.000000000 +0100
@@ -56,15 +56,15 @@ void __ptrace_unlink(struct task_struct 
 }
 
 struct ptrace_context {
-       int             options;
+       int                             options;
 
-       int             signr;
-       siginfo_t       *siginfo;
+       int                             signr;
+       siginfo_t                       *siginfo;
 
-       int             stop_code;
-       unsigned long   eventmsg;
+       int                             stop_code;
+       unsigned long                   eventmsg;
 
-       enum utrace_resume_action resume;
+       enum utrace_resume_action       resume;
 };
 
 #define PT_UTRACED                     0x00001000
@@ -78,19 +78,19 @@ struct ptrace_context {
 /* events visible to user-space */
 #define PTRACE_EVENT_MASK              0xFFFF
 
-static inline bool ptrace_event_pending(struct ptrace_context *context)
+static inline bool ptrace_event_pending(struct ptrace_context *ctx)
 {
-       return context->stop_code != 0;
+       return ctx->stop_code != 0;
 }
 
-static inline int get_stop_event(struct ptrace_context *context)
+static inline int get_stop_event(struct ptrace_context *ctx)
 {
-       return context->stop_code >> 8;
+       return ctx->stop_code >> 8;
 }
 
-static inline void set_stop_code(struct ptrace_context *context, int event)
+static inline void set_stop_code(struct ptrace_context *ctx, int event)
 {
-       context->stop_code = (event << 8) | SIGTRAP;
+       ctx->stop_code = (event << 8) | SIGTRAP;
 }
 
 static inline struct ptrace_context *
@@ -111,27 +111,27 @@ static struct utrace_engine *
 ptrace_reuse_engine(struct task_struct *tracee)
 {
        struct utrace_engine *engine;
-       struct ptrace_context *context;
+       struct ptrace_context *ctx;
        int err = -EPERM;
 
        engine = ptrace_lookup_engine(tracee);
        if (IS_ERR(engine))
                return engine;
 
-       context = ptrace_context(engine);
-       if (unlikely(context->resume == UTRACE_DETACH)) {
+       ctx = ptrace_context(engine);
+       if (unlikely(ctx->resume == UTRACE_DETACH)) {
                /*
                 * Try to reuse this self-detaching engine.
                 * The only caller which can hit this case is ptrace_attach(),
                 * it holds ->cred_guard_mutex.
                 */
-               context->options = 0;
-               context->eventmsg = 0;
+               ctx->options = 0;
+               ctx->eventmsg = 0;
 
                /* make sure we don't get unwanted reports */
                err = utrace_set_events(tracee, engine, UTRACE_EVENT(QUIESCE));
                if (!err || err == -EINPROGRESS) {
-                       context->resume = UTRACE_RESUME;
+                       ctx->resume = UTRACE_RESUME;
                        /* synchronize with ptrace_report_signal() */
                        err = utrace_barrier(tracee, engine);
                }
@@ -149,7 +149,7 @@ static struct utrace_engine *
 ptrace_attach_engine(struct task_struct *tracee)
 {
        struct utrace_engine *engine;
-       struct ptrace_context *context;
+       struct ptrace_context *ctx;
 
        if (unlikely(task_utrace_flags(tracee))) {
                engine = ptrace_reuse_engine(tracee);
@@ -157,21 +157,21 @@ ptrace_attach_engine(struct task_struct 
                        return engine;
        }
 
-       context = kzalloc(sizeof(*context), GFP_KERNEL);
-       if (unlikely(!context))
+       ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
+       if (unlikely(!ctx))
                return ERR_PTR(-ENOMEM);
 
-       context->resume = UTRACE_RESUME;
+       ctx->resume = UTRACE_RESUME;
 
        engine = utrace_attach_task(tracee, UTRACE_ATTACH_CREATE |
                                                UTRACE_ATTACH_EXCLUSIVE |
                                                UTRACE_ATTACH_MATCH_OPS,
-                                               &ptrace_utrace_ops, context);
+                                               &ptrace_utrace_ops, ctx);
        if (unlikely(IS_ERR(engine))) {
                if (engine != ERR_PTR(-ESRCH) &&
                    engine != ERR_PTR(-ERESTARTNOINTR))
                        engine = ERR_PTR(-EPERM);
-               kfree(context);
+               kfree(ctx);
        }
 
        return engine;
@@ -181,7 +181,7 @@ static inline int ptrace_set_events(stru
                                        struct utrace_engine *engine,
                                        unsigned long options)
 {
-       struct ptrace_context *context = ptrace_context(engine);
+       struct ptrace_context *ctx = ptrace_context(engine);
        /*
         * We need QUIESCE for resume handling, CLONE to check
         * for CLONE_PTRACE, other events are always reported.
@@ -189,7 +189,7 @@ static inline int ptrace_set_events(stru
        unsigned long events = UTRACE_EVENT(QUIESCE) | UTRACE_EVENT(CLONE) |
                               UTRACE_EVENT(EXEC) | UTRACE_EVENT_SIGNAL_ALL;
 
-       context->options = options;
+       ctx->options = options;
        if (options & PTRACE_O_TRACEEXIT)
                events |= UTRACE_EVENT(EXIT);
 
@@ -255,9 +255,9 @@ static void ptrace_detach_task(struct ta
                return;
 
        if (sig) {
-               struct ptrace_context *context = ptrace_context(engine);
+               struct ptrace_context *ctx = ptrace_context(engine);
 
-               switch (get_stop_event(context)) {
+               switch (get_stop_event(ctx)) {
                case PTRACE_EVENT_SYSCALL_ENTRY:
                case PTRACE_EVENT_SYSCALL_EXIT:
                        if (voluntary)
@@ -266,8 +266,8 @@ static void ptrace_detach_task(struct ta
 
                case PTRACE_EVENT_SIGNAL:
                        if (voluntary)
-                               context->signr = sig;
-                       context->resume = UTRACE_DETACH;
+                               ctx->signr = sig;
+                       ctx->resume = UTRACE_DETACH;
                        action = UTRACE_RESUME;
                        break;
                }
@@ -287,13 +287,13 @@ static u32 ptrace_report_exit(enum utrac
                              struct task_struct *task,
                              long orig_code, long *code)
 {
-       struct ptrace_context *context = ptrace_context(engine);
+       struct ptrace_context *ctx = ptrace_context(engine);
 
-       WARN_ON(ptrace_event_pending(context) &&
+       WARN_ON(ptrace_event_pending(ctx) &&
                        !signal_group_exit(task->signal));
 
-       set_stop_code(context, PTRACE_EVENT_EXIT);
-       context->eventmsg = *code;
+       set_stop_code(ctx, PTRACE_EVENT_EXIT);
+       ctx->eventmsg = *code;
 
        return UTRACE_STOP;
 }
@@ -333,22 +333,22 @@ static u32 ptrace_report_clone(enum utra
                               unsigned long clone_flags,
                               struct task_struct *child)
 {
-       struct ptrace_context *context = ptrace_context(engine);
+       struct ptrace_context *ctx = ptrace_context(engine);
        int event = 0;
 
-       WARN_ON(ptrace_event_pending(context));
+       WARN_ON(ptrace_event_pending(ctx));
 
        if (clone_flags & CLONE_UNTRACED) {
                /* no events reported */
        } else if (clone_flags & CLONE_VFORK) {
-               if (context->options & PTRACE_O_TRACEVFORK)
+               if (ctx->options & PTRACE_O_TRACEVFORK)
                        event = PTRACE_EVENT_VFORK;
-               else if (context->options & PTRACE_O_TRACEVFORKDONE)
+               else if (ctx->options & PTRACE_O_TRACEVFORKDONE)
                        event = PTRACE_EVENT_VFORK_DONE;
        } else if ((clone_flags & CSIGNAL) != SIGCHLD) {
-               if (context->options & PTRACE_O_TRACECLONE)
+               if (ctx->options & PTRACE_O_TRACECLONE)
                        event = PTRACE_EVENT_CLONE;
-       } else if (context->options & PTRACE_O_TRACEFORK) {
+       } else if (ctx->options & PTRACE_O_TRACEFORK) {
                event = PTRACE_EVENT_FORK;
        }
        /*
@@ -357,13 +357,13 @@ static u32 ptrace_report_clone(enum utra
         */
        if ((event && event != PTRACE_EVENT_VFORK_DONE) ||
                                (clone_flags & CLONE_PTRACE))
-               ptrace_clone_attach(parent, child, context->options);
+               ptrace_clone_attach(parent, child, ctx->options);
 
        if (!event)
                return UTRACE_RESUME;
 
-       set_stop_code(context, event);
-       context->eventmsg = child->pid;
+       set_stop_code(ctx, event);
+       ctx->eventmsg = child->pid;
        /*
         * We shouldn't stop now, inside the do_fork() path.
         * We will stop later, before return to user-mode.
@@ -374,11 +374,11 @@ static u32 ptrace_report_clone(enum utra
                return UTRACE_STOP;
 }
 
-static inline void set_syscall_code(struct ptrace_context *context, int event)
+static inline void set_syscall_code(struct ptrace_context *ctx, int event)
 {
-       set_stop_code(context, event);
-       if (context->options & PTRACE_O_TRACESYSGOOD)
-               context->stop_code |= 0x80;
+       set_stop_code(ctx, event);
+       if (ctx->options & PTRACE_O_TRACESYSGOOD)
+               ctx->stop_code |= 0x80;
 }
 
 static u32 ptrace_report_syscall_entry(u32 action,
@@ -386,13 +386,13 @@ static u32 ptrace_report_syscall_entry(u
                                       struct task_struct *task,
                                       struct pt_regs *regs)
 {
-       struct ptrace_context *context = ptrace_context(engine);
+       struct ptrace_context *ctx = ptrace_context(engine);
 
-       WARN_ON(ptrace_event_pending(context));
+       WARN_ON(ptrace_event_pending(ctx));
 
-       set_syscall_code(context, PTRACE_EVENT_SYSCALL_ENTRY);
+       set_syscall_code(ctx, PTRACE_EVENT_SYSCALL_ENTRY);
 
-       if (unlikely(context->options & PTRACE_O_SYSEMU)) {
+       if (unlikely(ctx->options & PTRACE_O_SYSEMU)) {
                if (test_thread_flag(TIF_SINGLESTEP))
                        user_disable_single_step(task);
                return UTRACE_SYSCALL_ABORT | UTRACE_REPORT;
@@ -405,12 +405,12 @@ static u32 ptrace_report_syscall_exit(en
                                      struct task_struct *task,
                                      struct pt_regs *regs)
 {
-       struct ptrace_context *context = ptrace_context(engine);
+       struct ptrace_context *ctx = ptrace_context(engine);
 
-       if (ptrace_event_pending(context))
+       if (ptrace_event_pending(ctx))
                return UTRACE_STOP;
 
-       set_syscall_code(context, PTRACE_EVENT_SYSCALL_EXIT);
+       set_syscall_code(ctx, PTRACE_EVENT_SYSCALL_EXIT);
 
        return UTRACE_STOP;
 }
@@ -422,11 +422,11 @@ static u32 ptrace_report_exec(enum utrac
                              const struct linux_binprm *bprm,
                              struct pt_regs *regs)
 {
-       struct ptrace_context *context = ptrace_context(engine);
+       struct ptrace_context *ctx = ptrace_context(engine);
 
-       WARN_ON(ptrace_event_pending(context));
+       WARN_ON(ptrace_event_pending(ctx));
 
-       if (!(context->options & PTRACE_O_TRACEEXEC)) {
+       if (!(ctx->options & PTRACE_O_TRACEEXEC)) {
                /*
                 * Old-fashioned ptrace'd exec just posts a plain signal.
                 */
@@ -434,7 +434,7 @@ static u32 ptrace_report_exec(enum utrac
                return UTRACE_RESUME;
        }
 
-       set_stop_code(context, PTRACE_EVENT_EXEC);
+       set_stop_code(ctx, PTRACE_EVENT_EXEC);
 
        return UTRACE_STOP;
 }
@@ -480,10 +480,10 @@ static u32 ptrace_report_signal(u32 acti
                                const struct k_sigaction *orig_ka,
                                struct k_sigaction *return_ka)
 {
-       struct ptrace_context *context = ptrace_context(engine);
-       enum utrace_resume_action resume = context->resume;
+       struct ptrace_context *ctx = ptrace_context(engine);
+       enum utrace_resume_action resume = ctx->resume;
 
-       if (ptrace_event_pending(context)) {
+       if (ptrace_event_pending(ctx)) {
                action = utrace_signal_action(action);
                WARN_ON(action != UTRACE_SIGNAL_REPORT);
                return action | UTRACE_STOP;
@@ -491,36 +491,36 @@ static u32 ptrace_report_signal(u32 acti
 
        switch (utrace_signal_action(action)) {
        case UTRACE_SIGNAL_HANDLER:
-               if (WARN_ON(context->siginfo))
-                       context->siginfo = NULL;
+               if (WARN_ON(ctx->siginfo))
+                       ctx->siginfo = NULL;
 
                if (resume != UTRACE_RESUME) {
-                       set_stop_code(context, PTRACE_EVENT_SIGTRAP);
+                       set_stop_code(ctx, PTRACE_EVENT_SIGTRAP);
                        return UTRACE_STOP | UTRACE_SIGNAL_IGN;
                }
 
        case UTRACE_SIGNAL_REPORT:
-               if (!context->siginfo)
+               if (!ctx->siginfo)
                        return resume | UTRACE_SIGNAL_IGN;
 
-               if (WARN_ON(context->siginfo != info))
+               if (WARN_ON(ctx->siginfo != info))
                        return resume | UTRACE_SIGNAL_IGN;
-               context->siginfo = NULL;
+               ctx->siginfo = NULL;
 
-               return resume | resume_signal(task, context->signr,
+               return resume | resume_signal(task, ctx->signr,
                                                info, return_ka);
        default:
-               WARN_ON(context->siginfo);
-               context->siginfo = info;
+               WARN_ON(ctx->siginfo);
+               ctx->siginfo = info;
                /*
-                * context->siginfo points to the caller's stack.
+                * ctx->siginfo points to the caller's stack.
                 * Make sure the subsequent UTRACE_SIGNAL_REPORT clears
                 * ->siginfo before return from get_signal_to_deliver().
                 */
                utrace_control(task, engine, UTRACE_INTERRUPT);
 
-               context->stop_code = (PTRACE_EVENT_SIGNAL << 8) | 
info->si_signo;
-               context->signr   = info->si_signo;
+               ctx->stop_code = (PTRACE_EVENT_SIGNAL << 8) | info->si_signo;
+               ctx->signr   = info->si_signo;
 
                return UTRACE_STOP | UTRACE_SIGNAL_IGN;
        }
@@ -531,12 +531,12 @@ static u32 ptrace_report_quiesce(u32 act
                                 struct task_struct *task,
                                 unsigned long event)
 {
-       struct ptrace_context *context = ptrace_context(engine);
+       struct ptrace_context *ctx = ptrace_context(engine);
 
-       if (ptrace_event_pending(context))
+       if (ptrace_event_pending(ctx))
                return UTRACE_STOP;
 
-       return event ? UTRACE_RESUME : context->resume;
+       return event ? UTRACE_RESUME : ctx->resume;
 }
 
 static void ptrace_release(void *data)
@@ -638,9 +638,7 @@ out:
        return retval;
 }
 
-/**
- * ptrace_traceme  --  helper for PTRACE_TRACEME
- *
+/*
  * Performs checks and sets PT_UTRACED.
  * Should be used by all ptrace implementations for PTRACE_TRACEME.
  */
@@ -737,13 +735,13 @@ static int ptrace_set_options(struct tas
 }
 
 static int ptrace_rw_siginfo(struct task_struct *tracee,
-                               struct ptrace_context *context,
+                               struct ptrace_context *ctx,
                                siginfo_t *info, bool write)
 {
        unsigned long flags;
        int err;
 
-       switch (get_stop_event(context)) {
+       switch (get_stop_event(ctx)) {
        case 0: /* jctl stop */
                return -EINVAL;
 
@@ -752,9 +750,9 @@ static int ptrace_rw_siginfo(struct task
                if (lock_task_sighand(tracee, &flags)) {
                        if (likely(task_is_traced(tracee))) {
                                if (write)
-                                       *context->siginfo = *info;
+                                       *ctx->siginfo = *info;
                                else
-                                       *info = *context->siginfo;
+                                       *info = *ctx->siginfo;
                                err = 0;
                        }
                        unlock_task_sighand(tracee, &flags);
@@ -766,7 +764,7 @@ static int ptrace_rw_siginfo(struct task
                if (!write) {
                        memset(info, 0, sizeof(*info));
                        info->si_signo = SIGTRAP;
-                       info->si_code = context->stop_code & PTRACE_EVENT_MASK;
+                       info->si_code = ctx->stop_code & PTRACE_EVENT_MASK;
                        info->si_pid = task_pid_vnr(tracee);
                        info->si_uid = task_uid(tracee);
                }
@@ -775,7 +773,7 @@ static int ptrace_rw_siginfo(struct task
        }
 }
 
-static void do_ptrace_notify_stop(struct ptrace_context *context,
+static void do_ptrace_notify_stop(struct ptrace_context *ctx,
                                        struct task_struct *tracee)
 {
        /*
@@ -784,7 +782,7 @@ static void do_ptrace_notify_stop(struct
         * for wait_task_stopped()->task_stopped_code(), we should
         * change it to use ptrace_context.
         */
-       tracee->exit_code = context->stop_code & PTRACE_EVENT_MASK;
+       tracee->exit_code = ctx->stop_code & PTRACE_EVENT_MASK;
        WARN_ON(!tracee->exit_code);
 
        read_lock(&tasklist_lock);
@@ -817,11 +815,11 @@ void ptrace_notify_stop(struct task_stru
 static int ptrace_resume_action(struct task_struct *tracee,
                                struct utrace_engine *engine, long request)
 {
-       struct ptrace_context *context = ptrace_context(engine);
+       struct ptrace_context *ctx = ptrace_context(engine);
        unsigned long events;
        int action;
 
-       context->options &= ~PTRACE_O_SYSEMU;
+       ctx->options &= ~PTRACE_O_SYSEMU;
        events = engine->flags & ~UTRACE_EVENT_SYSCALL;
        action = UTRACE_RESUME;
 
@@ -848,7 +846,7 @@ static int ptrace_resume_action(struct t
                        return -EIO;
                action = UTRACE_SINGLESTEP;
        case PTRACE_SYSEMU:
-               context->options |= PTRACE_O_SYSEMU;
+               ctx->options |= PTRACE_O_SYSEMU;
                events |= UTRACE_EVENT(SYSCALL_ENTRY);
                break;
 #endif
@@ -869,7 +867,7 @@ static int ptrace_resume(struct task_str
                                struct utrace_engine *engine,
                                long request, long data)
 {
-       struct ptrace_context *context = ptrace_context(engine);
+       struct ptrace_context *ctx = ptrace_context(engine);
        int action;
 
        if (!valid_signal(data))
@@ -879,10 +877,10 @@ static int ptrace_resume(struct task_str
        if (action < 0)
                return action;
 
-       switch (get_stop_event(context)) {
+       switch (get_stop_event(ctx)) {
        case PTRACE_EVENT_VFORK:
-               if (context->options & PTRACE_O_TRACEVFORKDONE) {
-                       set_stop_code(context, PTRACE_EVENT_VFORK_DONE);
+               if (ctx->options & PTRACE_O_TRACEVFORKDONE) {
+                       set_stop_code(ctx, PTRACE_EVENT_VFORK_DONE);
                        action = UTRACE_REPORT;
                }
                break;
@@ -892,8 +890,8 @@ static int ptrace_resume(struct task_str
        case PTRACE_EVENT_CLONE:
        case PTRACE_EVENT_VFORK_DONE:
                if (request == PTRACE_SYSCALL) {
-                       set_syscall_code(context, PTRACE_EVENT_SYSCALL_EXIT);
-                       do_ptrace_notify_stop(context, tracee);
+                       set_syscall_code(ctx, PTRACE_EVENT_SYSCALL_EXIT);
+                       do_ptrace_notify_stop(ctx, tracee);
                        return 0;
                }
                /* fallthrough, but suppress send_sig_info() below */
@@ -916,11 +914,11 @@ static int ptrace_resume(struct task_str
                break;
 
        case PTRACE_EVENT_SIGNAL:
-               context->signr = data;
+               ctx->signr = data;
                break;
        }
 
-       context->resume = action;
+       ctx->resume = action;
        ptrace_wake_up(tracee, engine, action, true);
        return 0;
 }

Reply via email to