From owner-svn-src-all@FreeBSD.ORG Thu Jul 18 18:40:54 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id A7D3AB1A; Thu, 18 Jul 2013 18:40:54 +0000 (UTC) (envelope-from grehan@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 9A973F50; Thu, 18 Jul 2013 18:40:54 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6IIes44027562; Thu, 18 Jul 2013 18:40:54 GMT (envelope-from grehan@svn.freebsd.org) Received: (from grehan@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6IIesot027561; Thu, 18 Jul 2013 18:40:54 GMT (envelope-from grehan@svn.freebsd.org) Message-Id: <201307181840.r6IIesot027561@svn.freebsd.org> From: Peter Grehan Date: Thu, 18 Jul 2013 18:40:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r253452 - head/usr.sbin/bhyve X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 18 Jul 2013 18:40:54 -0000 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);