mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Chen Ridong <chenridong@huaweicloud.com>
To: mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com,
	vincent.guittot@linaro.org, dietmar.eggemann@arm.com,
	rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de,
	bristot@redhat.com, vschneid@redhat.com, rafael@kernel.org,
	pavel@ucw.cz
Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org,
	lujialin4@huawei.com, chenridong@huawei.com
Subject: [PATCH 6.6 5/5] sched,freezer: Remove unnecessary warning in __thaw_task
Date: Mon, 28 Jul 2025 02:41:21 +0000	[thread overview]
Message-ID: <20250728024121.33864-6-chenridong@huaweicloud.com> (raw)
In-Reply-To: <20250728024121.33864-1-chenridong@huaweicloud.com>

From: Chen Ridong <chenridong@huawei.com>

[ Upstream commit 9beb8c5e77dc10e3889ff5f967eeffba78617a88 ]

Commit cff5f49d433f ("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 cff5f49d433f ("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 cff5f49d433f ("cgroup_freezer: cgroup_freezing: Check if
not frozen") to complete the fix.

Reported-by: Zhong Jiawei<zhongjiawei1@huawei.com>
Signed-off-by: Chen Ridong <chenridong@huawei.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
---
 kernel/freezer.c | 15 +++------------
 1 file changed, 3 insertions(+), 12 deletions(-)

diff --git a/kernel/freezer.c b/kernel/freezer.c
index f57aaf96b829..d8db479af478 100644
--- a/kernel/freezer.c
+++ b/kernel/freezer.c
@@ -196,18 +196,9 @@ static int __restore_freezer_state(struct task_struct *p, void *arg)
 
 void __thaw_task(struct task_struct *p)
 {
-	unsigned long flags;
-
-	spin_lock_irqsave(&freezer_lock, flags);
-	if (WARN_ON_ONCE(freezing(p)))
-		goto unlock;
-
-	if (!frozen(p) || task_call_func(p, __restore_freezer_state, NULL))
-		goto unlock;
-
-	wake_up_state(p, TASK_FROZEN);
-unlock:
-	spin_unlock_irqrestore(&freezer_lock, flags);
+	guard(spinlock_irqsave)(&freezer_lock);
+	if (frozen(p) && !task_call_func(p, __restore_freezer_state, NULL))
+		wake_up_state(p, TASK_FROZEN);
 }
 
 /**
-- 
2.34.1


  parent reply	other threads:[~2025-07-28  2:55 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <2025072421-deviate-skintight-bbd5@gregkh>
2025-07-28  2:41 ` [PATCH 6.6 0/5] [Backport] " Chen Ridong
2025-07-28  2:41   ` [PATCH 6.6 1/5] sched/core: Remove ifdeffery for saved_state Chen Ridong
2025-07-28  2:41   ` [PATCH 6.6 2/5] freezer,sched: Use saved_state to reduce some spurious wakeups Chen Ridong
2025-07-28  2:41   ` [PATCH 6.6 3/5] freezer,sched: Do not restore saved_state of a thawed task Chen Ridong
2025-07-28  2:41   ` [PATCH 6.6 4/5] freezer,sched: Clean saved_state when restoring it during thaw Chen Ridong
2025-07-28  2:41   ` Chen Ridong [this message]
2025-07-28  3:11   ` [PATCH 6.6 0/5] [Backport] sched,freezer: Remove unnecessary warning in __thaw_task Chen Ridong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250728024121.33864-6-chenridong@huaweicloud.com \
    --to=chenridong@huaweicloud.com \
    --cc=bristot@redhat.com \
    --cc=bsegall@google.com \
    --cc=chenridong@huawei.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=juri.lelli@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=lujialin4@huawei.com \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=pavel@ucw.cz \
    --cc=peterz@infradead.org \
    --cc=rafael@kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=vincent.guittot@linaro.org \
    --cc=vschneid@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®