lkml.org 
[lkml]   [2007]   [Aug]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH 2/4] posix-timers: fix creation race
From
Date
On Sun, 2007-08-12 at 21:05 +0400, Oleg Nesterov wrote:
> sys_timer_create() sets ->it_process and unlocks ->siglock, then checks
> tmr->it_sigev_notify to define if get_task_struct() is needed.
>
> We already passed ->it_id to the caller, another thread can delete this
> timer and free its memory in between.
>
> As a minimal fix, move this code under ->siglock, sys_timer_delete() takes
> it too before calling release_posix_timer(). A proper serialization would
> be to take ->it_lock, we add a partly initialized timer on posix_timers_id,
> not good.
>
> Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>

Acked-by: Thomas Gleixner <tglx@linutronix.de>

> --- t/kernel/posix-timers.c~2_CREATE 2007-08-12 17:59:17.000000000 +0400
> +++ t/kernel/posix-timers.c 2007-08-12 18:11:33.000000000 +0400
> @@ -547,13 +547,12 @@ sys_timer_create(const clockid_t which_c
> new_timer->it_process = process;
> list_add(&new_timer->list,
> &process->signal->posix_timers);
> - spin_unlock_irqrestore(&process->sighand->siglock, flags);
> if (new_timer->it_sigev_notify == (SIGEV_SIGNAL|SIGEV_THREAD_ID))
> get_task_struct(process);
> } else {
> - spin_unlock_irqrestore(&process->sighand->siglock, flags);
> process = NULL;
> }
> + spin_unlock_irqrestore(&process->sighand->siglock, flags);
> }
> read_unlock(&tasklist_lock);
> if (!process) {
>

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2007-08-12 21:09    [W:0.130 / U:0.324 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site