Skip to content

Commit

Permalink
ptrace: don't take tasklist to get/set ->last_siginfo
Browse files Browse the repository at this point in the history
Change ptrace_getsiginfo/ptrace_setsiginfo to use lock_task_sighand()
without tasklist_lock.  Perhaps it makes sense to make a single helper
with "bool rw" argument.

Signed-off-by: Oleg Nesterov <[email protected]>
Acked-by: Roland McGrath <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
oleg-nesterov authored and torvalds committed Jun 18, 2009
1 parent d926566 commit e496125
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions kernel/ptrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -424,37 +424,33 @@ static int ptrace_setoptions(struct task_struct *child, long data)

static int ptrace_getsiginfo(struct task_struct *child, siginfo_t *info)
{
unsigned long flags;
int error = -ESRCH;

read_lock(&tasklist_lock);
if (likely(child->sighand != NULL)) {
if (lock_task_sighand(child, &flags)) {
error = -EINVAL;
spin_lock_irq(&child->sighand->siglock);
if (likely(child->last_siginfo != NULL)) {
*info = *child->last_siginfo;
error = 0;
}
spin_unlock_irq(&child->sighand->siglock);
unlock_task_sighand(child, &flags);
}
read_unlock(&tasklist_lock);
return error;
}

static int ptrace_setsiginfo(struct task_struct *child, const siginfo_t *info)
{
unsigned long flags;
int error = -ESRCH;

read_lock(&tasklist_lock);
if (likely(child->sighand != NULL)) {
if (lock_task_sighand(child, &flags)) {
error = -EINVAL;
spin_lock_irq(&child->sighand->siglock);
if (likely(child->last_siginfo != NULL)) {
*child->last_siginfo = *info;
error = 0;
}
spin_unlock_irq(&child->sighand->siglock);
unlock_task_sighand(child, &flags);
}
read_unlock(&tasklist_lock);
return error;
}

Expand Down

0 comments on commit e496125

Please sign in to comment.