Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 24556
b: refs/heads/master
c: f63ee72
h: refs/heads/master
v: v3
  • Loading branch information
Oleg Nesterov authored and Linus Torvalds committed Mar 29, 2006
1 parent f0639ec commit e71e27f
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 15 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: aa1757f90bea3f598b6e5d04d922a6a60200f1da
refs/heads/master: f63ee72e0fb82e504a0489490babc7612c7cd6c2
9 changes: 9 additions & 0 deletions trunk/include/linux/sched.h
Original file line number Diff line number Diff line change
Expand Up @@ -1225,6 +1225,15 @@ static inline void task_unlock(struct task_struct *p)
spin_unlock(&p->alloc_lock);
}

extern struct sighand_struct *lock_task_sighand(struct task_struct *tsk,
unsigned long *flags);

static inline void unlock_task_sighand(struct task_struct *tsk,
unsigned long *flags)
{
spin_unlock_irqrestore(&tsk->sighand->siglock, *flags);
}

#ifndef __HAVE_THREAD_FUNCTIONS

#define task_thread_info(task) (task)->thread_info
Expand Down
38 changes: 24 additions & 14 deletions trunk/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -1120,27 +1120,37 @@ void zap_other_threads(struct task_struct *p)
/*
* Must be called under rcu_read_lock() or with tasklist_lock read-held.
*/
struct sighand_struct *lock_task_sighand(struct task_struct *tsk, unsigned long *flags)
{
struct sighand_struct *sighand;

for (;;) {
sighand = rcu_dereference(tsk->sighand);
if (unlikely(sighand == NULL))
break;

spin_lock_irqsave(&sighand->siglock, *flags);
if (likely(sighand == tsk->sighand))
break;
spin_unlock_irqrestore(&sighand->siglock, *flags);
}

return sighand;
}

int group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
{
unsigned long flags;
struct sighand_struct *sp;
int ret;

retry:
ret = check_kill_permission(sig, info, p);
if (!ret && sig && (sp = rcu_dereference(p->sighand))) {
spin_lock_irqsave(&sp->siglock, flags);
if (p->sighand != sp) {
spin_unlock_irqrestore(&sp->siglock, flags);
goto retry;
}
if ((atomic_read(&sp->count) == 0) ||
(atomic_read(&p->usage) == 0)) {
spin_unlock_irqrestore(&sp->siglock, flags);
return -ESRCH;

if (!ret && sig) {
ret = -ESRCH;
if (lock_task_sighand(p, &flags)) {
ret = __group_send_sig_info(sig, info, p);
unlock_task_sighand(p, &flags);
}
ret = __group_send_sig_info(sig, info, p);
spin_unlock_irqrestore(&sp->siglock, flags);
}

return ret;
Expand Down

0 comments on commit e71e27f

Please sign in to comment.