From: sashiko-bot@kernel.org
To: "Tejun Heo" <tj@kernel.org>
Cc: tj@kernel.org, mkoutny@suse.com, sched-ext@lists.linux.dev,
hannes@cmpxchg.org
Subject: Re: [PATCH cgroup/for-7.2-fixes] cgroup: Create the psimon kthread outside of cgroup_mutex
Date: Sat, 11 Jul 2026 00:04:33 +0000 [thread overview]
Message-ID: <20260711000434.36C4A1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260710134945-psimon-fix-tj@kernel.org>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but the psi rtpoll_timer can be re-armed after it is deleted and subsequently execute after the psi_group is freed, causing a Use-After-Free.
--
--- Patch [1]: [PATCH cgroup/for-7.2-fixes] cgroup: Create the psimon kthread outside of cgroup_mutex ---
commit 8790bcf0b23cb2132be9400b975c7f18fd1147b7
Author: Tejun Heo <tj@kernel.org>
cgroup: Create the psimon kthread outside of cgroup_mutex
This commit splits the trigger creation process so the rtpoll worker thread
is forked without holding cgroup_mutex. This resolves a deadlock between
cgroup_mutex and the fork path during sched_ext enablement.
Link: https://lore.kernel.org/all/20260710100441.2653477-1-matt@readmodwrite.com/
> diff --git a/kernel/sched/psi.c b/kernel/sched/psi.c
> index 848955f8893dd..b9f207c920edb 100644
> --- a/kernel/sched/psi.c
> +++ b/kernel/sched/psi.c
[ ... ]
> @@ -1565,12 +1592,22 @@ static ssize_t psi_write(struct file *file, const char __user *user_buf,
> return -EBUSY;
> }
>
> - new = psi_trigger_create(&psi_system, buf, res, file, NULL);
> + new = psi_trigger_create(&psi_system, buf, res, file, NULL,
> + &need_rtpoll_worker);
> if (IS_ERR(new)) {
> mutex_unlock(&seq->lock);
> return PTR_ERR(new);
> }
>
> + if (need_rtpoll_worker) {
> + ret = psi_trigger_create_rtpoll_worker(&psi_system);
> + if (ret) {
> + psi_trigger_destroy(new);
[Severity: High]
This isn't a bug introduced by this patch, but can the psi rtpoll_timer be
re-armed after it is deleted and subsequently execute after the psi_group is
freed, causing a use-after-free?
In psi_trigger_destroy(), the timer is deleted before synchronize_rcu():
psi_trigger_destroy() {
rcu_assign_pointer(group->rtpoll_task, NULL);
timer_delete(&group->rtpoll_timer);
...
synchronize_rcu();
}
If Thread A calls psi_schedule_rtpoll_work() and gets delayed or preempted
after reading rtpoll_task inside the RCU read-side critical section:
psi_schedule_rtpoll_work() {
rcu_read_lock();
task = rcu_dereference(group->rtpoll_task);
...
// Thread A delayed here
}
Thread B could then run psi_trigger_destroy(), delete the timer, and block in
synchronize_rcu() waiting for Thread A. When Thread A resumes, it sees the
task is non-NULL and calls mod_timer():
if (likely(task))
mod_timer(&group->rtpoll_timer, jiffies + delay);
This re-arms the timer after it was already deleted by Thread B.
Later, when the cgroup is removed and psi_cgroup_free() is called, the
psi_group is freed without deleting this leaked timer. When the timer finally
expires, poll_timer_fn() will attempt to access the freed group memory.
> + mutex_unlock(&seq->lock);
> + return ret;
> + }
> + }
> +
> smp_store_release(&seq->private, new);
> mutex_unlock(&seq->lock);
>
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260710134945-psimon-fix-tj@kernel.org?part=1
next prev parent reply other threads:[~2026-07-11 0:04 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-10 10:04 [PATCH] sched_ext: Fix deadlock with PSI trigger creation Matt Fleming
2026-07-10 10:17 ` sashiko-bot
2026-07-10 17:46 ` Andrea Righi
2026-07-10 18:24 ` Andrea Righi
2026-07-10 23:49 ` [PATCH cgroup/for-7.2-fixes] cgroup: Create the psimon kthread outside of cgroup_mutex Tejun Heo
2026-07-11 0:04 ` sashiko-bot [this message]
2026-07-11 5:54 ` Matt Fleming
2026-07-12 17:49 ` Tejun Heo
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=20260711000434.36C4A1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=hannes@cmpxchg.org \
--cc=mkoutny@suse.com \
--cc=sashiko-reviews@lists.linux.dev \
--cc=sched-ext@lists.linux.dev \
--cc=tj@kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.