Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 BEB18273D66 for ; Wed, 1 Oct 2025 07:43:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759304628; cv=none; b=s1oi0C4lyoBtvePgnXtLgr558QUYjMJ4j0wruimXQK3d+BafsYFQw04xGq2V018lapWurtx+J1WEwaBAbv9yJjeczeG3IcQ0oxT39hSl2nz4ETYeaKTJOunGijfd0hAGb1Ippqwxlp15kXoDBgIyWisO46Df6nF7rcvJ45m95zc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759304628; c=relaxed/simple; bh=S3OV9SxRaJNTpYqcvMtKcgTkuyh/Ufss7D24ON0DXT0=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=aKQGtUxgkvcNpD9aju/RrYQGEiAF4ivipRUPQtKo/pjv8YZbhBQ1ZQIsTIhbm6Syo/UMxbRmAuC3MKge9EzFqsAZtQR9/sO1XcEn8IjcjkWY7ZwUwBNg9hiy7hj/L3vPp0DQZ3MsKAQ8rw3Cc0o98OvhOaeQ5eol0UHAonOeKvs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Ghs4EDTb; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="Ghs4EDTb" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D62AAC4CEF4; Wed, 1 Oct 2025 07:43:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1759304628; bh=S3OV9SxRaJNTpYqcvMtKcgTkuyh/Ufss7D24ON0DXT0=; h=From:To:Cc:Subject:Date:Reply-to:From; b=Ghs4EDTbkHHCQl+Dg57oba0Ur6Ho3Lw5XrscmDs7EHU27ADvxgJLkMvQHQ1QMe2gW QARI9RyKCYArFqjVC+766gufILNGUBCagxOH5mCr03BwHXnOO49ZpVQ3BDKscexmV4 r1OTcV5T3iCkHqRjIAtcuqm7rQ2fui29PEBIhlao= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2025-39895: sched: Fix sched_numa_find_nth_cpu() if mask offline Date: Wed, 1 Oct 2025 09:43:19 +0200 Message-ID: <2025100115-CVE-2025-39895-d6e8@gregkh> X-Mailer: git-send-email 2.51.0 Precedence: bulk X-Mailing-List: linux-cve-announce@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Reply-to: , X-Developer-Signature: v=1; a=openpgp-sha256; l=6530; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=/60RdLq0yUhMg5nfyh11ef2rw+BEHm2ewrYm4FqvO9E=; b=owGbwMvMwCRo6H6F97bub03G02pJDBl3bk9+tLL3VOM9985fU8tFL+ZKXjPZdOCc9MM3Zuy7O 3L/bzHc0BHLwiDIxCArpsjyZRvP0f0VhxS9DG1Pw8xhZQIZwsDFKQATyZ3EMD9wlrZqpoO8ytTf vR9eMXEcuPqy5xDDglWT/KRl7KqmL2MIW9fD+1J8Y77HdwA= X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 Content-Transfer-Encoding: 8bit From: Greg Kroah-Hartman Description =========== In the Linux kernel, the following vulnerability has been resolved: sched: Fix sched_numa_find_nth_cpu() if mask offline sched_numa_find_nth_cpu() uses a bsearch to look for the 'closest' CPU in sched_domains_numa_masks and given cpus mask. However they might not intersect if all CPUs in the cpus mask are offline. bsearch will return NULL in that case, bail out instead of dereferencing a bogus pointer. The previous behaviour lead to this bug when using maxcpus=4 on an rk3399 (LLLLbb) (i.e. booting with all big CPUs offline): [ 1.422922] Unable to handle kernel paging request at virtual address ffffff8000000000 [ 1.423635] Mem abort info: [ 1.423889] ESR = 0x0000000096000006 [ 1.424227] EC = 0x25: DABT (current EL), IL = 32 bits [ 1.424715] SET = 0, FnV = 0 [ 1.424995] EA = 0, S1PTW = 0 [ 1.425279] FSC = 0x06: level 2 translation fault [ 1.425735] Data abort info: [ 1.425998] ISV = 0, ISS = 0x00000006, ISS2 = 0x00000000 [ 1.426499] CM = 0, WnR = 0, TnD = 0, TagAccess = 0 [ 1.426952] GCS = 0, Overlay = 0, DirtyBit = 0, Xs = 0 [ 1.427428] swapper pgtable: 4k pages, 39-bit VAs, pgdp=0000000004a9f000 [ 1.428038] [ffffff8000000000] pgd=18000000f7fff403, p4d=18000000f7fff403, pud=18000000f7fff403, pmd=0000000000000000 [ 1.429014] Internal error: Oops: 0000000096000006 [#1] SMP [ 1.429525] Modules linked in: [ 1.429813] CPU: 3 UID: 0 PID: 1 Comm: swapper/0 Not tainted 6.17.0-rc4-dirty #343 PREEMPT [ 1.430559] Hardware name: Pine64 RockPro64 v2.1 (DT) [ 1.431012] pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--) [ 1.431634] pc : sched_numa_find_nth_cpu+0x2a0/0x488 [ 1.432094] lr : sched_numa_find_nth_cpu+0x284/0x488 [ 1.432543] sp : ffffffc084e1b960 [ 1.432843] x29: ffffffc084e1b960 x28: ffffff80078a8800 x27: ffffffc0846eb1d0 [ 1.433495] x26: 0000000000000000 x25: 0000000000000000 x24: 0000000000000000 [ 1.434144] x23: 0000000000000000 x22: fffffffffff7f093 x21: ffffffc081de6378 [ 1.434792] x20: 0000000000000000 x19: 0000000ffff7f093 x18: 00000000ffffffff [ 1.435441] x17: 3030303866666666 x16: 66663d736b73616d x15: ffffffc104e1b5b7 [ 1.436091] x14: 0000000000000000 x13: ffffffc084712860 x12: 0000000000000372 [ 1.436739] x11: 0000000000000126 x10: ffffffc08476a860 x9 : ffffffc084712860 [ 1.437389] x8 : 00000000ffffefff x7 : ffffffc08476a860 x6 : 0000000000000000 [ 1.438036] x5 : 000000000000bff4 x4 : 0000000000000000 x3 : 0000000000000000 [ 1.438683] x2 : 0000000000000000 x1 : ffffffc0846eb000 x0 : ffffff8000407b68 [ 1.439332] Call trace: [ 1.439559] sched_numa_find_nth_cpu+0x2a0/0x488 (P) [ 1.440016] smp_call_function_any+0xc8/0xd0 [ 1.440416] armv8_pmu_init+0x58/0x27c [ 1.440770] armv8_cortex_a72_pmu_init+0x20/0x2c [ 1.441199] arm_pmu_device_probe+0x1e4/0x5e8 [ 1.441603] armv8_pmu_device_probe+0x1c/0x28 [ 1.442007] platform_probe+0x5c/0xac [ 1.442347] really_probe+0xbc/0x298 [ 1.442683] __driver_probe_device+0x78/0x12c [ 1.443087] driver_probe_device+0xdc/0x160 [ 1.443475] __driver_attach+0x94/0x19c [ 1.443833] bus_for_each_dev+0x74/0xd4 [ 1.444190] driver_attach+0x24/0x30 [ 1.444525] bus_add_driver+0xe4/0x208 [ 1.444874] driver_register+0x60/0x128 [ 1.445233] __platform_driver_register+0x24/0x30 [ 1.445662] armv8_pmu_driver_init+0x28/0x4c [ 1.446059] do_one_initcall+0x44/0x25c [ 1.446416] kernel_init_freeable+0x1dc/0x3bc [ 1.446820] kernel_init+0x20/0x1d8 [ 1.447151] ret_from_fork+0x10/0x20 [ 1.447493] Code: 90022e21 f000e5f5 910de2b5 2a1703e2 (f8767803) [ 1.448040] ---[ end trace 0000000000000000 ]--- [ 1.448483] note: swapper/0[1] exited with preempt_count 1 [ 1.449047] Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b [ 1.449741] SMP: stopping secondary CPUs [ 1.450105] Kernel Offset: disabled [ 1.450419] CPU features: 0x000000,00080000,20002001,0400421b [ 1.450935] Memory Limit: none [ 1.451217] ---[ end Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b ]--- Yury: with the fix, the function returns cpu == nr_cpu_ids, and later in smp_call_function_any -> smp_call_function_single -> generic_exec_single we test the cpu for '>= nr_cpu_ids' and return -ENXIO. So everything is handled correctly. The Linux kernel CVE team has assigned CVE-2025-39895 to this issue. Affected and fixed versions =========================== Issue introduced in 6.3 with commit cd7f55359c90a4108e6528e326b8623fce1ad72a and fixed in 6.6.105 with commit f9b8d4dba8e78c1887fecd81ba0d8204d6ff05fc Issue introduced in 6.3 with commit cd7f55359c90a4108e6528e326b8623fce1ad72a and fixed in 6.12.46 with commit b3ec50cc5eb5ca84256ca701d28b137a6036c412 Issue introduced in 6.3 with commit cd7f55359c90a4108e6528e326b8623fce1ad72a and fixed in 6.16.6 with commit b921c288cd8abef9af5b59e056a63cc2c263a9e3 Issue introduced in 6.3 with commit cd7f55359c90a4108e6528e326b8623fce1ad72a and fixed in 6.17 with commit 5ebf512f335053a42482ebff91e46c6dc156bf8c Please see https://www.kernel.org for a full list of currently supported kernel versions by the kernel community. Unaffected versions might change over time as fixes are backported to older supported kernel versions. The official CVE entry at https://cve.org/CVERecord/?id=CVE-2025-39895 will be updated if fixes are backported, please check that for the most up to date information about this issue. Affected files ============== The file(s) affected by this issue are: kernel/sched/topology.c Mitigation ========== The Linux kernel CVE team recommends that you update to the latest stable kernel version for this, and many other bugfixes. Individual changes are never tested alone, but rather are part of a larger kernel release. Cherry-picking individual commits is not recommended or supported by the Linux kernel community at all. If however, updating to the latest release is impossible, the individual changes to resolve this issue can be found at these commits: https://git.kernel.org/stable/c/f9b8d4dba8e78c1887fecd81ba0d8204d6ff05fc https://git.kernel.org/stable/c/b3ec50cc5eb5ca84256ca701d28b137a6036c412 https://git.kernel.org/stable/c/b921c288cd8abef9af5b59e056a63cc2c263a9e3 https://git.kernel.org/stable/c/5ebf512f335053a42482ebff91e46c6dc156bf8c