xen/sched: fix adding offline cpu to cpupool

Trying to add an offline cpu to a cpupool can crash the hypervisor,
as the probably non-existing percpu area of the cpu is accessed before
the availability of the cpu is being tested. This can happen in case
the cpupool's granularity is "core" or "socket".

Fix that by testing the cpu to be online.

Fixes: cb563d7665 ("xen/sched: support core scheduling for moving cpus to/from cpupools")
Reported-by: René Winther Højgaard <renewin@proton.me>
Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
master commit: 06e8d65d33
master date: 2023-12-05 09:57:38 +0100
This commit is contained in:
Juergen Gross authored and Jan Beulich committed 2023-12-06 10:40:54 +01:00
1 parent 18f900b77b
commit 5ac87c8afd
1 file changed
+2
+2
View File
@@ -892,6 +892,8 @@ int cpupool_do_sysctl(struct xen_sysctl_cpupool_op *op)
if ( cpu >= nr_cpu_ids )
goto addcpu_out;
ret = -ENODEV;
if ( !cpu_online(cpu) )
goto addcpu_out;
cpus = sched_get_opt_cpumask(c->gran, cpu);
if ( !cpumask_subset(cpus, &cpupool_free_cpus) ||
cpumask_intersects(cpus, &cpupool_locked_cpus) )
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.