Commit 5fcc57f2 authored by Gautham R Shenoy's avatar Gautham R Shenoy Committed by Linus Torvalds

freezer: fix PF_NOFREEZE vs freezeable race

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: default avatarGautham R Shenoy <ego@in.ibm.com>
Signed-off-by: default avatarRafael 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: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent a076e4bc
...@@ -63,8 +63,10 @@ static inline int thaw_process(struct task_struct *p) ...@@ -63,8 +63,10 @@ static inline int thaw_process(struct task_struct *p)
*/ */
static inline void frozen_process(struct task_struct *p) static inline void frozen_process(struct task_struct *p)
{ {
p->flags |= PF_FROZEN; if (!unlikely(p->flags & PF_NOFREEZE)) {
wmb(); p->flags |= PF_FROZEN;
wmb();
}
clear_tsk_thread_flag(p, TIF_FREEZE); clear_tsk_thread_flag(p, TIF_FREEZE);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment