summaryrefslogtreecommitdiffstats
path: root/usr.sbin/bhyve
diff options
context:
space:
mode:
authorgrehan <grehan@FreeBSD.org>2013-07-18 18:40:54 +0000
committergrehan <grehan@FreeBSD.org>2013-07-18 18:40:54 +0000
commitdc702c2d98e918027ccf108fa34855cf390caac6 (patch)
tree38ec4e15ec4f95e0d73e450b597497b1e0e72742 /usr.sbin/bhyve
parent71f36ebafc0f4422d0ac42c0b8d466d57f14bedd (diff)
downloadFreeBSD-src-dc702c2d98e918027ccf108fa34855cf390caac6.zip
FreeBSD-src-dc702c2d98e918027ccf108fa34855cf390caac6.tar.gz
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
Diffstat (limited to 'usr.sbin/bhyve')
-rw-r--r--usr.sbin/bhyve/bhyverun.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/usr.sbin/bhyve/bhyverun.c b/usr.sbin/bhyve/bhyverun.c
index cfcf7ec..43eea98 100644
--- a/usr.sbin/bhyve/bhyverun.c
+++ b/usr.sbin/bhyve/bhyverun.c
@@ -509,6 +509,7 @@ vm_loop(struct vmctx *ctx, int vcpu, uint64_t rip)
{
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, uint64_t rip)
}
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);
OpenPOWER on IntegriCloud