From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795022173; b=gzEaLxrTwnznsnqGO5lZZ+9gh9m4Zzi/fxe7zy6nn2texGP+jD9puFfQVXJP6845NF5H mF3ytcIesXc5+GS+OO2irjaP1RHEG6/4l1/wq4P/iU78cZ0CbZv0xDcCMQepfI6Fe/Wp1 NLe1X4xYbkQZVrGiynL5DLaGU1xbvZwy5IIQNB69WohZDZC5wwQ9h95aIqT7bvHtTXOTM djgqbwKBjPiSJy7a4H3MsyYdfhaNcr3d4TqIaucnjUjpb2xF4fi3jY+PV4d2kOUc9Qz3o YqJrFiZye3G9Dpy5gnPEuoDHavtA0z8gaRwc8wn3H2Hrv5wEVntVGnH4hmHFhsnhtxw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795022173; h=DMARC-Filter:DKIM-Signature:Received:X-MC-Unique: X-Mimecast-MFC-AGG-ID:Received:Received:Message-ID:Date:MIME-Version: User-Agent:Subject:To:Cc:References:Content-Language:From:In-Reply-To: Content-Type:Content-Transfer-Encoding:X-Scanned-By; bh=uQgs/LnSsb7T5Yqdh//B4nhVbzY1sGg8qFnrYeg3TTk=; b=v8eVBFfSgCkWLs8Fflr4pAi68DlOsOJtW/vE0Sv737foMUnAnP8Jd7fvJfqIOr0fQB0c xARPyO7o3khnQsUGV6U7L/y8iS8USc93CdmT21bTicgXyYkf1/fE4mIcxIhSCiDx99LGL PcQOr99Pk3qXv45RpI1OHnyzk9vND7IE3nGHYjFxMWB6Hk0R4aWfvC2chOmKmu3v/cPeM WglVZgvGGkowBTybm74gBNvdhi7q2JdsKvC7uXlPHlVhqmjSN42cDs1tg2+bn/n80Fci7 Xw7ZXP/bdJm4seIvYK6ZfT58tCcj3shAFsxOE22FFImJpZ00QG0ns5WSmrIW4kt0qaw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=iiTjJUjV; arc=none smtp.remote-ip=170.10.129.124 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 130A7606A32F for ; Wed, 18 Nov 2026 17:16:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 130A7606A32F Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=iiTjJUjV DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1795022172; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=uQgs/LnSsb7T5Yqdh//B4nhVbzY1sGg8qFnrYeg3TTk=; b=iiTjJUjV0siAR1LiqPb/KhNZ0l1qyfO2ZH6mpm4+QXolFfqOdSX+N/sfBJ4kX/nkBAVvRW u0cr+wwCgfqbba2tskzznFESWu1wQ16nRP3IoUlZSPg3NVt6kmZeUxVycvjg5OVxHcvaWJ 2Zw45nywK/v5MTQlu2aRn2NYC9RK3yo= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-465-V9WYMYi8MFSwRBdgCDsq2g-1; Wed, 18 Nov 2026 12:16:08 -0500 X-MC-Unique: V9WYMYi8MFSwRBdgCDsq2g-1 X-Mimecast-MFC-AGG-ID: V9WYMYi8MFSwRBdgCDsq2g_1795022165 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id D79B919560B1; Wed, 18 Nov 2026 17:16:04 +0000 (UTC) Received: from [10.17.16.204] (unknown [10.17.16.204]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 361F31956088; Wed, 18 Nov 2026 17:16:01 +0000 (UTC) Message-ID: Date: Wed, 18 Nov 2026 12:16:00 -0500 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] sched/isolation: Publish new HK_TYPE_DOMAIN cpumask under cpuset_mutex To: Frederic Weisbecker , Ridong Cc: 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 References: <054a53a3-c038-48fe-ac01-fc24fd8065d0@linux.dev> <20261117083915.2971979-1-ridong.chen@linux.dev> Content-Language: en-US From: Waiman Long In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 On 11/18/26 9:20 AM, Frederic Weisbecker wrote: > Le Tue, Nov 17, 2026 at 04:39:15PM +0800, Ridong a écrit : >> From: Ridong Chen >> >> 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 > Ok that should work but, IIRC this whole locking puzzle is there because > cpuset_handle_hotplug() can change isolated partitions. Why is it the case > since cpuset.cpus shouldn't care about offline CPUs? > > I remember Waiman said it could be fixed in the long run. I don't remember > the details though. cpuset_handle_hotplug() has to remove the newly offlined CPU or to add back the newly online CPUs to the effective_cpus of all the cpusets that include the affected CPUs whether it is in an isolated or root partition or not. In the worst case that the last online CPU in an isolated partition is offline, we have to disable it. That is the main reason why hotplug can affect isolated partitions. I don't remember saying it is something that can be fixed long term. Perhaps, it is not something related but not exactly this. Cheers, Longman