From: Frederic Weisbecker <frederic@kernel.org>
To: Ridong Chen <ridong.chen@linux.dev>
Cc: longman@redhat.com, tj@kernel.org, peterz@infradead.org,
mingo@redhat.com, juri.lelli@redhat.com,
vincent.guittot@linaro.org, dietmar.eggemann@arm.com,
rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de,
vschneid@redhat.com, kprateek.nayak@amd.com, hannes@cmpxchg.org,
mkoutny@suse.com, linux-kernel@vger.kernel.org,
cgroups@vger.kernel.org, guopeng.zhang@linux.dev,
mathieu.desnoyers@efficios.com,
Ridong Chen <chenridong@xiaomi.com>
Subject: Re: [PATCH] sched/isolation: Publish new HK_TYPE_DOMAIN cpumask under cpuset_mutex
Date: Fri, 27 Nov 2026 14:14:53 +0100 [thread overview]
Message-ID: <awmCTbP_SaIPGRYf@localhost.localdomain> (raw)
In-Reply-To: <bc6e38f6-1412-49d0-95e2-76d5e9fc3858@linux.dev>
Le Fri, Nov 27, 2026 at 10:15:07AM +0800, Ridong Chen a écrit :
>
>
> On 11/17/2026 4:39 PM, Ridong wrote:
> > From: Ridong Chen<chenridong@xiaomi.com>
> >
> > Commit a84097e625f2 ("cgroup/cpuset: Call housekeeping_update() without
> > holding cpus_read_lock") calls housekeeping_update() after dropping
> > cpus_read_lock and cpuset_mutex, so the HK_TYPE_DOMAIN cpumask is now
> > switched and freed outside of those locks. But readers holding either
> > lock may still access it without rcu_read_lock() as allowed by
> > housekeeping_dereference_check(), and synchronize_rcu() doesn't wait
> > for them:
> >
> > CPU A CPU B
> > rebuild_sched_domains() cpuset_update_sd_hk_unlock()
> > mutex_unlock(&cpuset_mutex)
> > cpus_read_unlock()
> > mutex_lock(&cpuset_mutex)
> > p = housekeeping_cpumask(DOMAIN)
> > housekeeping_update()
> > rcu_assign_pointer()
> > synchronize_rcu()
> > kfree(old)
> > access p <- UAF
> >
> > Fix it by moving the pointer switch into housekeeping_publish(), which
> > is called before dropping the locks. Then CPU A either finishes before
> > CPU B switches the pointer, or only sees the new cpumask:
> >
> > CPU A CPU B
> > cpuset_update_sd_hk_unlock()
> > housekeeping_publish()
> > rcu_assign_pointer()
> > mutex_lock(&cpuset_mutex) <- wait
> > mutex_unlock(&cpuset_mutex)
> > cpus_read_unlock()
> > p = housekeeping_cpumask(DOMAIN) housekeeping_update()
> > <- new cpumask synchronize_rcu()
> > kfree(old)
> >
> > The rest of housekeeping_update(), including the workqueue flushes,
> > still runs without those locks.
> >
> > Fixes: a84097e625f2 ("cgroup/cpuset: Call housekeeping_update() without holding cpus_read_lock")
> > Signed-off-by: Ridong Chen<chenridong@xiaomi.com>
>
>
> Hi Frederic, Tejun,
>
> There are two fixes for the HK_TYPE_DOMAIN UAF after commit
> a84097e625f2, and neither is in linux-next yet:
>
> [1] Waiman's v2, which takes cpus_read_lock and cpuset_mutex once
> before kfree(old), so readers holding either lock are done
> before the old cpumask is freed.
>
> [2] This patch, which switches the pointer before dropping the
> locks, so readers holding either lock only see the new cpumask.
Yes the second one is clearer.
Thanks.
--
Frederic Weisbecker
SUSE Labs
next prev parent reply other threads:[~2026-11-27 13:14 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <054a53a3-c038-48fe-ac01-fc24fd8065d0@linux.dev>
2026-11-17 8:39 ` [PATCH] sched/isolation: Publish new HK_TYPE_DOMAIN cpumask under cpuset_mutex Ridong
2026-11-17 16:15 ` Waiman Long
2026-11-18 0:03 ` Ridong Chen
2026-11-17 21:18 ` Tejun Heo
2026-11-18 14:20 ` Frederic Weisbecker
2026-11-18 17:16 ` Waiman Long
2026-11-27 2:15 ` Ridong Chen
2026-11-27 13:14 ` Frederic Weisbecker [this message]
2026-11-27 13:13 ` Frederic Weisbecker
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=awmCTbP_SaIPGRYf@localhost.localdomain \
--to=frederic@kernel.org \
--cc=bsegall@google.com \
--cc=cgroups@vger.kernel.org \
--cc=chenridong@xiaomi.com \
--cc=dietmar.eggemann@arm.com \
--cc=guopeng.zhang@linux.dev \
--cc=hannes@cmpxchg.org \
--cc=juri.lelli@redhat.com \
--cc=kprateek.nayak@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=longman@redhat.com \
--cc=mathieu.desnoyers@efficios.com \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=mkoutny@suse.com \
--cc=peterz@infradead.org \
--cc=ridong.chen@linux.dev \
--cc=rostedt@goodmis.org \
--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