diff options
author | Gautham R Shenoy <ego@in.ibm.com> | 2007-05-23 16:57:28 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-05-23 23:14:11 -0400 |
commit | 5fcc57f2d5d558056668159f9153bf21d2c53d16 (patch) | |
tree | aa81c453b093f051bf775cd8fb557df9d2f79543 | |
parent | a076e4bca2fdabb9e45d86722cc72c0944da5f94 (diff) |
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: 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>
-rw-r--r-- | include/linux/freezer.h | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/include/linux/freezer.h b/include/linux/freezer.h index c9435252e8e4..1045ee9c0bb4 100644 --- a/include/linux/freezer.h +++ b/include/linux/freezer.h | |||
@@ -63,8 +63,10 @@ static inline int thaw_process(struct task_struct *p) | |||
63 | */ | 63 | */ |
64 | static inline void frozen_process(struct task_struct *p) | 64 | static inline void frozen_process(struct task_struct *p) |
65 | { | 65 | { |
66 | p->flags |= PF_FROZEN; | 66 | if (!unlikely(p->flags & PF_NOFREEZE)) { |
67 | wmb(); | 67 | p->flags |= PF_FROZEN; |
68 | wmb(); | ||
69 | } | ||
68 | clear_tsk_thread_flag(p, TIF_FREEZE); | 70 | clear_tsk_thread_flag(p, TIF_FREEZE); |
69 | } | 71 | } |
70 | 72 | ||