Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 18 Jul 2013 18:40:54 +0000 (UTC)
From:      Peter Grehan <grehan@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r253452 - head/usr.sbin/bhyve
Message-ID:  <201307181840.r6IIesot027561@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: grehan
Date: Thu Jul 18 18:40:54 2013
New Revision: 253452
URL: http://svnweb.freebsd.org/changeset/base/253452

Log:
  Sanity-check the vm exitcode, and exit the process if it's out-of-bounds
  or there is no registered handler.
  
  Submitted by:	Bela Lubkin   bela dot lubkin at tidalscale dot com

Modified:
  head/usr.sbin/bhyve/bhyverun.c

Modified: head/usr.sbin/bhyve/bhyverun.c
==============================================================================
--- head/usr.sbin/bhyve/bhyverun.c	Thu Jul 18 17:25:50 2013	(r253451)
+++ head/usr.sbin/bhyve/bhyverun.c	Thu Jul 18 18:40:54 2013	(r253452)
@@ -509,6 +509,7 @@ vm_loop(struct vmctx *ctx, int vcpu, uin
 {
 	cpuset_t mask;
 	int error, rc, prevcpu;
+	enum vm_exitcode exitcode;
 
 	if (guest_vcpu_mux)
 		setup_timeslice();
@@ -538,8 +539,16 @@ vm_loop(struct vmctx *ctx, int vcpu, uin
 		}
 
 		prevcpu = vcpu;
-                rc = (*handler[vmexit[vcpu].exitcode])(ctx, &vmexit[vcpu],
-                                                       &vcpu);		
+
+		exitcode = vmexit[vcpu].exitcode;
+		if (exitcode >= VM_EXITCODE_MAX || handler[exitcode] == NULL) {
+			fprintf(stderr, "vm_loop: unexpected exitcode 0x%x\n",
+			    exitcode);
+			exit(1);
+		}
+
+                rc = (*handler[exitcode])(ctx, &vmexit[vcpu], &vcpu);
+
 		switch (rc) {
                 case VMEXIT_SWITCH:
 			assert(guest_vcpu_mux);



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