WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] libxenlight: add fuse around generic_devi

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] libxenlight: add fuse around generic_device_add related to invalid kinds
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Thu, 14 Jan 2010 02:20:17 -0800
Delivery-date: Thu, 14 Jan 2010 02:20:26 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1263462094 0
# Node ID fd8707f8698d6cc101332187bf080827826a460e
# Parent  94442ca0423d34d2618ce76de196a42ef995873a
libxenlight: add fuse around generic_device_add related to invalid kinds

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@xxxxxxxxxxxxx>
---
 tools/libxl/libxl_device.c   |    5 ++++-
 tools/libxl/libxl_internal.h |    2 +-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff -r 94442ca0423d -r fd8707f8698d tools/libxl/libxl_device.c
--- a/tools/libxl/libxl_device.c        Thu Jan 14 09:40:55 2010 +0000
+++ b/tools/libxl/libxl_device.c        Thu Jan 14 09:41:34 2010 +0000
@@ -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",
@@ -44,6 +44,9 @@ int libxl_device_generic_add(struct libx
     struct xs_permissions frontend_perms[2];
     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 -r 94442ca0423d -r fd8707f8698d tools/libxl/libxl_internal.h
--- a/tools/libxl/libxl_internal.h      Thu Jan 14 09:40:55 2010 +0000
+++ b/tools/libxl/libxl_internal.h      Thu Jan 14 09:41:34 2010 +0000
@@ -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;

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] libxenlight: add fuse around generic_device_add related to invalid kinds, Xen patchbot-unstable <=