Skip to content

Commit 8fc25d3

Browse files
Chen Ridonggregkh
authored andcommitted
sched,freezer: Remove unnecessary warning in __thaw_task
commit 9beb8c5 upstream. Commit cff5f49 ("cgroup_freezer: cgroup_freezing: Check if not frozen") modified the cgroup_freezing() logic to verify that the FROZEN flag is not set, affecting the return value of the freezing() function, in order to address a warning in __thaw_task. A race condition exists that may allow tasks to escape being frozen. The following scenario demonstrates this issue: CPU 0 (get_signal path) CPU 1 (freezer.state reader) try_to_freeze read freezer.state __refrigerator freezer_read update_if_frozen WRITE_ONCE(current->__state, TASK_FROZEN); ... /* Task is now marked frozen */ /* frozen(task) == true */ /* Assuming other tasks are frozen */ freezer->state |= CGROUP_FROZEN; /* freezing(current) returns false */ /* because cgroup is frozen (not freezing) */ break out __set_current_state(TASK_RUNNING); /* Bug: Task resumes running when it should remain frozen */ The existing !frozen(p) check in __thaw_task makes the WARN_ON_ONCE(freezing(p)) warning redundant. Removing this warning enables reverting commit cff5f49 ("cgroup_freezer: cgroup_freezing: Check if not frozen") to resolve the issue. This patch removes the warning from __thaw_task. A subsequent patch will revert commit cff5f49 ("cgroup_freezer: cgroup_freezing: Check if not frozen") to complete the fix. Reported-by: Zhong Jiawei<[email protected]> Signed-off-by: Chen Ridong <[email protected]> Signed-off-by: Tejun Heo <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 7258b43 commit 8fc25d3

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

kernel/freezer.c

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -201,18 +201,9 @@ static int __restore_freezer_state(struct task_struct *p, void *arg)
201201

202202
void __thaw_task(struct task_struct *p)
203203
{
204-
unsigned long flags;
205-
206-
spin_lock_irqsave(&freezer_lock, flags);
207-
if (WARN_ON_ONCE(freezing(p)))
208-
goto unlock;
209-
210-
if (!frozen(p) || task_call_func(p, __restore_freezer_state, NULL))
211-
goto unlock;
212-
213-
wake_up_state(p, TASK_FROZEN);
214-
unlock:
215-
spin_unlock_irqrestore(&freezer_lock, flags);
204+
guard(spinlock_irqsave)(&freezer_lock);
205+
if (frozen(p) && !task_call_func(p, __restore_freezer_state, NULL))
206+
wake_up_state(p, TASK_FROZEN);
216207
}
217208

218209
/**

0 commit comments

Comments
 (0)