Skip to content

Commit 9e3d62d

Browse files
svens-s390Vasily Gorbik
authored andcommitted
s390/topology: clear thread/group maps for offline cpus
The current code doesn't clear the thread/group maps for offline CPUs. This may cause kernel crashes like the one bewlow in common code that assumes if a CPU has sibblings it is online. Unable to handle kernel pointer dereference in virtual kernel address space Call Trace: [<000000013a4b8c3c>] blk_mq_map_swqueue+0x10c/0x388 ([<000000013a4b8bcc>] blk_mq_map_swqueue+0x9c/0x388) [<000000013a4b9300>] blk_mq_init_allocated_queue+0x448/0x478 [<000000013a4b9416>] blk_mq_init_queue+0x4e/0x90 [<000003ff8019d3e6>] loop_add+0x106/0x278 [loop] [<000003ff801b8148>] loop_init+0x148/0x1000 [loop] [<0000000139de4924>] do_one_initcall+0x3c/0x1e0 [<0000000139ef449a>] do_init_module+0x6a/0x2a0 [<0000000139ef61bc>] __do_sys_finit_module+0xa4/0xc0 [<0000000139de9e6e>] do_syscall+0x7e/0xd0 [<000000013a8e0aec>] __do_syscall+0xbc/0x110 [<000000013a8ee2e8>] system_call+0x78/0xa0 Fixes: 52aeda7 ("s390/topology: remove offline CPUs from CPU topology masks") Cc: <[email protected]> # 5.7+ Reported-by: Marius Hillenbrand <[email protected]> Signed-off-by: Sven Schnelle <[email protected]> Reviewed-by: Heiko Carstens <[email protected]> Signed-off-by: Vasily Gorbik <[email protected]>
1 parent 8c0795d commit 9e3d62d

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

arch/s390/kernel/topology.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,10 @@ static void cpu_group_map(cpumask_t *dst, struct mask_info *info, unsigned int c
6666
{
6767
static cpumask_t mask;
6868

69-
cpumask_copy(&mask, cpumask_of(cpu));
69+
cpumask_clear(&mask);
70+
if (!cpu_online(cpu))
71+
goto out;
72+
cpumask_set_cpu(cpu, &mask);
7073
switch (topology_mode) {
7174
case TOPOLOGY_MODE_HW:
7275
while (info) {
@@ -83,10 +86,10 @@ static void cpu_group_map(cpumask_t *dst, struct mask_info *info, unsigned int c
8386
default:
8487
fallthrough;
8588
case TOPOLOGY_MODE_SINGLE:
86-
cpumask_copy(&mask, cpumask_of(cpu));
8789
break;
8890
}
8991
cpumask_and(&mask, &mask, cpu_online_mask);
92+
out:
9093
cpumask_copy(dst, &mask);
9194
}
9295

@@ -95,7 +98,10 @@ static void cpu_thread_map(cpumask_t *dst, unsigned int cpu)
9598
static cpumask_t mask;
9699
int i;
97100

98-
cpumask_copy(&mask, cpumask_of(cpu));
101+
cpumask_clear(&mask);
102+
if (!cpu_online(cpu))
103+
goto out;
104+
cpumask_set_cpu(cpu, &mask);
99105
if (topology_mode != TOPOLOGY_MODE_HW)
100106
goto out;
101107
cpu -= cpu % (smp_cpu_mtid + 1);

0 commit comments

Comments
 (0)