Patch "sched/topology: Fix sched_numa_find_nth_cpu() in CPU-less case" has been added to the 6.6-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    sched/topology: Fix sched_numa_find_nth_cpu() in CPU-less case

to the 6.6-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     sched-topology-fix-sched_numa_find_nth_cpu-in-cpu-le.patch
and it can be found in the queue-6.6 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 57ea1086724953b69f8b3951e5c5832e892ff6aa
Author: Yury Norov <yury.norov@xxxxxxxxx>
Date:   Sat Aug 19 07:12:35 2023 -0700

    sched/topology: Fix sched_numa_find_nth_cpu() in CPU-less case
    
    [ Upstream commit 617f2c38cb5ce60226042081c09e2ee3a90d03f8 ]
    
    When the node provided by user is CPU-less, corresponding record in
    sched_domains_numa_masks is not set. Trying to dereference it in the
    following code leads to kernel crash.
    
    To avoid it, start searching from the nearest node with CPUs.
    
    Fixes: cd7f55359c90 ("sched: add sched_numa_find_nth_cpu()")
    Reported-by: Yicong Yang <yangyicong@xxxxxxxxxxxxx>
    Reported-by: Guenter Roeck <linux@xxxxxxxxxxxx>
    Signed-off-by: Yury Norov <yury.norov@xxxxxxxxx>
    Signed-off-by: Ingo Molnar <mingo@xxxxxxxxxx>
    Reviewed-by: Yicong Yang <yangyicong@xxxxxxxxxxxxx>
    Cc: Mel Gorman <mgorman@xxxxxxx>
    Link: https://lore.kernel.org/r/20230819141239.287290-4-yury.norov@xxxxxxxxx
    
    Closes: https://lore.kernel.org/lkml/CAAH8bW8C5humYnfpW3y5ypwx0E-09A3QxFE1JFzR66v+mO4XfA@xxxxxxxxxxxxxx/T/
    Closes: https://lore.kernel.org/lkml/ZMHSNQfv39HN068m@yury-ThinkPad/T/#mf6431cb0b7f6f05193c41adeee444bc95bf2b1c4
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c
index 05a5bc678c089..423d08947962c 100644
--- a/kernel/sched/topology.c
+++ b/kernel/sched/topology.c
@@ -2122,12 +2122,16 @@ static int hop_cmp(const void *a, const void *b)
  */
 int sched_numa_find_nth_cpu(const struct cpumask *cpus, int cpu, int node)
 {
-	struct __cmp_key k = { .cpus = cpus, .node = node, .cpu = cpu };
+	struct __cmp_key k = { .cpus = cpus, .cpu = cpu };
 	struct cpumask ***hop_masks;
 	int hop, ret = nr_cpu_ids;
 
 	rcu_read_lock();
 
+	/* CPU-less node entries are uninitialized in sched_domains_numa_masks */
+	node = numa_nearest_node(node, N_CPU);
+	k.node = node;
+
 	k.masks = rcu_dereference(sched_domains_numa_masks);
 	if (!k.masks)
 		goto unlock;



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux