From: Gautham R Shenoy This patch fixes the race pointed out by Oleg Nesterov. * Freezer marks a thread as freezeable. * The thread now marks itself PF_NOFREEZE causing it to freeze 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 Cc: "Rafael J. Wysocki" Cc: Oleg Nesterov Signed-off-by: Andrew Morton --- include/linux/freezer.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff -puN include/linux/freezer.h~fix-pf_nofreeze-and-freezeable-race-2 include/linux/freezer.h --- a/include/linux/freezer.h~fix-pf_nofreeze-and-freezeable-race-2 +++ a/include/linux/freezer.h @@ -57,8 +57,10 @@ static inline int thaw_process(struct ta */ 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); } _