From nobody Fri Oct 2 08:26:23 2026 Received: from canpmsgout05.his.huawei.com (canpmsgout05.his.huawei.com [113.46.200.220]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CAC433932D8 for ; Mon, 3 Aug 2026 12:55:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.220 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785761723; cv=none; b=IEbgoO291B2s3mlg7yO15d6sDdoNE/BoIfYzKSvL3NlIccdb9OrL7ll7BtU1FkeBOa0724k5z2iGb78Ze/cDM1K+PyjKcohg1A6z9DhFfe++EdeIp2AzC6Tmp3Jn4KTevAZEE5VN8ppyNYy6IDFPlWwITs8u3Uu6tCtwQty3Wco= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785761723; c=relaxed/simple; bh=uyIJMjoltT6jKXIwwYWfOOIb4y8z90Hf+EU+aINzy1M=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=E03hDXemihfXqBY0FwQPxHf5PhGXMoW9n2GDdxTanBePbjwIpyo1d9/jD0x+mGmX3ZixAIuKMKl4C9Ui31MLqvQNGbSSTtiE8Zdqml/LXCScE3tM0LpDRBrU8ZcxYAWxS97e127JQtWoZpslAMMsO0SjMtCbD5bRg9bfSaoqeX4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b=yjXvNoHZ; arc=none smtp.client-ip=113.46.200.220 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b="yjXvNoHZ" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=IYYP+CmoSPXWFVk1PfNPs+PBRe3h12yU/afEd6vH+IE=; b=yjXvNoHZKv6PkFkuHCc+l6p7Mkq90PH/3U0q1PwlSzzmch93kfDo/rSOEBCAMKUQtEzc8TL3G THoayU8dfkAXphixOKThbTAqAKwETIeSiT+HQ7AQ/vAvNu1CFlj2ghyatZttVISJfFstvUsiIdt sMa/OqED3hADJt8lsiTNVS8= Received: from mail.maildlp.com (unknown [172.19.162.223]) by canpmsgout05.his.huawei.com (SkyGuard) with ESMTPS id 4hDGcV5gvzz12LDt; Mon, 3 Aug 2026 20:45:46 +0800 (CST) Received: from kwepemr500016.china.huawei.com (unknown [7.202.195.68]) by mail.maildlp.com (Postfix) with ESMTPS id AB24840561; Mon, 3 Aug 2026 20:55:13 +0800 (CST) Received: from huawei.com (10.67.174.242) by kwepemr500016.china.huawei.com (7.202.195.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.45; Mon, 3 Aug 2026 20:55:13 +0800 From: Chen Jinghuang To: Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Paolo Bonzini CC: Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider , K Prateek Nayak , Subject: [PATCH] sched/numa: Prevent race on sysctl_numa_balancing static key Date: Mon, 3 Aug 2026 12:30:46 +0000 Message-ID: <20260803123046.297426-1-chenjinghuang2@huawei.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: kwepems200002.china.huawei.com (7.221.188.68) To kwepemr500016.china.huawei.com (7.202.195.68) While fuzzing with syzkaller, a concurrent 1/0 write race to /proc/sys/kernel/numa_balancing was found that trips a jump_label WARN_ON_ONCE(). Concurrent writes of 1/0 to /proc/sys/kernel/numa_balancing enable/disable the same static key. Enable sets key->enabled to -1 while holding the lock, restoring it to 1 only after jump_label_update(); disable checks enabled before taking the lock. Under concurrency, disable reads -1 and trips WARN_ON_ONCE(). Timeline: write 1 =E2=86=92 enable write 0 =E2=86=92 disable =E2=94=82 =E2=94=82 =E2=94=9C=E2=94=80 static_key_enable_cpuslocked() =E2=94=9C=E2=94=80= static_key_disable_cpuslocked() =E2=94=82 jump_label_lock() =E2=94=82 atomic_read(ena= bled) =E2=86=90 before lock =E2=94=82 atomic_set(enabled, -1) =E2=97=84=E2=94=80=E2=94=80=E2=94= =80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=BC=E2=94=80=E2=94=80 reads -1 =E2=94=82 jump_label_update() =E2=94=82 WARN_ON_ONCE(en= abled!=3D0) =E2=94=82 atomic_set_release(enabled,1) =E2=94=82 return =E2=86= =90 disable skipped =E2=94=82 jump_label_unlock() =E2=94=82 Serialize the enable/disable switch at the convergence point in set_numabalancing_state() with a mutex, so the transient -1 in key->enabled never leaks to a concurrent disable and this WARN_ON_ONCE no longer trips. This follows existing kernel practice, e.g. timer_key_mutex guarding timers_update_migration() (kernel/time/timer.c) and perf_sched_mutex guarding static_branch_enable() (kernel/events/core.c). Fixes: 1dbb6704de91 ("jump_label: Fix concurrent static_key_enable/disable(= )") Reported-by: Zhang zhaotian Signed-off-by: Chen Jinghuang --- kernel/sched/core.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 96226707c2f6..61fb0d7966e4 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -4629,13 +4629,17 @@ static void __set_numabalancing_state(bool enabled) static_branch_disable(&sched_numa_balancing); } =20 +static DEFINE_MUTEX(numabalancing_mutex); + void set_numabalancing_state(bool enabled) { + mutex_lock(&numabalancing_mutex); if (enabled) sysctl_numa_balancing_mode =3D NUMA_BALANCING_NORMAL; else sysctl_numa_balancing_mode =3D NUMA_BALANCING_DISABLED; __set_numabalancing_state(enabled); + mutex_unlock(&numabalancing_mutex); } =20 #ifdef CONFIG_PROC_SYSCTL --=20 2.34.1