Skip to content

Commit

Permalink
freezer: fix PF_NOFREEZE vs freezeable race
Browse files Browse the repository at this point in the history
This patch fixes the race pointed out by Oleg Nesterov.

* Freezer marks a thread as freezeable.
* The thread now marks itself PF_NOFREEZE, but it will be frozen on
  on calling try_to_freeze(). Thus the task is frozen, even though it doesn't
  want to.
* Subsequent thaw_processes() will also fail to thaw the task since it is
  marked PF_NOFREEZE.

Avoid this problem by checking the task's PF_NOFREEZE status in
frozen_processes() before marking the task as frozen.

Signed-off-by: Gautham R Shenoy <ego@in.ibm.com>
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Cc: Oleg Nesterov <oleg@tv-sign.ru>
Cc: Pavel Machek <pavel@ucw.cz>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Gautham R Shenoy authored and Linus Torvalds committed May 24, 2007
1 parent a076e4b commit 5fcc57f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions include/linux/freezer.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,10 @@ static inline int thaw_process(struct task_struct *p)
*/
static inline void frozen_process(struct task_struct *p)
{
p->flags |= PF_FROZEN;
wmb();
if (!unlikely(p->flags & PF_NOFREEZE)) {
p->flags |= PF_FROZEN;
wmb();
}
clear_tsk_thread_flag(p, TIF_FREEZE);
}

Expand Down

0 comments on commit 5fcc57f

Please sign in to comment.