From: Kamala Narasimhan <kamala.narasimhan@gmail.com>
To: Gianni Tedesco <gianni.tedesco@citrix.com>
Cc: Ian Campbell <Ian.Campbell@eu.citrix.com>,
"xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>,
Ian Jackson <Ian.Jackson@eu.citrix.com>,
Stefano Stabellini <Stefano.Stabellini@eu.citrix.com>
Subject: Re: [PATCH] xl: Perform minimal validation of virtual disk file while parsing config file
Date: Fri, 21 Jan 2011 21:33:39 -0500 [thread overview]
Message-ID: <4D3A4203.2050706@gmail.com> (raw)
In-Reply-To: <1295616468.12018.352.camel@qabil.uk.xensource.com>
Ian - Apologies for the delay. I think I have covered all comments so far. If there are more I will get to it ASAP. Please let me know.
Also, I switched email client to avoid word wrapping and other issues. If you still find the format of the patches inconvenient, please let me know.
Signed-off-by: Kamala Narasimhan <kamala.narasimhan@citrix.com>
Kamala
diff -r fe8a177ae9cb tools/libxl/libxl.c
--- a/tools/libxl/libxl.c Wed Jan 19 15:29:04 2011 +0000
+++ b/tools/libxl/libxl.c Fri Jan 21 18:00:37 2011 -0500
@@ -826,6 +826,35 @@ skip_autopass:
/******************************************************************************/
+static int validate_virtual_disk(libxl_ctx *ctx, char *file_name, libxl_disk_phystype disk_type)
+{
+ struct stat stat_buf;
+
+ /* Return without further validation for empty cdrom drive.
+ Note: Post 4.1 we need to change the interface to handle empty
+ cdrom rather than go with the below assumption.
+ */
+ if ( (file_name[0] == '\0') && (disk_type == PHYSTYPE_PHY) )
+ 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);
@@ -835,6 +864,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) {
next prev parent reply other threads:[~2011-01-22 2:33 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-13 15:35 [PATCH] xl: Perform minimal validation of virtual disk file while parsing config file Kamala Narasimhan
2011-01-14 9:05 ` Ian Campbell
2011-01-14 14:55 ` Kamala Narasimhan
2011-01-14 16:59 ` Gianni Tedesco
2011-01-14 17:17 ` Kamala Narasimhan
2011-01-19 18:09 ` Kamala Narasimhan
2011-01-19 18:26 ` Kamala Narasimhan
2011-01-20 14:04 ` Gianni Tedesco
2011-01-20 14:12 ` Gianni Tedesco
2011-01-20 15:08 ` Kamala Narasimhan
2011-01-20 15:22 ` Gianni Tedesco
2011-01-20 15:22 ` Kamala Narasimhan
2011-01-20 15:41 ` Kamala Narasimhan
2011-01-20 15:49 ` Ian Jackson
2011-01-20 16:46 ` Kamala Narasimhan
2011-01-20 21:14 ` Kamala Narasimhan
2011-01-21 12:17 ` Ian Jackson
2011-01-21 13:27 ` Gianni Tedesco
2011-01-22 2:33 ` Kamala Narasimhan [this message]
2011-01-25 18:10 ` Ian Jackson
2011-01-26 3:07 ` Kamala Narasimhan
2011-01-26 11:43 ` Ian Jackson
2011-01-26 18:02 ` Kamala Narasimhan
2011-01-26 10:27 ` Ian Campbell
2011-01-26 11:48 ` Ian Jackson
2011-01-26 11:54 ` Ian Campbell
2011-01-24 14:18 ` Kamala Narasimhan
2011-01-24 14:31 ` Kamala Narasimhan
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=4D3A4203.2050706@gmail.com \
--to=kamala.narasimhan@gmail.com \
--cc=Ian.Campbell@eu.citrix.com \
--cc=Ian.Jackson@eu.citrix.com \
--cc=Stefano.Stabellini@eu.citrix.com \
--cc=gianni.tedesco@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).