qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] qcow2: Prevent backing file names longer than 1023
@ 2016-04-06 15:14 Max Reitz
  2016-04-06 15:36 ` Eric Blake
  2016-04-06 16:18 ` Kevin Wolf
  0 siblings, 2 replies; 3+ messages in thread
From: Max Reitz @ 2016-04-06 15:14 UTC (permalink / raw)
  To: qemu-block; +Cc: Kevin Wolf, qemu-stable, qemu-devel, Max Reitz

We reject backing file names with a length of more than 1023 characters
when opening a qcow2 file, so we should not produce such files
ourselves.

Cc: qemu-stable@nongnu.org
Signed-off-by: Max Reitz <mreitz@redhat.com>
---
 block/qcow2.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/block/qcow2.c b/block/qcow2.c
index 056525c..011a0ae 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -1957,6 +1957,11 @@ int qcow2_update_header(BlockDriverState *bs)
     if (s->image_backing_file) {
         size_t backing_file_len = strlen(s->image_backing_file);
 
+        if (backing_file_len > 1023) {
+            ret = -EINVAL;
+            goto fail;
+        }
+
         if (buflen < backing_file_len) {
             ret = -ENOSPC;
             goto fail;
-- 
2.8.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] qcow2: Prevent backing file names longer than 1023
  2016-04-06 15:14 [Qemu-devel] [PATCH] qcow2: Prevent backing file names longer than 1023 Max Reitz
@ 2016-04-06 15:36 ` Eric Blake
  2016-04-06 16:18 ` Kevin Wolf
  1 sibling, 0 replies; 3+ messages in thread
From: Eric Blake @ 2016-04-06 15:36 UTC (permalink / raw)
  To: Max Reitz, qemu-block; +Cc: Kevin Wolf, qemu-stable, qemu-devel

[-- Attachment #1: Type: text/plain, Size: 508 bytes --]

On 04/06/2016 09:14 AM, Max Reitz wrote:
> We reject backing file names with a length of more than 1023 characters
> when opening a qcow2 file, so we should not produce such files
> ourselves.
> 
> Cc: qemu-stable@nongnu.org
> Signed-off-by: Max Reitz <mreitz@redhat.com>
> ---
>  block/qcow2.c | 5 +++++
>  1 file changed, 5 insertions(+)

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] qcow2: Prevent backing file names longer than 1023
  2016-04-06 15:14 [Qemu-devel] [PATCH] qcow2: Prevent backing file names longer than 1023 Max Reitz
  2016-04-06 15:36 ` Eric Blake
@ 2016-04-06 16:18 ` Kevin Wolf
  1 sibling, 0 replies; 3+ messages in thread
From: Kevin Wolf @ 2016-04-06 16:18 UTC (permalink / raw)
  To: Max Reitz; +Cc: qemu-devel, qemu-block, qemu-stable

Am 06.04.2016 um 17:14 hat Max Reitz geschrieben:
> We reject backing file names with a length of more than 1023 characters
> when opening a qcow2 file, so we should not produce such files
> ourselves.
> 
> Cc: qemu-stable@nongnu.org
> Signed-off-by: Max Reitz <mreitz@redhat.com>
> ---
>  block/qcow2.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/block/qcow2.c b/block/qcow2.c
> index 056525c..011a0ae 100644
> --- a/block/qcow2.c
> +++ b/block/qcow2.c
> @@ -1957,6 +1957,11 @@ int qcow2_update_header(BlockDriverState *bs)
>      if (s->image_backing_file) {
>          size_t backing_file_len = strlen(s->image_backing_file);
>  
> +        if (backing_file_len > 1023) {
> +            ret = -EINVAL;
> +            goto fail;
> +        }
> +
>          if (buflen < backing_file_len) {
>              ret = -ENOSPC;
>              goto fail;

We should probably already check this in qcow2_change_backing_file(), so
that s->image_backing_file can never contain anything longer than that.
If you like, you can keep an assertion here.

The advantage is that in qcow2_change_backing_file() we can fail the
operation before all of the variables are updated and therefore become
inconsistent with the on-disk state of the image.

Kevin

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-04-06 16:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-06 15:14 [Qemu-devel] [PATCH] qcow2: Prevent backing file names longer than 1023 Max Reitz
2016-04-06 15:36 ` Eric Blake
2016-04-06 16:18 ` Kevin Wolf

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).