xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Vincent Hanquez <vincent.hanquez@eu.citrix.com>
To: xen-devel@lists.xensource.com
Cc: Vincent Hanquez <vincent.hanquez@eu.citrix.com>
Subject: [PATCH 3/5] add fuse around generic_device_add related to invalid kinds
Date: Wed, 13 Jan 2010 16:14:53 +0000	[thread overview]
Message-ID: <1263399295-19453-4-git-send-email-vincent.hanquez@eu.citrix.com> (raw)
In-Reply-To: <1263399295-19453-1-git-send-email-vincent.hanquez@eu.citrix.com>

[-- Attachment #1: Type: text/plain, Size: 331 bytes --]


prevent segfault in case the backend or frontend kinds have
not been set to a correct kind value (or not initilized).

Signed-off-by: Vincent Hanquez <vincent.hanquez@eu.citrix.com>
---
 tools/libxl/libxl_device.c   |    5 ++++-
 tools/libxl/libxl_internal.h |    2 +-
 2 files changed, 5 insertions(+), 2 deletions(-)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0003-add-fuse-around-generic_device_add-related-to-invali.patch --]
[-- Type: text/x-patch; name="0003-add-fuse-around-generic_device_add-related-to-invali.patch", Size: 1301 bytes --]

diff --git a/tools/libxl/libxl_device.c b/tools/libxl/libxl_device.c
index 7bbc924..726c543 100644
--- a/tools/libxl/libxl_device.c
+++ b/tools/libxl/libxl_device.c
@@ -26,7 +26,7 @@
 #include "libxl.h"
 #include "libxl_internal.h"
 
-const char *string_of_kinds[] = {
+static const char *string_of_kinds[] = {
     [DEVICE_VIF] = "vif",
     [DEVICE_VBD] = "vbd",
     [DEVICE_TAP] = "tap",
@@ -45,6 +45,9 @@ int libxl_device_generic_add(struct libxl_ctx *ctx, libxl_device *device,
     struct xs_permissions backend_perms[2];
     struct xs_permissions hotplug_perms[1];
 
+    if (!is_valid_device_kind(device->backend_kind) || !is_valid_device_kind(device->kind))
+        return ERROR_INVAL;
+
     dom_path_backend = libxl_xs_get_dompath(ctx, device->backend_domid);
     dom_path = libxl_xs_get_dompath(ctx, device->domid);
 
diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
index 11698bc..34f2e38 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -68,7 +68,7 @@ typedef enum {
     DEVICE_CONSOLE,
 } libxl_device_kinds;
 
-extern const char *string_of_kinds[];
+#define is_valid_device_kind(kind) (((kind) >= DEVICE_VIF) && ((kind) <= DEVICE_CONSOLE))
 
 typedef struct {
     uint32_t backend_devid;

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

  parent reply	other threads:[~2010-01-13 16:14 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-13 16:14 [PATCH 0/5] more solidification work Vincent Hanquez
2010-01-13 16:14 ` [PATCH 1/5] add some return values testing in stubdom Vincent Hanquez
2010-01-13 16:14 ` [PATCH 2/5] initialize enum to 1, to prevent defaulting to the 0 values when structure when not properly initialized by the client Vincent Hanquez
2010-01-13 16:14 ` Vincent Hanquez [this message]
2010-01-13 16:14 ` [PATCH 4/5] add error in disk_add if phystype is not recognized Vincent Hanquez
2010-01-13 16:14 ` [PATCH 5/5] fix name to domid conversion Vincent Hanquez

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=1263399295-19453-4-git-send-email-vincent.hanquez@eu.citrix.com \
    --to=vincent.hanquez@eu.citrix.com \
    --cc=xen-devel@lists.xensource.com \
    /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).