]> xenbits.xensource.com Git - xen.git/commit
libxc: check return values from malloc
authorIan Jackson <ian.jackson@eu.citrix.com>
Fri, 14 Jun 2013 15:45:41 +0000 (16:45 +0100)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Fri, 14 Jun 2013 15:45:41 +0000 (16:45 +0100)
commita2986a7959919bc748784bb75970bfbd42697d3b
treee27e2d46beeb2b9c4ab5aa9ba40a8e71421bf104
parent117a538dbef62f8d39159dea652e633e01b50a9a
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.

Changes in the Xen 4.2 version of this series:
* No need to fix code relating to ARM.
* No need to fix code relating to superpage support.
* Additionally fix `dom->p2m_host = xc_dom_malloc...' in xc_dom_ia64.c.

Changes in the Xen 4.1 version of this series:
* An additional check is needed in xc_flask.c:xc_flask_access.

This is part of the fix to a security issue, XSA-55.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
tools/libxc/xc_cpuid_x86.c
tools/libxc/xc_dom_core.c
tools/libxc/xc_dom_elfloader.c
tools/libxc/xc_dom_ia64.c
tools/libxc/xc_dom_x86.c
tools/libxc/xc_domain_restore.c
tools/libxc/xc_flask.c
tools/libxc/xc_linux_osdep.c
tools/libxc/xc_private.c
tools/libxc/xenctrl.h