From: Ian Campbell Subject: [PATCH] libxc: restore: bounds check for start_info.{store_mfn, console.domU.mfn} Date: Fri, 20 Jul 2012 15:13:38 +0100 Message-ID: <5e8449a87a993cc2d2fb.1342793618@cosworth.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xen.org Cc: ian.jackson@citrix.com, Jonathan Ludlam List-Id: xen-devel@lists.xenproject.org # HG changeset patch # User Ian Campbell # Date 1342793598 -3600 # Node ID 5e8449a87a993cc2d2fb89a6ba0bbdc1df916771 # Parent 79cfa1892a5d55f2c137da6d4f2d5f261b47db26 libxc: restore: bounds check for start_info.{store_mfn,console.domU.mfn} These fields are canonicalised by the guest on suspend and therefore must be valid pfns during restore. Reported-by: Jonathan Ludlam Signed-off-by: Ian Campbell diff -r 79cfa1892a5d -r 5e8449a87a99 tools/libxc/xc_domain_restore.c --- a/tools/libxc/xc_domain_restore.c Fri Jul 20 14:51:05 2012 +0100 +++ b/tools/libxc/xc_domain_restore.c Fri Jul 20 15:13:18 2012 +0100 @@ -1912,9 +1912,21 @@ int xc_domain_restore(xc_interface *xch, SET_FIELD(start_info, nr_pages, dinfo->p2m_size); SET_FIELD(start_info, shared_info, shared_info_frame< dinfo->p2m_size ) + { + ERROR("Suspend record xenstore frame number is bad"); + munmap(start_info, PAGE_SIZE); + goto out; + } *store_mfn = ctx->p2m[GET_FIELD(start_info, store_mfn)]; SET_FIELD(start_info, store_mfn, *store_mfn); SET_FIELD(start_info, store_evtchn, store_evtchn); + if ( GET_FIELD(start_info, console.domU.mfn) > dinfo->p2m_size ) + { + ERROR("Suspend record console frame number is bad"); + munmap(start_info, PAGE_SIZE); + goto out; + } *console_mfn = ctx->p2m[GET_FIELD(start_info, console.domU.mfn)]; SET_FIELD(start_info, console.domU.mfn, *console_mfn); SET_FIELD(start_info, console.domU.evtchn, console_evtchn);