qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Anthony Liguori <anthony@codemonkey.ws>
To: Kevin Wolf <kwolf@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] block/raw-posix: Abort on pread beyond end of non-growable file
Date: Tue, 26 Jan 2010 18:07:35 -0600	[thread overview]
Message-ID: <4B5F83C7.4030901@codemonkey.ws> (raw)
In-Reply-To: <1264166798-27422-1-git-send-email-kwolf@redhat.com>

On 01/22/2010 07:26 AM, Kevin Wolf wrote:
> This shouldn't happen under any normal circumstances. However, it looks like
> it's possible to achieve this with corrupted images. Without this patch
> raw_pread is hanging in an endless loop in such cases.
>
> The patch is not affecting growable files, for which such reads happen in
> normal use cases. raw_pread_aligned already handles these cases and won't
> return zero in the first place.
>
> Signed-off-by: Kevin Wolf<kwolf@redhat.com>
>    

Applied.  Thanks.

Regards,

Anthony Liguori
> ---
>   block/raw-posix.c |    6 +++++-
>   1 files changed, 5 insertions(+), 1 deletions(-)
>
> diff --git a/block/raw-posix.c b/block/raw-posix.c
> index 4d79881..6ef1cff 100644
> --- a/block/raw-posix.c
> +++ b/block/raw-posix.c
> @@ -403,8 +403,12 @@ static int raw_pread(BlockDriverState *bs, int64_t offset,
>                       size = ALIGNED_BUFFER_SIZE;
>
>                   ret = raw_pread_aligned(bs, offset, s->aligned_buf, size);
> -                if (ret<  0)
> +                if (ret<  0) {
>                       return ret;
> +                } else if (ret == 0) {
> +                    fprintf(stderr, "raw_pread: read beyond end of file\n");
> +                    abort();
> +                }
>
>                   size = ret;
>                   if (size>  count)
>    

      reply	other threads:[~2010-01-27  0:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-22 13:26 [Qemu-devel] [PATCH] block/raw-posix: Abort on pread beyond end of non-growable file Kevin Wolf
2010-01-27  0:07 ` Anthony Liguori [this message]

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=4B5F83C7.4030901@codemonkey.ws \
    --to=anthony@codemonkey.ws \
    --cc=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.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;
as well as URLs for NNTP newsgroup(s).