|
|
|
|
|
|
|
|
|
|
xen-changelog
[Xen-changelog] [xen-3.4-testing] libxc: Check there's enough memory for
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1265625271 0
# Node ID 12b5a705c29fb0af5d9ca10bcb6b3cbaeed13be2
# Parent 11c5101f526708ec8a7118329e07bb1fffa9eca4
libxc: Check there's enough memory for segments we're creating
Previously, xc_dom_alloc_segment would go ahead even if the segment
we're trying to create is too big for the domain's RAM (or the
requested addr is out of range). It would pass invalid parameters to
xc_dom_seg_to_ptr giving undefined behaviour.
Fixing xc_dom_seg_to_ptr to fail is not sufficient because we want to
provide a comprehensible explanation to the caller - which may
ultimately be the user.
In particular, with this change attempting "xl create" with a ramdisk
image bigger than the guest's specified RAM will provide a useful
error message mentioning the ramdisk.
Signed-off-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
xen-unstable changeset: 20889:7a10f8513b3f
xen-unstable date: Wed Feb 03 09:46:01 2010 +0000
---
tools/libxc/xc_dom_core.c | 13 ++++++++++++-
1 files changed, 12 insertions(+), 1 deletion(-)
diff -r 11c5101f5267 -r 12b5a705c29f tools/libxc/xc_dom_core.c
--- a/tools/libxc/xc_dom_core.c Mon Feb 08 10:34:07 2010 +0000
+++ b/tools/libxc/xc_dom_core.c Mon Feb 08 10:34:31 2010 +0000
@@ -409,8 +409,19 @@ int xc_dom_alloc_segment(struct xc_dom_i
}
seg->vstart = start;
+ seg->pfn = (seg->vstart - dom->parms.virt_base) / page_size;
+
+ if ( pages > dom->total_pages || /* double test avoids overflow probs */
+ pages > dom->total_pages - seg->pfn)
+ {
+ xc_dom_panic(XC_OUT_OF_MEMORY,
+ "%s: segment %s too large (0x%"PRIpfn" > "
+ "0x%"PRIpfn" - 0x%"PRIpfn" pages)\n",
+ __FUNCTION__, name, pages, dom->total_pages, seg->pfn);
+ return -1;
+ }
+
seg->vend = start + pages * page_size;
- seg->pfn = (seg->vstart - dom->parms.virt_base) / page_size;
dom->virt_alloc_end = seg->vend;
if (dom->allocate)
dom->allocate(dom, dom->virt_alloc_end);
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|
<Prev in Thread] |
Current Thread |
[Next in Thread> |
- [Xen-changelog] [xen-3.4-testing] libxc: Check there's enough memory for segments we're creating,
Xen patchbot-3.4-testing <=
|
|
|
|
|