Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 256833
b: refs/heads/master
c: 755e276
h: refs/heads/master
i:
  256831: 7867b8a
v: v3
  • Loading branch information
Tejun Heo authored and Oleg Nesterov committed Jun 4, 2011
1 parent 5a91065 commit 4500209
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: a8f072c1d624a627b67f2ace2f0c25d856ef4e54
refs/heads/master: 755e276b3326f300585435d2f3876e66e248c476
2 changes: 1 addition & 1 deletion trunk/include/linux/ptrace.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ extern long arch_ptrace(struct task_struct *child, long request,
extern int ptrace_readdata(struct task_struct *tsk, unsigned long src, char __user *dst, int len);
extern int ptrace_writedata(struct task_struct *tsk, char __user *src, unsigned long dst, int len);
extern void ptrace_disable(struct task_struct *);
extern int ptrace_check_attach(struct task_struct *task, int kill);
extern int ptrace_check_attach(struct task_struct *task, bool ignore_state);
extern int ptrace_request(struct task_struct *child, long request,
unsigned long addr, unsigned long data);
extern void ptrace_notify(int exit_code);
Expand Down
24 changes: 19 additions & 5 deletions trunk/kernel/ptrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,24 @@ void __ptrace_unlink(struct task_struct *child)
spin_unlock(&child->sighand->siglock);
}

/*
* Check that we have indeed attached to the thing..
/**
* ptrace_check_attach - check whether ptracee is ready for ptrace operation
* @child: ptracee to check for
* @ignore_state: don't check whether @child is currently %TASK_TRACED
*
* Check whether @child is being ptraced by %current and ready for further
* ptrace operations. If @ignore_state is %false, @child also should be in
* %TASK_TRACED state and on return the child is guaranteed to be traced
* and not executing. If @ignore_state is %true, @child can be in any
* state.
*
* CONTEXT:
* Grabs and releases tasklist_lock and @child->sighand->siglock.
*
* RETURNS:
* 0 on success, -ESRCH if %child is not ready.
*/
int ptrace_check_attach(struct task_struct *child, int kill)
int ptrace_check_attach(struct task_struct *child, bool ignore_state)
{
int ret = -ESRCH;

Expand All @@ -119,13 +133,13 @@ int ptrace_check_attach(struct task_struct *child, int kill)
*/
spin_lock_irq(&child->sighand->siglock);
WARN_ON_ONCE(task_is_stopped(child));
if (task_is_traced(child) || kill)
if (task_is_traced(child) || ignore_state)
ret = 0;
spin_unlock_irq(&child->sighand->siglock);
}
read_unlock(&tasklist_lock);

if (!ret && !kill)
if (!ret && !ignore_state)
ret = wait_task_inactive(child, TASK_TRACED) ? 0 : -ESRCH;

/* All systems go.. */
Expand Down

0 comments on commit 4500209

Please sign in to comment.