From: Ian Campbell <Ian.Campbell@citrix.com>
To: xen-devel <xen-devel@lists.xen.org>
Cc: Ian Jackson <Ian.Jackson@eu.citrix.com>,
Wei Liu <wei.liu2@citrix.com>, Jan Beulich <jbeulich@suse.com>
Subject: [PATCH] libxc: x86: ensure that the initial mapping fits into the guest's memory
Date: Fri, 4 Jan 2013 16:52:40 +0000 [thread overview]
Message-ID: <1357318360.14291.93.camel@zakaz.uk.xensource.com> (raw)
In-Reply-To: <E1Tr9he-0007fM-NC@xenbits.xen.org>
On Fri, 2013-01-04 at 16:01 +0000, Xen.org security team wrote:
> Xen Security Advisory CVE-2013-0154 / XSA-37
>
> Hypervisor crash due to incorrect ASSERT (debug build only)
This issue was exposed/triggered by a libxc bug, the fix for which is
below.
8<---------------------------------
# HG changeset patch
# User Ian Campbell <ijc@hellion.org.uk>
# Date 1357318325 0
# Node ID 84dea8458c36e6ee7d9347d32455cbeb5595825b
# Parent 7a61269a0c1ab33cc93b47f88d760f0d1f88eaab
libxc: x86: ensure that the initial mapping fits into the guest's memory
In particular we need to check that adding 512KB of slack and
rounding up to a 4MB boundary do not overflow the guest's memory
allocation. Otherwise we run off the end of the p2m when building the
guest's initial page tables and populate them with garbage.
Wei noticed this when build tiny (2MB) mini-os domains.
Reported-by: Wei Liu <Wei.Liu2@citrix.com>
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
diff -r 7a61269a0c1a -r 84dea8458c36 tools/libxc/xc_dom_core.c
--- a/tools/libxc/xc_dom_core.c Thu Jan 03 16:31:44 2013 +0000
+++ b/tools/libxc/xc_dom_core.c Fri Jan 04 16:52:05 2013 +0000
@@ -873,7 +873,8 @@ int xc_dom_build_image(struct xc_dom_ima
goto err;
if ( dom->arch_hooks->count_pgtables )
{
- dom->arch_hooks->count_pgtables(dom);
+ if ( dom->arch_hooks->count_pgtables(dom) != 0 )
+ goto err;
if ( (dom->pgtables > 0) &&
(xc_dom_alloc_segment(dom, &dom->pgtables_seg, "page tables", 0,
dom->pgtables * page_size) != 0) )
diff -r 7a61269a0c1a -r 84dea8458c36 tools/libxc/xc_dom_x86.c
--- a/tools/libxc/xc_dom_x86.c Thu Jan 03 16:31:44 2013 +0000
+++ b/tools/libxc/xc_dom_x86.c Fri Jan 04 16:52:05 2013 +0000
@@ -91,6 +91,15 @@ static int count_pgtables(struct xc_dom_
{
try_virt_end = round_up(dom->virt_alloc_end + pages * PAGE_SIZE_X86,
bits_to_mask(22)); /* 4MB alignment */
+
+ if ( (try_virt_end >> PAGE_SHIFT_X86) > dom->total_pages )
+ {
+ xc_dom_panic(dom->xch, XC_OUT_OF_MEMORY,
+ "%s: not enough memory for initial mapping",
+ __FUNCTION__);
+ return -ENOMEM;
+ }
+
dom->pg_l4 =
nr_page_tables(dom, dom->parms.virt_base, try_virt_end, l4_bits);
dom->pg_l3 =
next parent reply other threads:[~2013-01-04 16:52 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <E1Tr9he-0007fM-NC@xenbits.xen.org>
2013-01-04 16:52 ` Ian Campbell [this message]
2013-01-07 7:00 ` [PATCH] libxc: x86: ensure that the initial mapping fits into the guest's memory Jan Beulich
2013-01-07 10:35 ` Jan Beulich
2013-01-07 10:37 ` Ian Campbell
2013-01-07 11:05 ` Jan Beulich
2013-01-07 11:39 ` Ian Campbell
2013-01-07 13:37 ` [PATCH V2] " Ian Campbell
2013-01-07 10:21 ` Security support for debug=y builds (Was Re: Xen Security Advisory 37 (CVE-2013-0154) - Hypervisor crash due to incorrect ASSERT (debug build only)) Ian Campbell
2013-01-07 11:08 ` Keir Fraser
2013-01-07 11:21 ` Andrew Cooper
2013-01-07 11:36 ` Ian Campbell
2013-01-07 12:58 ` James Bulpin
2013-01-07 16:22 ` Keir Fraser
2013-02-08 11:25 ` Ian Campbell
2013-02-08 11:29 ` Ian Campbell
2013-02-08 11:29 ` Ian Campbell
2013-02-08 11:40 ` Jan Beulich
2013-02-08 11:47 ` Ian Campbell
2013-01-07 11:09 ` Jan Beulich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1357318360.14291.93.camel@zakaz.uk.xensource.com \
--to=ian.campbell@citrix.com \
--cc=Ian.Jackson@eu.citrix.com \
--cc=jbeulich@suse.com \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.