aboutsummaryrefslogtreecommitdiffstats
path: root/tools/libxc/xc_dom_arm.c
diff options
context:
space:
mode:
authorIan Jackson <ian.jackson@eu.citrix.com>2013-06-14 16:39:38 +0100
committerIan Jackson <Ian.Jackson@eu.citrix.com>2013-06-14 16:39:38 +0100
commit3d5a1d4733e55e33521cd5004cab1313e5c5d5ff (patch)
tree24b11362d42baa63117d9bb660d6ecce3602c83b /tools/libxc/xc_dom_arm.c
parentaaebaba5ae225f591e0602e071037a935bb281b6 (diff)
downloadxen-3d5a1d4733e55e33521cd5004cab1313e5c5d5ff.tar.gz
xen-3d5a1d4733e55e33521cd5004cab1313e5c5d5ff.tar.bz2
xen-3d5a1d4733e55e33521cd5004cab1313e5c5d5ff.zip
libxc: check return values from malloc
A sufficiently malformed input to libxc (such as a malformed input ELF or other guest-controlled data) might cause one of libxc's malloc() to fail. In this case we need to make sure we don't dereference or do pointer arithmetic on the result. Search for all occurrences of \b(m|c|re)alloc in libxc, and all functions which call them, and add appropriate error checking where missing. This includes the functions xc_dom_malloc*, which now print a message when they fail so that callers don't have to do so. The function xc_cpuid_to_str wasn't provided with a sane return value and has a pretty strange API, which now becomes a little stranger. There are no in-tree callers. This is part of the fix to a security issue, XSA-55. Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com> v8: Move a check in xc_exchange_page to the previous patch (ie, remove it from this patch). v7: Add a missing check for a call to alloc_str. Add arithmetic overflow check in xc_dom_malloc. Coding style fix. v6: Fix a missed call `pfn_err = calloc...' in xc_domain_restore.c. Fix a missed call `new_pfn = xc_map_foreign_range...' in xc_offline_page.c v5: This patch is new in this version of the series.
Diffstat (limited to 'tools/libxc/xc_dom_arm.c')
-rw-r--r--tools/libxc/xc_dom_arm.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/tools/libxc/xc_dom_arm.c b/tools/libxc/xc_dom_arm.c
index aaf35ca70d..df59ffb84c 100644
--- a/tools/libxc/xc_dom_arm.c
+++ b/tools/libxc/xc_dom_arm.c
@@ -170,6 +170,8 @@ int arch_setup_meminit(struct xc_dom_image *dom)
dom->shadow_enabled = 1;
dom->p2m_host = xc_dom_malloc(dom, sizeof(xen_pfn_t) * dom->total_pages);
+ if ( dom->p2m_host == NULL )
+ return -EINVAL;
/* setup initial p2m */
for ( pfn = 0; pfn < dom->total_pages; pfn++ )