diff options
author | Dave Voutila <dv@cvs.openbsd.org> | 2021-09-03 11:47:06 +0000 |
---|---|---|
committer | Dave Voutila <dv@cvs.openbsd.org> | 2021-09-03 11:47:06 +0000 |
commit | af4bbf2afb7034582c1ce322a0d005dc5ba3cce6 (patch) | |
tree | cd1dc36c800f4be1c5080cd555499f4fa5140ba4 /sys/arch/amd64 | |
parent | d6f5b90a943b82adb77749c6c0fe3728b7313c70 (diff) |
vmm(4): grab kernel lock before vmspace init
We need the kernel lock before calling some uvm functions. Fixes a
panic reported by syzbot.
Reported-by: syzbot+dd7a70eaf794705db27e@syzkaller.appspotmail.com
ok mlarkin@
Diffstat (limited to 'sys/arch/amd64')
-rw-r--r-- | sys/arch/amd64/amd64/vmm.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/sys/arch/amd64/amd64/vmm.c b/sys/arch/amd64/amd64/vmm.c index ffe06fb0b89..c04a1f05bf4 100644 --- a/sys/arch/amd64/amd64/vmm.c +++ b/sys/arch/amd64/amd64/vmm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vmm.c,v 1.289 2021/09/02 07:19:53 dv Exp $ */ +/* $OpenBSD: vmm.c,v 1.290 2021/09/03 11:47:05 dv Exp $ */ /* * Copyright (c) 2014 Mike Larkin <mlarkin@openbsd.org> * @@ -1685,14 +1685,20 @@ vm_impl_init_svm(struct vm *vm, struct proc *p) int vm_impl_init(struct vm *vm, struct proc *p) { + int ret; + + KERNEL_LOCK(); if (vmm_softc->mode == VMM_MODE_VMX || vmm_softc->mode == VMM_MODE_EPT) - return vm_impl_init_vmx(vm, p); + ret = vm_impl_init_vmx(vm, p); else if (vmm_softc->mode == VMM_MODE_SVM || vmm_softc->mode == VMM_MODE_RVI) - return vm_impl_init_svm(vm, p); + ret = vm_impl_init_svm(vm, p); else panic("%s: unknown vmm mode: %d", __func__, vmm_softc->mode); + KERNEL_UNLOCK(); + + return (ret); } /* |