Oleg Nesterov a69ac4a78d [PATCH] posix-timers: fix posix_cpu_timer_set() vs run_posix_cpu_timers() race
This might be harmless, but looks like a race from code inspection (I
was unable to trigger it).  I must admit, I don't understand why we
can't return TIMER_RETRY after 'spin_unlock(&p->sighand->siglock)'
without doing bump_cpu_timer(), but this is what original code does.

posix_cpu_timer_set:

	read_lock(&tasklist_lock);

	spin_lock(&p->sighand->siglock);
	list_del_init(&timer->it.cpu.entry);
	spin_unlock(&p->sighand->siglock);

We are probaly deleting the timer from run_posix_cpu_timers's 'firing'
local list_head while run_posix_cpu_timers() does list_for_each_safe.

Various bad things can happen, for example we can just delete this timer
so that list_for_each() will not notice it and run_posix_cpu_timers()
will not reset '->firing' flag. In that case,

	....

	if (timer->it.cpu.firing) {
		read_unlock(&tasklist_lock);
		timer->it.cpu.firing = -1;
		return TIMER_RETRY;
	}

sys_timer_settime() goes to 'retry:', calls posix_cpu_timer_set() again,
it returns TIMER_RETRY ...

Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-10-24 08:13:14 -07:00
..
2005-09-10 10:06:26 -07:00
2005-10-08 15:00:57 -07:00
2005-04-16 15:20:36 -07:00
2005-06-25 16:24:29 -07:00
2005-04-16 15:20:36 -07:00
2005-04-16 15:20:36 -07:00
2005-04-16 15:20:36 -07:00
2005-09-07 16:57:33 -07:00
2005-07-27 16:25:51 -07:00
2005-06-28 14:53:40 -07:00
2005-10-08 15:00:57 -07:00
2005-09-10 10:06:21 -07:00
2005-04-16 15:20:36 -07:00
2005-09-21 10:11:54 -07:00
2005-07-07 18:23:46 -07:00
2005-09-07 16:57:45 -07:00
2005-09-13 09:59:04 -07:00
2005-04-16 15:20:36 -07:00
2005-09-07 16:57:17 -07:00
2005-09-10 10:06:21 -07:00
2005-08-01 10:03:56 -07:00
2005-08-29 16:01:32 -07:00
2005-04-16 15:20:36 -07:00
2005-07-12 20:38:38 -07:00
2005-04-16 15:20:36 -07:00
2005-09-07 16:57:45 -07:00