aboutsummaryrefslogtreecommitdiffstats
path: root/tools/libxc/xc_dom_core.c
Commit message (Collapse)AuthorAgeFilesLines
* libxc: Fix guest boot on ARM after XSA-55Julien Grall2013-06-261-4/+6
| | | | | | | | XSA-55 has exposed errors for guest creation on ARM: - domain virt_base was not defined; - xc_dom_alloc_segment allocates pfn from 0 instead of the RAM base address. Signed-off-by: Julien Grall <julien.grall@linaro.org>
* libxc: Better range check in xc_dom_alloc_segmentIan Jackson2013-06-141-1/+2
| | | | | | | | | | If seg->pfn is too large, the arithmetic in the range check might overflow, defeating the range check. 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>
* libxc: check blob size before proceeding in xc_dom_check_gzipMatthew Daley2013-06-141-0/+5
| | | | | | | | | | | | | This is part of the fix to a security issue, XSA-55. Signed-off-by: Matthew Daley <mattjd@gmail.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com> v8: Add a comment explaining where the number 6 comes from. v6: This patch is new in v6 of the series.
* libxc: check return values from mallocIan Jackson2013-06-141-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* libxc: check failure of xc_dom_*_to_ptr, xc_map_foreign_rangeIan Jackson2013-06-141-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The return values from xc_dom_*_to_ptr and xc_map_foreign_range are sometimes dereferenced, or subjected to pointer arithmetic, without checking whether the relevant function failed and returned NULL. Add an appropriate error check at every call site. 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: Add a missing check in xc_offline_page.c:xc_exchange_page, which was in the next patch in v7 of the series. Also improve the message. I think in this particular error case it may be that the results are a broken guest, but turning this from a possible host tools crash into a guest problem seems to solve the potential security problem. v7: Simplify an error DOMPRINTF to not use "load ? : ". Make DOMPRINTF allocation error messages consistent. Do not set elf->dest_pages in xc_dom_load_elf_kernel if xc_dom_seg_to_ptr_pages fails. v5: This patch is new in this version of the series.
* libxc: Fix range checking in xc_dom_pfn_to_ptr etc.Ian Jackson2013-06-141-0/+13
| | | | | | | | | | | | | | | | | | | | | * Ensure that xc_dom_pfn_to_ptr (when called with count==0) does not return a previously-allocated block which is entirely before the requested pfn (!) * Provide a version of xc_dom_pfn_to_ptr, xc_dom_pfn_to_ptr_retcount, which provides the length of the mapped region via an out parameter. * Change xc_dom_vaddr_to_ptr to always provide the length of the mapped region and change the call site in xc_dom_binloader.c to check it. The call site in xc_dom_load_elf_symtab will be corrected in a forthcoming patch, and for now ignores the returned length. 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> v5: This patch is new in v5 of the series.
* Fix emacs local variable block to use correct C style variable.David Vrabel2013-02-211-1/+1
| | | | | | | The emacs variable to set the C style from a local variable block is c-file-style, not c-set-style. Signed-off-by: David Vrabel <david.vrabel@citrix.com
* libxc: x86: ensure that the initial mapping fits into the guest's memoryIan Campbell2013-01-111-1/+2
| | | | | | | | | | | | | | 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> Committed-by: Ian Campbell <ian.campbell@citrix.com>
* libxc: builder: limit maximum size of kernel/ramdisk.Ian Jackson2012-10-261-4/+73
| | | | | | | | | | | | | | | | | | | | | | Allowing user supplied kernels of arbitrary sizes, especially during decompression, can swallow up dom0 memory leading to either virtual address space exhaustion in the builder process or allocation failures/OOM killing of both toolstack and unrelated processes. We disable these checks when building in a stub domain for pvgrub since this uses the guest's own memory and is isolated. Decompression of gzip compressed kernels and ramdisks has been safe since 14954:58205257517d (Xen 3.1.0 onwards). This is XSA-25 / CVE-2012-4544. Also make explicit checks for buffer overflows in various decompression routines. These were already ruled out due to other properties of the code but check them as a belt-and-braces measure. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
* Revert 26109:6ccfe4d29f95Ian Jackson2012-10-261-73/+4
| | | | | | | This changeset was contaminated by changes hanging around in my working tree. Sorry :-(. Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
* xl: Do not leak events when a domain exits.Ian Campbell2012-10-251-4/+73
| | | | | | | | | | | | | | | | | | | | | | | | The goto in both of these places misses the event free which would normally clean up. ==8655== 80 bytes in 1 blocks are definitely lost in loss record 1 of 1 ==8655== at 0x4024370: calloc (vg_replace_malloc.c:593) ==8655== by 0x406EAAE: libxl__zalloc (libxl_internal.c:83) ==8655== by 0x4078173: libxl__event_new (libxl_event.c:1167) ==8655== by 0x4056373: domain_death_occurred (libxl.c:958) ==8655== by 0x4058D06: domain_death_xswatch_callback (libxl.c:1038) ==8655== by 0x4078EB5: watchfd_callback (libxl_event.c:458) ==8655== by 0x407839E: afterpoll_internal (libxl_event.c:949) ==8655== by 0x4079142: eventloop_iteration (libxl_event.c:1371) ==8655== by 0x40799BB: libxl_event_wait (libxl_event.c:1396) ==8655== by 0x805CC67: create_domain (xl_cmdimpl.c:1698) ==8655== by 0x805E001: main_create (xl_cmdimpl.c:3986) ==8655== by 0x804D43D: main (xl.c:285) Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
* libxc: add ARM support to xc_dom (PV domain building)Ian Campbell2012-10-091-4/+6
| | | | | | | | Includes ARM zImage support. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: Stefano Stabellini <Stefano.Stabellini@eu.citrix.com> Committed-by: Ian Campbell <ian.campbell@citrix.com>
* # HG changeset patchIan Campbell2010-08-241-1/+15
| | | | | | | | | | | | | | | | | | | | | | | | | # User Ian Campbell <ian.campbell@citrix.com> # Date 1282671421 -3600 # Node ID d1dd29a470ef1b9d2c77478a123326036dfe90bb # Parent d7a4adad9c328decbd384d87b23001aea8951b86 tools/libxc, tools/libelf: Relicense under LGPL v2.1 Relicense these two libraries under LGPL v2.1 only except where individual files already included the "or later" provision. Copyright holders have been contacted by Stephen Spector and have all agreed this change. Removed tools/libxc/ia64/aclinux.h since it appeared to be unused. There is a separate, more up to date, copy in xen/include/acpi/platform/aclinux.h which does appear to be used. Clarify the license of MiniOS privcmd.h under the same terms as other tools/include/xen-sys headers. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: Stephen Spector <stephen.spector@citrix.com> Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
* libxc: eliminate static variables, use xentoollog; API changeKeir Fraser2010-05-281-120/+133
| | | | | | | | | | | | | | | | | | | | This patch eliminate the global variables in libxenctrl (used for logging and error reporting). Instead the information which was in the global variables is now in a new xc_interface* opaque structure, which xc_interface open returns instead of the raw file descriptor; furthermore, logging is done via xentoollog. There are three new parameters to xc_interface_open to control the logging, but existing callers can just pass "0" for all three to get the old behaviour. All libxc callers have been adjusted accordingly. Also update QEMU_TAG for corresponding qemu change. Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
* libxc: Check there's enough memory for segments we're creatingKeir Fraser2010-02-031-1/+12
| | | | | | | | | | | | | | | | | 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@eu.citrix.com>
* libxc: Check full range of pfns for xc_dom_pfn_to_ptrKeir Fraser2010-02-031-1/+3
| | | | | | | | | | | | Previously, passing a valid pfn but an overly large count to xc_dom_pfn_to_ptr, and functions which call it, would run off the end of the pfn array giving undefined behaviour. It is tempting to change this check to an assert, as no callers should be providing invalid parameters here. But this is probably best not done while frozen for 4.0. Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
* libxc: Fix memory leak in zlib usageKeir Fraser2008-12-101-0/+1
| | | | | | | Any call to inflate() must be followed by inflateEnd(), otherwise the internal zlib state is leaked. Signed-off-by: Kevin Wolf <kwolf@suse.de>
* Add PV-GRUBKeir Fraser2008-06-181-1/+5
| | | | | | | | | | | This fetches GRUB1 sources, applies the {graphical, print function, save default, and ext3_256byte} patches from debian, and applies a patch to make it work on x86_64 and port it to Mini-OS. By using libxc, PV-GRUB can then "kexec" the loaded kernel from inside the domain itself, hence permitting to avoid the security-concerned pygrub. Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
* domain builder: make mmap() failure message more verbose.Keir Fraser2007-12-041-2/+6
| | | | Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
* libxc portability fixes for NetBSD.kfraser@localhost.localdomain2007-09-191-2/+2
| | | | | | | | | | | - use MAP_ANON, that is what both (BSD-)Unix and Linux have - change last_error handling to use pthreads - round mlock() parameters to page alignment - cleanup: No need to include <xen/sys/privcmd.h> a second time in xg_private.h Signed-off-by: Christoph Egger <Christoph.Egger@amd.com> Signed-off-by: Keir Fraser <keir@xensource.com>
* domain builder: Fix sanity check for gzip size.kfraser@localhost.localdomain2007-04-261-2/+2
| | | | Signed-off-by: Keir Fraser <keir@xensource.com>
* [LIBXC] Allocate memory and populate p2m in arch-specific code.Hollis Blanchard2007-03-211-5/+1
| | | | Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
* [domain builder] Remove unnecessary alignment of virtual address base.Christian Limpach2007-03-031-3/+0
| | | | | | Unbreaks loading NetBSD kernels with the new ^^ domain builder. Signed-off-by: Christian Limpach <Christian.Limpach@xensource.com>
* libxc: Code format cleanups.Keir Fraser2007-02-241-285/+298
| | | | Signed-off-by: Keir Fraser <keir@xensource.com>
* libxc: Domain builder must align initial virtual mapping to 4MBkfraser@localhost.localdomain2007-02-021-0/+3
| | | | | | boundaries. From: Gerd Hoffmann <kraxel@suse.de> Signed-off-by: Keir Fraser <keir@xensource.com>
* libxc domain builder rewrite, core bits.Emmanuel Ackaouy2007-01-251-0/+773
Signed-off-by: Gerd Hoffmann <kraxel@suse.de> --- tools/libxc/Makefile | 14 tools/libxc/xc_dom.h | 261 +++++++++++++ tools/libxc/xc_dom_binloader.c | 294 +++++++++++++++ tools/libxc/xc_dom_boot.c | 515 +++++++++++++++++++++++++++ tools/libxc/xc_dom_core.c | 773 +++++++++++++++++++++++++++++++++++++++++ tools/libxc/xc_dom_elfloader.c | 283 +++++++++++++++ tools/libxc/xc_dom_ia64.c | 118 ++++++ tools/libxc/xc_dom_powerpc64.c | 100 +++++ tools/libxc/xc_dom_x86.c | 559 +++++++++++++++++++++++++++++ 9 files changed, 2917 insertions(+)