]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
freezer: fix PF_NOFREEZE vs freezeable race
authorGautham R Shenoy <ego@in.ibm.com>
Wed, 23 May 2007 20:57:28 +0000 (13:57 -0700)
committerLinus Torvalds <torvalds@woody.linux-foundation.org>
Thu, 24 May 2007 03:14:11 +0000 (20:14 -0700)
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>
include/linux/freezer.h

index c9435252e8e45e9cc9b7857cc7c4185359a51b7a..1045ee9c0bb45ab96c3794fb8b9a1697ff2e465a 100644 (file)
@@ -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);
 }