From nobody Tue Apr 7 14:02:45 2026 Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6CD491B6CE9 for ; Wed, 25 Feb 2026 21:15:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772054129; cv=none; b=IX10dgqAgdhmEuKvOop2Ni7fEnRmWr1zkDe9urydnxnSVX7bF1eWxuRzIjv6q/KcRtHw2a0Z6lSfPgOfbYrvE5K9Ab6DzXplgR83yAlmtselumZLSgr/ewZ9Y4mp63ac9Pc9IDFM53JHRJ5fiVl8n8ossrnjGe1AnGqJ72Jzjao= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772054129; c=relaxed/simple; bh=ajpvC3Y7noxqYwisbE73Hi1UmeX1LjH1CvNKq6jS4gg=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=Rv7rBaT9SliZxNheJFGRoRCV5TeXeTXosNdkUHyX5SF/w6u3FM3TqkzVmhI0E2Z/GzSPGMKKSdXigEvCuQZ9Rt5QiWzdu68bBcMNYnxQIGcJwYAkWuDpmKe5C0VRhYa6D192AtYo1OVcU5pV9xQZZ5lhWjQNuyQXo5qaW88WYng= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ZSjSF9Ro; arc=none smtp.client-ip=209.85.128.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ZSjSF9Ro" Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-4833115090dso2137865e9.3 for ; Wed, 25 Feb 2026 13:15:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1772054127; x=1772658927; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=RXdYpX0bfwiJPvqUYlcRi0cGEcBdpUwRf90WpbQbApE=; b=ZSjSF9RodBRWwWMew0QJOVlKoNnCO61KunVzKPwbZWPI1N3LWivwQSpc8BfM9EmvyT y17shNkjXFvhaVVn9n/eeS4vRergHIJHq59a/OG/F+DXhkJuGQhDcFtYHetckOfUZ6UG tW1J4hyqhXFtxsdDF9t19EnzJg2mONhqkMKGHgHegCOBdHpTtZeeLxg4kkvoJZrPImxA 8W7kUl9uM0dUISfbSmlxyz980tqyBM8aVWv+eUiJW7VJIGe+FrCGZwlOcnsanRNjinn2 qBIc/Dn3IcMt2KH18uoQfjIQmkrSYQSAFP0/kj5zfkwIxV53L8z5Wm10lU+MMMXi1E7U jTVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772054127; x=1772658927; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=RXdYpX0bfwiJPvqUYlcRi0cGEcBdpUwRf90WpbQbApE=; b=ZOFnwyY4mNCihBfiGdQKx695giZeEIg9+YSeIcED3DFIFjjntLvlHSk05/eaHDikhA up+bn4Z9hlAwK4rLbYUuLYHgEU2+FO3QVMDCdIyR27Vm8uob2G2CWQq3sc4n45fWUb8X kESwGID2DWKdEfkZKA2xyJEj1zEpNQJUNd2AHWiDX7tMTdBdzRBSv3p/AtNVrSEfB1Lz 0otJ1a49WrT+XuNMs/6QKp18qoMW+tKwHqw0Pq3a+SJXKX7Xa067eXq2d9VXKSI9MFXd cG+c1G13Cy+wo+ui7Hxm6leqDOZofBKZWIeu/II1e0uWtyooPFoGcsfBG/nkA/2z93xI +XOQ== X-Gm-Message-State: AOJu0YxPvVmeqjSIZ5QlVgZovOvNGChBkwzprIKX7TMpIwriAB8MDlAp M6nqfeVsL251hqpndy7ClepfGkbLMgqugZPJGPeU05ZndGeZfEf8WDRilemyBK4c X-Gm-Gg: ATEYQzw0P3+ZG/J2o0jpc3sjcnsk6WO8zMv1z9byehjo/io+GKN5aCr5afhMOMavoJ6 AYROhe8BCEmbxW85JOx+D5LjM9P/WdO7X7SlA5i8+zGRjoBV8hlv4/aBNWaRg/rabQSi02X9IB9 SlPUthlwM5BD/loJyOIgWrY9QGrpO6o1GoZGRP2cA5HxHU/JBnoUomqliz3a2a0HNnMQKg04TK+ JGtfII4i/V/mcpeOuMGOv7ckHMcKYWc4jrDVZUygmHWUozQwAQdytjWpKPJYdCYs38uel2EDsZc tH6fBjQUUiV7LKbSTwLARuwxFkdLrKONDTmIs0uwNVuOAQ9Tk2kgZ27aVyWkg5Y8MZ5WYmx9l7P c/IlRoeifL4bpbJ5FplF5GmdJvhfZrX4TZNDCLwZM32wwBvH51XT9zaspIRIaObOC0YXix7JAvs mmwqvmQuj1hJ/GbyjjytD5cGtncTsaSH5jg9Kwvzn5D1sIEkF+M+5MQ9dmWqrhRsolainoNrLSg hRbJXyIngdNMVYgRKdV X-Received: by 2002:a05:600c:45cc:b0:483:4807:210c with SMTP id 5b1f17b1804b1-483a95f5611mr315573715e9.24.1772054126576; Wed, 25 Feb 2026 13:15:26 -0800 (PST) Received: from rozandragon.chello.ie (188-141-5-72.dynamic.upc.ie. [188.141.5.72]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-483bd732eb1sm94351645e9.12.2026.02.25.13.15.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Feb 2026 13:15:26 -0800 (PST) From: David Carlier To: Tejun Heo , David Vernet Cc: linux-kernel@vger.kernel.org, David Carlier Subject: [PATCH] sched_ext: Fix out-of-bounds access in scx_idle_init_masks() Date: Wed, 25 Feb 2026 21:15:23 +0000 Message-ID: <20260225211523.399284-1-devnexen@gmail.com> X-Mailer: git-send-email 2.51.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" scx_idle_node_masks is allocated with num_possible_nodes() elements but indexed by NUMA node IDs via for_each_node(). On systems with non-contiguous NUMA node numbering (e.g. nodes 0 and 4), node IDs can exceed the array size, causing out-of-bounds memory corruption. Use nr_node_ids instead, which represents the maximum node ID range and is the correct size for arrays indexed by node ID. Fixes: 7c60329e3521 ("sched_ext: Add NUMA-awareness to the default idle sel= ection policy") Signed-off-by: David Carlier --- kernel/sched/ext_idle.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/sched/ext_idle.c b/kernel/sched/ext_idle.c index 3d9d404d5cd2..2cca09097d82 100644 --- a/kernel/sched/ext_idle.c +++ b/kernel/sched/ext_idle.c @@ -663,8 +663,8 @@ void scx_idle_init_masks(void) BUG_ON(!alloc_cpumask_var(&scx_idle_global_masks.cpu, GFP_KERNEL)); BUG_ON(!alloc_cpumask_var(&scx_idle_global_masks.smt, GFP_KERNEL)); =20 - /* Allocate per-node idle cpumasks */ - scx_idle_node_masks =3D kcalloc(num_possible_nodes(), + /* Allocate per-node idle cpumasks, we need to take in account non-contig= uous NUMA nodes */ + scx_idle_node_masks =3D kcalloc(nr_node_ids, sizeof(*scx_idle_node_masks), GFP_KERNEL); BUG_ON(!scx_idle_node_masks); =20 --=20 2.51.0