提交 e4961254 编写于 作者: O Oleg Nesterov 提交者: Linus Torvalds

ptrace: don't take tasklist to get/set ->last_siginfo

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: NOleg Nesterov <oleg@redhat.com>
Acked-by: NRoland McGrath <roland@redhat.com>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 d9265663
...@@ -424,37 +424,33 @@ static int ptrace_setoptions(struct task_struct *child, long data) ...@@ -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) static int ptrace_getsiginfo(struct task_struct *child, siginfo_t *info)
{ {
unsigned long flags;
int error = -ESRCH; int error = -ESRCH;
read_lock(&tasklist_lock); if (lock_task_sighand(child, &flags)) {
if (likely(child->sighand != NULL)) {
error = -EINVAL; error = -EINVAL;
spin_lock_irq(&child->sighand->siglock);
if (likely(child->last_siginfo != NULL)) { if (likely(child->last_siginfo != NULL)) {
*info = *child->last_siginfo; *info = *child->last_siginfo;
error = 0; error = 0;
} }
spin_unlock_irq(&child->sighand->siglock); unlock_task_sighand(child, &flags);
} }
read_unlock(&tasklist_lock);
return error; return error;
} }
static int ptrace_setsiginfo(struct task_struct *child, const siginfo_t *info) static int ptrace_setsiginfo(struct task_struct *child, const siginfo_t *info)
{ {
unsigned long flags;
int error = -ESRCH; int error = -ESRCH;
read_lock(&tasklist_lock); if (lock_task_sighand(child, &flags)) {
if (likely(child->sighand != NULL)) {
error = -EINVAL; error = -EINVAL;
spin_lock_irq(&child->sighand->siglock);
if (likely(child->last_siginfo != NULL)) { if (likely(child->last_siginfo != NULL)) {
*child->last_siginfo = *info; *child->last_siginfo = *info;
error = 0; error = 0;
} }
spin_unlock_irq(&child->sighand->siglock); unlock_task_sighand(child, &flags);
} }
read_unlock(&tasklist_lock);
return error; return error;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册