From: dv Date: Fri, 3 Sep 2021 11:47:05 +0000 (+0000) Subject: vmm(4): grab kernel lock before vmspace init X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=8e114673a836afc182cf07571ed0fce8e2401ff3;p=openbsd 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@ --- 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 * @@ -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); } /*