Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 15 Sep 2020 21:28:48 +0000 (UTC)
From:      Ed Maste <emaste@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r365777 - in stable: 11/sys/amd64/vmm/amd 11/sys/amd64/vmm/intel 12/sys/amd64/vmm/amd 12/sys/amd64/vmm/intel
Message-ID:  <202009152128.08FLSmJO034135@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: emaste
Date: Tue Sep 15 21:28:47 2020
New Revision: 365777
URL: https://svnweb.freebsd.org/changeset/base/365777

Log:
  MFC r365775: bhyve: do not permit write access to VMCB / VMCS
  
  Reported by:	Patrick Mooney
  Submitted by:	jhb
  Security:	CVE-2020-24718

Modified:
  stable/11/sys/amd64/vmm/amd/svm.c
  stable/11/sys/amd64/vmm/intel/vmx.c
Directory Properties:
  stable/11/   (props changed)

Changes in other areas also in this revision:
Modified:
  stable/12/sys/amd64/vmm/amd/svm.c
  stable/12/sys/amd64/vmm/intel/vmx.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/11/sys/amd64/vmm/amd/svm.c
==============================================================================
--- stable/11/sys/amd64/vmm/amd/svm.c	Tue Sep 15 21:07:30 2020	(r365776)
+++ stable/11/sys/amd64/vmm/amd/svm.c	Tue Sep 15 21:28:47 2020	(r365777)
@@ -2202,8 +2202,11 @@ svm_setreg(void *arg, int vcpu, int ident, uint64_t va
 		return (svm_modify_intr_shadow(svm_sc, vcpu, val));
 	}
 
-	if (vmcb_write(svm_sc, vcpu, ident, val) == 0) {
-		return (0);
+	/* Do not permit user write access to VMCB fields by offset. */
+	if (!VMCB_ACCESS_OK(ident)) {
+		if (vmcb_write(svm_sc, vcpu, ident, val) == 0) {
+			return (0);
+		}
 	}
 
 	reg = swctx_regptr(svm_get_guest_regctx(svm_sc, vcpu), ident);

Modified: stable/11/sys/amd64/vmm/intel/vmx.c
==============================================================================
--- stable/11/sys/amd64/vmm/intel/vmx.c	Tue Sep 15 21:07:30 2020	(r365776)
+++ stable/11/sys/amd64/vmm/intel/vmx.c	Tue Sep 15 21:28:47 2020	(r365777)
@@ -3215,6 +3215,10 @@ vmx_setreg(void *arg, int vcpu, int reg, uint64_t val)
 	if (vmxctx_setreg(&vmx->ctx[vcpu], reg, val) == 0)
 		return (0);
 
+	/* Do not permit user write access to VMCS fields by offset. */
+	if (reg < 0)
+		return (EINVAL);
+
 	error = vmcs_setreg(&vmx->vmcs[vcpu], running, reg, val);
 
 	if (error == 0) {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202009152128.08FLSmJO034135>