Re: [PATCH 05/11] smp: Enable preemption early in smp_call_function_many_cond
From: Chuyi Zhou
Date: Mon Feb 09 2026 - 02:56:50 EST
在 2026/2/5 17:52, Peter Zijlstra 写道:
> On Tue, Feb 03, 2026 at 07:23:55PM +0800, Chuyi Zhou wrote:
>
>> + /*
>> + * Prevent the current CPU from going offline.
>> + * Being migrated to another CPU and calling csd_lock_wait() may cause
>> + * UAF due to smpcfd_dead_cpu() during the current CPU offline process.
>> + */
>> + migrate_disable();
>
> This is horrible crap. migrate_disable() is *NOT* supposed to be used to
> serialize cpu hotplug.
Here we can use rcu_read_lock to replace migrate_disable/cpus_read_lock,
and in smpcfd_dead_cpu(), wait for all rcu read critical sections to
exit before releasing percpu csd data.
This allows csd_lock_wait() to be preemptible and migratable, while
avoiding concurrency issues between smpcfd_dead_cpu() and csd_lock_wait.
Thanks.