* [PATCH 1/3] check_process_timers: fix possible lockup
@ 2006-06-15 16:11 Oleg Nesterov
2006-06-15 19:56 ` john stultz
0 siblings, 1 reply; 2+ messages in thread
From: Oleg Nesterov @ 2006-06-15 16:11 UTC (permalink / raw)
To: Linus Torvalds, Andrew Morton, john stultz
Cc: Roland McGrath, Thomas Gleixner, Ingo Molnar, Steven Rostedt,
Chris Wright, linux-kernel
If the local timer interrupt happens just after do_exit() sets PF_EXITING
(and before it clears ->it_xxx_expires) run_posix_cpu_timers() will call
check_process_timers() with tasklist_lock + ->siglock held and
check_process_timers:
t = tsk;
do {
....
do {
t = next_thread(t);
} while (unlikely(t->flags & PF_EXITING));
} while (t != tsk);
the outer loop will never stop.
Actually, the window is bigger. Another process can attach the timer after
->it_xxx_expires was cleared (see the patch 2/3) and the 'if (PF_EXITING)'
check in arm_timer() is racy (see the patch 3/3).
Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>
--- 2.6.17-rc6/kernel/posix-cpu-timers.c~1_CPT 2006-06-15 17:59:15.000000000 +0400
+++ 2.6.17-rc6/kernel/posix-cpu-timers.c 2006-06-15 18:01:57.000000000 +0400
@@ -1173,6 +1173,9 @@ static void check_process_timers(struct
}
t = tsk;
do {
+ if (unlikely(t->flags & PF_EXITING))
+ continue;
+
ticks = cputime_add(cputime_add(t->utime, t->stime),
prof_left);
if (!cputime_eq(prof_expires, cputime_zero) &&
@@ -1193,11 +1196,7 @@ static void check_process_timers(struct
t->it_sched_expires > sched)) {
t->it_sched_expires = sched;
}
-
- do {
- t = next_thread(t);
- } while (unlikely(t->flags & PF_EXITING));
- } while (t != tsk);
+ } while ((t = next_thread(t)) != tsk);
}
}
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH 1/3] check_process_timers: fix possible lockup
2006-06-15 16:11 [PATCH 1/3] check_process_timers: fix possible lockup Oleg Nesterov
@ 2006-06-15 19:56 ` john stultz
0 siblings, 0 replies; 2+ messages in thread
From: john stultz @ 2006-06-15 19:56 UTC (permalink / raw)
To: Oleg Nesterov
Cc: Linus Torvalds, Andrew Morton, Roland McGrath, Thomas Gleixner,
Ingo Molnar, Steven Rostedt, Chris Wright, linux-kernel
On Thu, 2006-06-15 at 20:11 +0400, Oleg Nesterov wrote:
> If the local timer interrupt happens just after do_exit() sets PF_EXITING
> (and before it clears ->it_xxx_expires) run_posix_cpu_timers() will call
> check_process_timers() with tasklist_lock + ->siglock held and
>
> check_process_timers:
>
> t = tsk;
> do {
> ....
>
> do {
> t = next_thread(t);
> } while (unlikely(t->flags & PF_EXITING));
> } while (t != tsk);
>
> the outer loop will never stop.
I believe we've hit the same issue here in the -RT tree.
> Actually, the window is bigger. Another process can attach the timer after
> ->it_xxx_expires was cleared (see the patch 2/3) and the 'if (PF_EXITING)'
> check in arm_timer() is racy (see the patch 3/3).
>
> Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>
>
> --- 2.6.17-rc6/kernel/posix-cpu-timers.c~1_CPT 2006-06-15 17:59:15.000000000 +0400
> +++ 2.6.17-rc6/kernel/posix-cpu-timers.c 2006-06-15 18:01:57.000000000 +0400
> @@ -1173,6 +1173,9 @@ static void check_process_timers(struct
> }
> t = tsk;
> do {
> + if (unlikely(t->flags & PF_EXITING))
> + continue;
> +
> ticks = cputime_add(cputime_add(t->utime, t->stime),
> prof_left);
> if (!cputime_eq(prof_expires, cputime_zero) &&
> @@ -1193,11 +1196,7 @@ static void check_process_timers(struct
> t->it_sched_expires > sched)) {
> t->it_sched_expires = sched;
> }
> -
> - do {
> - t = next_thread(t);
> - } while (unlikely(t->flags & PF_EXITING));
> - } while (t != tsk);
> + } while ((t = next_thread(t)) != tsk);
> }
> }
This looks equivalent to the fix in -RT.
thanks
-john
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2006-06-15 19:56 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-06-15 16:11 [PATCH 1/3] check_process_timers: fix possible lockup Oleg Nesterov
2006-06-15 19:56 ` john stultz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®