OpenVZ / Virtuozzo kernel development (devel@openvz.org)
 help / color / mirror / Atom feed
From: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
To: den@openvz.org
Cc: devel@openvz.org
Subject: Re: [Devel] [PATCH hci-8.1 v2 2/6] dm-qcow2: truncate unused tail of image on suspend
Date: Thu, 8 Oct 2026 11:50:48 +0200	[thread overview]
Message-ID: <84548c3c-b663-4b55-a04b-6c5575330deb@virtuozzo.com> (raw)
In-Reply-To: <20261008073837.510678-3-alexander.ivanov@virtuozzo.com>

> [Severity: Medium]
> Can the value returned here exceed qcow2->file_size?
>
> file_preallocated_area_start is only page aligned after
> qcow2_parse_metadata(), not aligned to clu_size.  When clu_size is larger
> than PAGE_SIZE and the file ends in the middle of a cluster, the first
> cluster examined starts below file_preallocated_area_start but extends
> past it.
>
> If that cluster has a non-zero refcount, the function returns
> pos + clu_size, which is greater than file_size.

Fixed.

> [Severity: Medium]
> Is the check against file_size sufficient here?
>
> Only end == qcow2->file_size is tested, so with used_end greater than
> file_size the code goes on to call qcow2_truncate_safe(), and ftruncate
> extends the file.  qcow2->file_size and file_preallocated_area_start are
> then set to the larger value, although this patch is meant only to shrink
> the image.
>
> The growth is at most one cluster, but would it make sense to clamp with
> min(used_end, qcow2->file_size), or to use end >= qcow2->file_size for the
> early return?
After the previous fix qcow2_calc_used_end() can't return value greater 
than file_size.

> [Severity: Low]
> This isn't a bug, but QC_ERR already adds the "dm-qcow2: " prefix through
> QCOW2_FMT, so this message prints the prefix twice:
>
>      dm-qcow2: <dev>: dm-qcow2: Can't find used end: -5
>
> The raw negative errno is also printed with %lld.  Neighbouring messages in
> the same function repeat the prefix as well.
Fixed in the old and the new code.


_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

  parent reply	other threads:[~2026-10-08  9:52 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-08  7:38 [Devel] [PATCH hci-8.1 v2 0/6] truncate unused tail of images " Alexander Ivanov
2026-10-08  7:38 ` [Devel] [PATCH hci-8.1 v2 1/6] dm-qcow2: add qcow2_md_page_read_sync() helper Alexander Ivanov
2026-10-08  7:43   ` no-reply
2026-10-08  7:38 ` [Devel] [PATCH hci-8.1 v2 2/6] dm-qcow2: truncate unused tail of image on suspend Alexander Ivanov
2026-10-08  7:44   ` no-reply
2026-10-08  9:50   ` Alexander Ivanov [this message]
2026-10-08  7:38 ` [Devel] [PATCH hci-8.1 v2 3/6] dm-ploop: set delta is_raw before applying its mappings Alexander Ivanov
2026-10-08  7:46   ` no-reply
2026-10-08 10:42   ` Alexander Ivanov
2026-10-08  7:38 ` [Devel] [PATCH hci-8.1 v2 4/6] dm-ploop: factor out ploop_read_delta() from ploop_add_delta() Alexander Ivanov
2026-10-08  7:46   ` no-reply
2026-10-08  7:38 ` [Devel] [PATCH hci-8.1 v2 5/6] dm-ploop: reload metadata on resume Alexander Ivanov
2026-10-08  7:54   ` no-reply
2026-10-08 11:46   ` Alexander Ivanov
2026-10-08  7:38 ` [Devel] [PATCH hci-8.1 v2 6/6] dm-ploop: truncate unused tail of top delta on suspend Alexander Ivanov
2026-10-08  7:52   ` no-reply

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=84548c3c-b663-4b55-a04b-6c5575330deb@virtuozzo.com \
    --to=alexander.ivanov@virtuozzo.com \
    --cc=den@openvz.org \
    --cc=devel@openvz.org \
    /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