[PATCH 0/8 v2] Complete fix for CVE-2010-3851.
1/8 generator: Rearrange argt logically (RHBZ#642934,CVE-2010-3851). 2/8 generator: Optional arguments, add-drive-opts (RHBZ#642934,CVE-2010-3851). These two previously posted. 3/8 fish: Specify format of disks (RHBZ#642934,CVE-2010-3851). Updates to guestfish to add the --format option and to make -d copy the format from libvirt. 4/8 fuse: Specify format of disks (RHBZ#642934,CVE-2010-3851). Nearly the same for guestmount. 5/8 tools: Specify format of disks (RHBZ#642934,CVE-2010-3851). Update Sys::Guestfs::Lib and the tools, except for the tools below. For each tool, add --format or copy the format from libvirt. 6/8 df: Specify format of disks (RHBZ#642934,CVE-2010-3851). Update virt-df, add --format or copy the format from libvirt. 7/8 virt-make-fs: Specify format of disk (RHBZ#642934,CVE-2010-3851). Update virt-make-fs to set the format correctly. 8/8 resize: Specify format of input, output disk (RHBZ#642934,CVE-2010-3851). Update virt-resize, add --format, --output-format. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones New in Fedora 11: Fedora Windows cross-compiler. Compile Windows programs, test, and build Windows installers. Over 70 libraries supprt'd http://fedoraproject.org/wiki/MinGW http://www.annexia.org/fedora_mingw
-- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://et.redhat.com/~rjones/virt-top
-- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones New in Fedora 11: Fedora Windows cross-compiler. Compile Windows programs, test, and build Windows installers. Over 70 libraries supprt'd http://fedoraproject.org/wiki/MinGW http://www.annexia.org/fedora_mingw
Richard W.M. Jones wrote:
Subject: [PATCH 2/8] generator: Optional arguments, add-drive-opts (RHBZ#642934,CVE-2010-3851). ...
Hi Rich, I skimmed v1 of this patch and saw nothing wrong. As mentioned on IRC, I did wonder if it'd make sense to warn whenever format=... is omitted. One comment below.
int -guestfs__add_drive_ro_with_if (guestfs_h *g, const char *filename, - const char *drive_if) +guestfs__add_drive_opts (guestfs_h *g, const char *filename, + const struct guestfs_add_drive_opts_argv *optargs) { if (strchr (filename, ',') != NULL) { error (g, _("filename cannot contain ',' (comma) character")); return -1; }
- if (access (filename, F_OK) == -1) { - perrorf (g, "%s", filename); + int readonly = + optargs->bitmask & GUESTFS_ADD_DRIVE_OPTS_READONLY_BITMASK + ? optargs->readonly : 0; + + const char *iface = + optargs->bitmask & GUESTFS_ADD_DRIVE_OPTS_IFACE_BITMASK + ? optargs->iface : DRIVE_IF; + + const char *format = + optargs->bitmask & GUESTFS_ADD_DRIVE_OPTS_FORMAT_BITMASK + ? optargs->format : NULL; + + /* For writable files, see if we can use cache=off. This also + * checks for the existence of the file. For readonly we have + * to do the check explicitly. + */ + int use_cache_off = readonly ? 0 : test_cache_off (g, filename); + if (use_cache_off == -1) return -1; + + if (readonly) { + if (access (filename, F_OK) == -1) { + perrorf (g, "%s", filename); + return -1; + } }
- size_t len = strlen (filename) + 64; + /* Construct the final -drive parameter. */ + size_t len = 64 + strlen (filename) + strlen (iface); + if (format) len += strlen (format); char buf[len];
- snprintf (buf, len, "file=%s,snapshot=on,if=%s", filename, drive_if); + snprintf (buf, len, "file=%s%s%s%s%s,if=%s", + filename, + readonly ? ",snapshot=on" : "", + use_cache_off ? ",cache=off" : "", + format ? ",format=" : "", + format ? format : "", + iface);
Seeing this makes me wonder if using asprintf would be worthwhile. Of course, that would mean handling allocation failure and freeing the resulting buffer before returning, but it does render the "64" unnecessary, and makes the code a little more robust to addition of a few long_named_option=on options that would exceed the slack provided by 64.
return guestfs__config (g, "-drive", buf); }
-- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://et.redhat.com/~rjones/virt-top
-- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones New in Fedora 11: Fedora Windows cross-compiler. Compile Windows programs, test, and build Windows installers. Over 70 libraries supprt'd http://fedoraproject.org/wiki/MinGW http://www.annexia.org/fedora_mingw
-- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://et.redhat.com/~rjones/virt-top
-- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://et.redhat.com/~rjones/virt-top
-- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-df lists disk usage of guests without needing to install any software inside the virtual machine. Supports Linux and Windows. http://et.redhat.com/~rjones/virt-df/
-- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones libguestfs lets you edit virtual machines. Supports shell scripting, bindings from many languages. http://et.redhat.com/~rjones/libguestfs/ See what it can do: http://et.redhat.com/~rjones/libguestfs/recipes.html
participants (2)
-
Jim Meyering -
Richard W.M. Jones