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] xl: Perform minimal validation of virtual

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] xl: Perform minimal validation of virtual disk file while parsing config file
From: Xen patchbot-unstable <patchbot@xxxxxxx>
Date: Sat, 29 Jan 2011 15:05:22 -0800
Delivery-date: Sat, 29 Jan 2011 15:07:04 -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 Kamala Narasimhan <kamala.narasimhan@xxxxxxxxx>
# Date 1295978989 0
# Node ID 1d1eec7e1fb4c8bc7be6873fcf235eeee90920c5
# Parent  6ec61438713a2891a3f21f926c306bed2629d441
xl: Perform minimal validation of virtual disk file while parsing config file

This patch performs some very basic validation on the virtual disk
file passed through the config file.  This validation ensures that we
don't go too far with the initialization like spawn qemu and more
while there could be some potentially fundamental issues.

[ Patch fixed up to work with PHYSTYPE_EMPTY 22808:6ec61438713a -iwj ]

Signed-off-by: Kamala Narasimhan <kamala.narasimhan@xxxxxxxxxx>
Acked-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
Signed-off-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
Committed-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
---
 tools/libxl/libxl.c |   29 +++++++++++++++++++++++++++++
 1 files changed, 29 insertions(+)

diff -r 6ec61438713a -r 1d1eec7e1fb4 tools/libxl/libxl.c
--- a/tools/libxl/libxl.c       Tue Jan 25 18:06:53 2011 +0000
+++ b/tools/libxl/libxl.c       Tue Jan 25 18:09:49 2011 +0000
@@ -833,6 +833,31 @@ skip_autopass:
 
 
/******************************************************************************/
 
+static int validate_virtual_disk(libxl_ctx *ctx, char *file_name, 
libxl_disk_phystype disk_type)
+{
+    struct stat stat_buf;
+
+    if ( (file_name[0] == '\0') && (disk_type == PHYSTYPE_EMPTY) )
+        return 0;
+
+    if ( stat(file_name, &stat_buf) != 0 ) {
+        LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "failed to stat %s", 
file_name);
+        return ERROR_INVAL;
+    }
+    if ( disk_type == PHYSTYPE_PHY ) {
+        if ( !(S_ISBLK(stat_buf.st_mode)) ) {
+            LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "Virtual disk %s is not a block 
device!\n",
+                file_name);
+            return ERROR_INVAL;
+        }
+    } else if ( stat_buf.st_size == 0 ) {
+        LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "Virtual disk %s size is 0!\n", 
file_name);
+        return ERROR_INVAL;
+    }
+
+    return 0;
+}
+
 int libxl_device_disk_add(libxl_ctx *ctx, uint32_t domid, libxl_device_disk 
*disk)
 {
     libxl__gc gc = LIBXL_INIT_GC(ctx);
@@ -842,6 +867,10 @@ int libxl_device_disk_add(libxl_ctx *ctx
     int devid;
     libxl__device device;
     int major, minor, rc;
+
+    rc = validate_virtual_disk(ctx, disk->physpath, disk->phystype);
+    if (rc)
+        return rc;
 
     front = flexarray_make(16, 1);
     if (!front) {

_______________________________________________
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] xl: Perform minimal validation of virtual disk file while parsing config file, Xen patchbot-unstable <=