From: Kayra Cizmeci <kayracizmeci@gmail.com>
To: Andrea Parri <parri.andrea@gmail.com>
Cc: Ingo Molnar <mingo@redhat.com>,
Peter Zijlstra <peterz@infradead.org>,
Juri Lelli <juri.lelli@redhat.com>,
Vincent Guittot <vincent.guittot@linaro.org>,
Dietmar Eggemann <dietmar.eggemann@arm.com>,
Steven Rostedt <rostedt@goodmis.org>,
Ben Segall <bsegall@google.com>, Mel Gorman <mgorman@suse.de>,
Valentin Schneider <vschneid@redhat.com>,
K Prateek Nayak <kprateek.nayak@amd.com>,
Waiman Long <longman@redhat.com>, Tejun Heo <tj@kernel.org>,
Hui Su <sh_def@163.com>,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
Clark Williams <clrkwllms@kernel.org>,
linux-rt-devel@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] sched: Fix cpuset_mutex double unlock in __sched_setscheduler()
Date: Mon, 2 Nov 2026 18:47:17 +0300 [thread overview]
Message-ID: <auimbkttN-iPGtwZ@scheduler.schedules> (raw)
In-Reply-To: <20261102134606.242743-1-parri.andrea@gmail.com>
On Mon, Nov 02, 2026 at 02:46:05PM +0100, Andrea Parri wrote:
:
> A sched_setattr() with SCHED_FLAG_KEEP_POLICY on a SCHED_DEADLINE task
> unlocks cpuset_mutex twice if the task's policy changes concurrently:
Uh-oh.
> kernel/sched/syscalls.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/sched/syscalls.c b/kernel/sched/syscalls.c
> index 45a127deeadd9..2af550f92ac65 100644
> --- a/kernel/sched/syscalls.c
> +++ b/kernel/sched/syscalls.c
> @@ -640,8 +640,10 @@ int __sched_setscheduler(struct task_struct *p,
> if (unlikely(oldpolicy != -1 && oldpolicy != p->policy)) {
> policy = oldpolicy = -1;
> task_rq_unlock(rq, p, &rf);
> - if (cpuset_locked)
> + if (cpuset_locked) {
> cpuset_unlock();
> + cpuset_locked = false;
> + }
> goto recheck;
> }
>
> --
> 2.53.0
>
So the issue is that when tasks policy changes before we come to this
check, we don't clear cpuset_locked while calling cpuset_unlock().
In the other calls of cpuset_unlock() this is not a problem since we
just return and don't use the local cpuset_locked. But on this one we
do. And if we don't retake the lock it just stays true. Even if we
didn't claimed the lock. And that causes bad, bad, bad, bad problems.
Reviewed-by: Kayra Cizmeci <kayracizmeci@gmail.com>
Thanks,
Kayra
prev parent reply other threads:[~2026-11-02 15:47 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-02 13:46 Andrea Parri
2026-11-02 15:03 ` Waiman Long
2026-11-02 15:47 ` Kayra Cizmeci [this message]
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=auimbkttN-iPGtwZ@scheduler.schedules \
--to=kayracizmeci@gmail.com \
--cc=bigeasy@linutronix.de \
--cc=bsegall@google.com \
--cc=clrkwllms@kernel.org \
--cc=dietmar.eggemann@arm.com \
--cc=juri.lelli@redhat.com \
--cc=kprateek.nayak@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rt-devel@lists.linux.dev \
--cc=longman@redhat.com \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=parri.andrea@gmail.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=sh_def@163.com \
--cc=tj@kernel.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®