xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Simon Gaiser <simon@invisiblethingslab.com>
To: xen-devel@lists.xenproject.org
Cc: "Simon Gaiser" <simon@invisiblethingslab.com>,
	"Wei Liu" <wei.liu2@citrix.com>,
	"Ian Jackson" <ian.jackson@eu.citrix.com>,
	"Roger Pau Monné" <roger.pau@citrix.com>
Subject: [PATCH 3/3] libxc: xc_dom_parse_elf_kernel: Return error for invalid kernel images
Date: Thu,  8 Feb 2018 22:49:10 +0100	[thread overview]
Message-ID: <20180208214910.10699-4-simon@invisiblethingslab.com> (raw)
In-Reply-To: <20180208214910.10699-1-simon@invisiblethingslab.com>

Commit 96edb111dd ("libxc: panic when trying to create a PVH guest
without kernel support") already improved the handling of non PVH
capable kernels. But xc_dom_parse_elf_kernel() still returned success on
invalid elf images and the domain build only failed later. Now the build
process will fail immediately on detecting the error.

Signed-off-by: Simon Gaiser <simon@invisiblethingslab.com>
---
 tools/libxc/xc_dom_elfloader.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/tools/libxc/xc_dom_elfloader.c b/tools/libxc/xc_dom_elfloader.c
index c936f92a66..26b2846365 100644
--- a/tools/libxc/xc_dom_elfloader.c
+++ b/tools/libxc/xc_dom_elfloader.c
@@ -64,7 +64,7 @@ static char *xc_dom_guest_type(struct xc_dom_image *dom,
         xc_dom_panic(dom->xch, XC_INVALID_KERNEL,
                      "%s: image not capable of booting inside a HVM container",
                      __FUNCTION__);
-        return "xen-3.0-unknown";
+        return NULL;
     }
 
     switch ( machine )
@@ -86,7 +86,10 @@ static char *xc_dom_guest_type(struct xc_dom_image *dom,
     case EM_X86_64:
         return "xen-3.0-x86_64";
     default:
-        return "xen-3.0-unknown";
+        xc_dom_panic(dom->xch, XC_INVALID_KERNEL,
+                     "%s: unkown image type %"PRIu64,
+                     __FUNCTION__, machine);
+        return NULL;
     }
 }
 
@@ -192,6 +195,8 @@ static elf_negerrnoval xc_dom_parse_elf_kernel(struct xc_dom_image *dom)
     dom->kernel_seg.vend   = dom->parms.virt_kend;
 
     dom->guest_type = xc_dom_guest_type(dom, elf);
+    if ( dom->guest_type == NULL )
+        return -EINVAL;
     DOMPRINTF("%s: %s: 0x%" PRIx64 " -> 0x%" PRIx64 "",
               __FUNCTION__, dom->guest_type,
               dom->kernel_seg.vstart, dom->kernel_seg.vend);
-- 
2.15.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  parent reply	other threads:[~2018-02-08 21:51 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-08 21:49 libx[lc]: Improve error reporting for invalid kernel images Simon Gaiser
2018-02-08 21:49 ` [PATCH 1/3] libxc: Cleanup xc_dom_parse_elf_kernel()'s return value Simon Gaiser
2018-02-09 12:00   ` Roger Pau Monné
2018-02-08 21:49 ` [PATCH 2/3] libxl: Improve logging in libxl__build_dom() Simon Gaiser
2018-02-09 12:08   ` Roger Pau Monné
2018-02-08 21:49 ` Simon Gaiser [this message]
2018-02-09 12:19   ` [PATCH 3/3] libxc: xc_dom_parse_elf_kernel: Return error for invalid kernel images Roger Pau Monné
2018-02-12 14:51 ` libx[lc]: Improve error reporting " Wei Liu

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=20180208214910.10699-4-simon@invisiblethingslab.com \
    --to=simon@invisiblethingslab.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=roger.pau@citrix.com \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xenproject.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).