https://github.com/torvalds/linux
Revision 3366cdb6d350d95466ee430ac50f3c8415ca8f46 authored by Olaf Hering on 07 September 2018, 14:31:35 UTC, committed by Boris Ostrovsky on 14 September 2018, 12:51:10 UTC
The command 'xl vcpu-set 0 0', issued in dom0, will crash dom0:

BUG: unable to handle kernel NULL pointer dereference at 00000000000002d8
PGD 0 P4D 0
Oops: 0000 [#1] PREEMPT SMP NOPTI
CPU: 7 PID: 65 Comm: xenwatch Not tainted 4.19.0-rc2-1.ga9462db-default #1 openSUSE Tumbleweed (unreleased)
Hardware name: Intel Corporation S5520UR/S5520UR, BIOS S5500.86B.01.00.0050.050620101605 05/06/2010
RIP: e030:device_offline+0x9/0xb0
Code: 77 24 00 e9 ce fe ff ff 48 8b 13 e9 68 ff ff ff 48 8b 13 e9 29 ff ff ff 48 8b 13 e9 ea fe ff ff 90 66 66 66 66 90 41 54 55 53 <f6> 87 d8 02 00 00 01 0f 85 88 00 00 00 48 c7 c2 20 09 60 81 31 f6
RSP: e02b:ffffc90040f27e80 EFLAGS: 00010203
RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000000
RDX: ffff8801f3800000 RSI: ffffc90040f27e70 RDI: 0000000000000000
RBP: 0000000000000000 R08: ffffffff820e47b3 R09: 0000000000000000
R10: 0000000000007ff0 R11: 0000000000000000 R12: ffffffff822e6d30
R13: dead000000000200 R14: dead000000000100 R15: ffffffff8158b4e0
FS:  00007ffa595158c0(0000) GS:ffff8801f39c0000(0000) knlGS:0000000000000000
CS:  e033 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00000000000002d8 CR3: 00000001d9602000 CR4: 0000000000002660
Call Trace:
 handle_vcpu_hotplug_event+0xb5/0xc0
 xenwatch_thread+0x80/0x140
 ? wait_woken+0x80/0x80
 kthread+0x112/0x130
 ? kthread_create_worker_on_cpu+0x40/0x40
 ret_from_fork+0x3a/0x50

This happens because handle_vcpu_hotplug_event is called twice. In the
first iteration cpu_present is still true, in the second iteration
cpu_present is false which causes get_cpu_device to return NULL.
In case of cpu#0, cpu_online is apparently always true.

Fix this crash by checking if the cpu can be hotplugged, which is false
for a cpu that was just removed.

Also check if the cpu was actually offlined by device_remove, otherwise
leave the cpu_present state as it is.

Rearrange to code to do all work with device_hotplug_lock held.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Reviewed-by: Juergen Gross <jgross@suse.com>
Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
1 parent 197ecb3
History
Tip revision: 3366cdb6d350d95466ee430ac50f3c8415ca8f46 authored by Olaf Hering on 07 September 2018, 14:31:35 UTC
xen: avoid crash in disable_hotplug_cpu
Tip revision: 3366cdb
File Mode Size
kasan
Kconfig -rw-r--r-- 24.7 KB
Kconfig.debug -rw-r--r-- 3.8 KB
Makefile -rw-r--r-- 3.6 KB
backing-dev.c -rw-r--r-- 26.9 KB
balloon_compaction.c -rw-r--r-- 5.5 KB
bootmem.c -rw-r--r-- 19.8 KB
cleancache.c -rw-r--r-- 9.9 KB
cma.c -rw-r--r-- 13.9 KB
cma.h -rw-r--r-- 573 bytes
cma_debug.c -rw-r--r-- 4.5 KB
compaction.c -rw-r--r-- 58.7 KB
debug.c -rw-r--r-- 4.5 KB
debug_page_ref.c -rw-r--r-- 1.4 KB
dmapool.c -rw-r--r-- 13.7 KB
early_ioremap.c -rw-r--r-- 6.8 KB
fadvise.c -rw-r--r-- 5.0 KB
failslab.c -rw-r--r-- 1.4 KB
filemap.c -rw-r--r-- 89.3 KB
frame_vector.c -rw-r--r-- 6.4 KB
frontswap.c -rw-r--r-- 14.2 KB
gup.c -rw-r--r-- 50.6 KB
gup_benchmark.c -rw-r--r-- 2.1 KB
highmem.c -rw-r--r-- 11.7 KB
hmm.c -rw-r--r-- 37.9 KB
huge_memory.c -rw-r--r-- 81.0 KB
hugetlb.c -rw-r--r-- 130.1 KB
hugetlb_cgroup.c -rw-r--r-- 10.9 KB
hwpoison-inject.c -rw-r--r-- 3.2 KB
init-mm.c -rw-r--r-- 1.2 KB
internal.h -rw-r--r-- 16.4 KB
interval_tree.c -rw-r--r-- 3.1 KB
khugepaged.c -rw-r--r-- 48.9 KB
kmemleak-test.c -rw-r--r-- 3.2 KB
kmemleak.c -rw-r--r-- 59.0 KB
ksm.c -rw-r--r-- 88.2 KB
list_lru.c -rw-r--r-- 14.6 KB
maccess.c -rw-r--r-- 3.1 KB
madvise.c -rw-r--r-- 22.8 KB
memblock.c -rw-r--r-- 54.5 KB
memcontrol.c -rw-r--r-- 170.2 KB
memfd.c -rw-r--r-- 8.4 KB
memory-failure.c -rw-r--r-- 52.1 KB
memory.c -rw-r--r-- 128.0 KB
memory_hotplug.c -rw-r--r-- 49.1 KB
mempolicy.c -rw-r--r-- 71.4 KB
mempool.c -rw-r--r-- 15.5 KB
memtest.c -rw-r--r-- 2.8 KB
migrate.c -rw-r--r-- 77.8 KB
mincore.c -rw-r--r-- 6.7 KB
mlock.c -rw-r--r-- 22.6 KB
mm_init.c -rw-r--r-- 4.8 KB
mmap.c -rw-r--r-- 98.9 KB
mmu_context.c -rw-r--r-- 1.3 KB
mmu_notifier.c -rw-r--r-- 12.4 KB
mmzone.c -rw-r--r-- 2.4 KB
mprotect.c -rw-r--r-- 15.6 KB
mremap.c -rw-r--r-- 17.0 KB
msync.c -rw-r--r-- 2.6 KB
nobootmem.c -rw-r--r-- 10.9 KB
nommu.c -rw-r--r-- 47.6 KB
oom_kill.c -rw-r--r-- 30.6 KB
page-writeback.c -rw-r--r-- 84.3 KB
page_alloc.c -rw-r--r-- 222.3 KB
page_counter.c -rw-r--r-- 6.6 KB
page_ext.c -rw-r--r-- 11.1 KB
page_idle.c -rw-r--r-- 5.5 KB
page_io.c -rw-r--r-- 10.5 KB
page_isolation.c -rw-r--r-- 8.7 KB
page_owner.c -rw-r--r-- 15.1 KB
page_poison.c -rw-r--r-- 2.7 KB
page_vma_mapped.c -rw-r--r-- 6.9 KB
pagewalk.c -rw-r--r-- 8.7 KB
percpu-internal.h -rw-r--r-- 5.9 KB
percpu-km.c -rw-r--r-- 2.9 KB
percpu-stats.c -rw-r--r-- 5.7 KB
percpu-vm.c -rw-r--r-- 10.3 KB
percpu.c -rw-r--r-- 84.5 KB
pgtable-generic.c -rw-r--r-- 5.3 KB
process_vm_access.c -rw-r--r-- 10.0 KB
quicklist.c -rw-r--r-- 2.4 KB
readahead.c -rw-r--r-- 16.8 KB
rmap.c -rw-r--r-- 53.1 KB
rodata_test.c -rw-r--r-- 1.4 KB
shmem.c -rw-r--r-- 104.4 KB
slab.c -rw-r--r-- 110.8 KB
slab.h -rw-r--r-- 14.6 KB
slab_common.c -rw-r--r-- 37.5 KB
slob.c -rw-r--r-- 16.2 KB
slub.c -rw-r--r-- 141.3 KB
sparse-vmemmap.c -rw-r--r-- 6.6 KB
sparse.c -rw-r--r-- 20.5 KB
swap.c -rw-r--r-- 28.7 KB
swap_cgroup.c -rw-r--r-- 5.2 KB
swap_slots.c -rw-r--r-- 9.4 KB
swap_state.c -rw-r--r-- 22.4 KB
swapfile.c -rw-r--r-- 95.7 KB
truncate.c -rw-r--r-- 26.4 KB
usercopy.c -rw-r--r-- 9.4 KB
userfaultfd.c -rw-r--r-- 15.0 KB
util.c -rw-r--r-- 19.7 KB
vmacache.c -rw-r--r-- 3.7 KB
vmalloc.c -rw-r--r-- 69.6 KB
vmpressure.c -rw-r--r-- 13.9 KB
vmscan.c -rw-r--r-- 119.9 KB
vmstat.c -rw-r--r-- 51.6 KB
workingset.c -rw-r--r-- 18.0 KB
z3fold.c -rw-r--r-- 30.0 KB
zbud.c -rw-r--r-- 18.2 KB
zpool.c -rw-r--r-- 10.7 KB
zsmalloc.c -rw-r--r-- 60.4 KB
zswap.c -rw-r--r-- 34.7 KB

back to top