Skip to content

Commit 14a67b4

Browse files
Chen Ridonghtejun
authored andcommitted
Revert "cgroup_freezer: cgroup_freezing: Check if not frozen"
This reverts commit cff5f49. 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 the commit cff5f49 ("cgroup_freezer: cgroup_freezing: Check if not frozen") to resolve the issue. The warning has been removed in the previous patch. This patch revert the commit cff5f49 ("cgroup_freezer: cgroup_freezing: Check if not frozen") to complete the fix. Fixes: cff5f49 ("cgroup_freezer: cgroup_freezing: Check if not frozen") Reported-by: Zhong Jiawei<[email protected]> Signed-off-by: Chen Ridong <[email protected]> Signed-off-by: Tejun Heo <[email protected]>
1 parent 9beb8c5 commit 14a67b4

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

kernel/cgroup/legacy_freezer.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,9 @@ static struct freezer *parent_freezer(struct freezer *freezer)
6666
bool cgroup_freezing(struct task_struct *task)
6767
{
6868
bool ret;
69-
unsigned int state;
7069

7170
rcu_read_lock();
72-
/* Check if the cgroup is still FREEZING, but not FROZEN. The extra
73-
* !FROZEN check is required, because the FREEZING bit is not cleared
74-
* when the state FROZEN is reached.
75-
*/
76-
state = task_freezer(task)->state;
77-
ret = (state & CGROUP_FREEZING) && !(state & CGROUP_FROZEN);
71+
ret = task_freezer(task)->state & CGROUP_FREEZING;
7872
rcu_read_unlock();
7973

8074
return ret;

0 commit comments

Comments
 (0)