Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JqZw0-0001b1-1a for qemu-devel@nongnu.org; Mon, 28 Apr 2008 16:26:48 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JqZvz-0001aD-5F for qemu-devel@nongnu.org; Mon, 28 Apr 2008 16:26:47 -0400 Received: from [199.232.76.173] (port=59851 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JqZvz-0001a8-1x for qemu-devel@nongnu.org; Mon, 28 Apr 2008 16:26:47 -0400 Received: from savannah.gnu.org ([199.232.41.3] helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1JqZvy-00078r-PF for qemu-devel@nongnu.org; Mon, 28 Apr 2008 16:26:46 -0400 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.63) (envelope-from ) id 1JqZvy-000712-Da for qemu-devel@nongnu.org; Mon, 28 Apr 2008 20:26:46 +0000 Received: from aurel32 by cvs.savannah.gnu.org with local (Exim 4.63) (envelope-from ) id 1JqZvx-00070q-UF for qemu-devel@nongnu.org; Mon, 28 Apr 2008 20:26:46 +0000 MIME-Version: 1.0 Errors-To: aurel32 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Aurelien Jarno Message-Id: Date: Mon, 28 Apr 2008 20:26:45 +0000 Subject: [Qemu-devel] [4277] add format= to drive options (CVE-2008-2004) Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Revision: 4277 http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=4277 Author: aurel32 Date: 2008-04-28 20:26:45 +0000 (Mon, 28 Apr 2008) Log Message: ----------- add format= to drive options (CVE-2008-2004) It is possible for a guest with a raw formatted disk image to write a header to that disk image describing another format (such as qcow2). Stopping and subsequent restart of the guest will cause qemu to detect that format, and could allow the guest to read any host file if qemu is sufficiently privileged (typical in virt environments). The patch defaults to existing behaviour (probing based on file contents), so it still requires the mgmt app (e.g. libvirt xml) to pass a new "format=raw" parameter for raw disk images. Originally noted by Avi Kivity, patch from Chris Wright. Modified Paths: -------------- trunk/qemu-doc.texi trunk/vl.c Modified: trunk/qemu-doc.texi =================================================================== --- trunk/qemu-doc.texi 2008-04-28 08:54:59 UTC (rev 4276) +++ trunk/qemu-doc.texi 2008-04-28 20:26:45 UTC (rev 4277) @@ -261,6 +261,10 @@ @var{snapshot} is "on" or "off" and allows to enable snapshot for given drive (see @option{-snapshot}). @item cache=@var{cache} @var{cache} is "on" or "off" and allows to disable host cache to access data. +@item format=@var{format} +Specify which disk @var{format} will be used rather than detecting +the format. Can be used to specifiy format=raw to avoid interpreting +an untrusted format header. @end table Instead of @option{-cdrom} you can use: Modified: trunk/vl.c =================================================================== --- trunk/vl.c 2008-04-28 08:54:59 UTC (rev 4276) +++ trunk/vl.c 2008-04-28 20:26:45 UTC (rev 4277) @@ -4961,6 +4961,7 @@ int bus_id, unit_id; int cyls, heads, secs, translation; BlockDriverState *bdrv; + BlockDriver *drv = NULL; int max_devs; int index; int cache; @@ -4968,7 +4969,7 @@ char *str = arg->opt; char *params[] = { "bus", "unit", "if", "index", "cyls", "heads", "secs", "trans", "media", "snapshot", "file", - "cache", NULL }; + "cache", "format", NULL }; if (check_params(buf, sizeof(buf), params, str) < 0) { fprintf(stderr, "qemu: unknown parameter '%s' in '%s'\n", @@ -5136,6 +5137,14 @@ } } + if (get_param_value(buf, sizeof(buf), "format", str)) { + drv = bdrv_find_format(buf); + if (!drv) { + fprintf(stderr, "qemu: '%s' invalid format\n", buf); + return -1; + } + } + if (arg->file == NULL) get_param_value(file, sizeof(file), "file", str); else @@ -5238,7 +5247,7 @@ bdrv_flags |= BDRV_O_SNAPSHOT; if (!cache) bdrv_flags |= BDRV_O_DIRECT; - if (bdrv_open(bdrv, file, bdrv_flags) < 0 || qemu_key_check(bdrv, file)) { + if (bdrv_open2(bdrv, file, bdrv_flags, drv) < 0 || qemu_key_check(bdrv, file)) { fprintf(stderr, "qemu: could not open disk image %s\n", file); return -1;