History

[PATCH] check_process_timers: fix possible lockup

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 next commit) and the 'if (PF_EXITING)' check in arm_timer() is racy (see the one after that).

Oleg Nesterov committed 20 years ago

Commit 8f17fc21 parent 88d11361 file · +4 −5Browse files

Unified · Split

kernel/posix-cpu-timers.c+4−5
@@ -1173,6 +1173,9 @@ static void check_process_timers(struct task_struct *tsk, · 1172 unmodified lines
11731173 }
11741174 t = tsk;
11751175 do {
1176+ if (unlikely(t->flags & PF_EXITING))
1177+ continue;
1178+
11761179 ticks = cputime_add(cputime_add(t->utime, t->stime),
11771180 prof_left);
11781181 if (!cputime_eq(prof_expires, cputime_zero) &&
@@ -1193,11 +1196,7 @@ static void check_process_timers(struct task_struct *tsk, · 14 unmodified lines
11931196 t->it_sched_expires > sched)) {
11941197 t->it_sched_expires = sched;
11951198 }
1196−
1197− do {
1198− t = next_thread(t);
1199− } while (unlikely(t->flags & PF_EXITING));
1200− } while (t != tsk);
1199+ } while ((t = next_thread(t)) != tsk);
12011200 }
12021201 }
12031202

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t