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); _______________________________________________ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"