Skip to content

Commit

Permalink
posix-timers: don't switch to ->group_leader if ->it_process dies
Browse files Browse the repository at this point in the history
posix_timer_event() drops SIGEV_THREAD_ID and switches to ->group_leader
if send_sigqueue() fails.

This is not very useful and doesn't work reliably.  send_sigqueue() can
only fail if ->it_process is dead.  But it can die before it dequeues the
SI_TIMER signal, in that case the timer stops anyway.

Remove this code.  I guess it was needed a long ago to ensure that the
timer is not destroyed when when its creator thread dies.

Q: perhaps it makes sense to change sys_timer_settime() to return an error
if ->it_process is dead?

Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>
Cc: mingo@elte.hu
Cc: Roland McGrath <roland@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
  • Loading branch information
Oleg Nesterov authored and Thomas Gleixner committed Sep 24, 2008
1 parent bb34d92 commit 4aa7361
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions kernel/posix-timers.c
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ void do_schedule_next_timer(struct siginfo *info)

int posix_timer_event(struct k_itimer *timr, int si_private)
{
int shared, ret;
/*
* FIXME: if ->sigq is queued we can race with
* dequeue_signal()->do_schedule_next_timer().
Expand All @@ -316,20 +317,10 @@ int posix_timer_event(struct k_itimer *timr, int si_private)
timr->sigq->info.si_tid = timr->it_id;
timr->sigq->info.si_value = timr->it_sigev_value;

if (timr->it_sigev_notify & SIGEV_THREAD_ID) {
struct task_struct *leader;
int ret = send_sigqueue(timr->sigq, timr->it_process, 0);

if (likely(ret >= 0))
return ret;

timr->it_sigev_notify = SIGEV_SIGNAL;
leader = timr->it_process->group_leader;
put_task_struct(timr->it_process);
timr->it_process = leader;
}

return send_sigqueue(timr->sigq, timr->it_process, 1);
shared = !(timr->it_sigev_notify & SIGEV_THREAD_ID);
ret = send_sigqueue(timr->sigq, timr->it_process, shared);
/* If we failed to send the signal the timer stops. */
return ret > 0;
}
EXPORT_SYMBOL_GPL(posix_timer_event);

Expand Down

0 comments on commit 4aa7361

Please sign in to comment.