qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: Heinz Graalfs <graalfs@linux.vnet.ibm.com>
Cc: Christian Borntraeger <borntraeger@de.ibm.com>,
	jfrei@linux.vnet.ibm.com, qemu-devel@nongnu.org,
	Stefan Hajnoczi <stefanha@redhat.com>,
	agraf@suse.de
Subject: Re: [Qemu-devel] [PATCH/RFC] block: Ensure that block size constraints are considered
Date: Tue, 11 Dec 2012 11:30:37 +0100	[thread overview]
Message-ID: <50C70B4D.1000505@redhat.com> (raw)
In-Reply-To: <1355219892.4245.14.camel@br8hfpp0.de.ibm.com>

Am 11.12.2012 10:58, schrieb Heinz Graalfs:
> Hi Kevin,
> 
> I'm using the bdrv_pread() function during boot partition detection ...
> 
> In detail: 
> bdrv_pread() is called to read 32 bytes from a 2048 bytes formatted
> disk. This results in setting up a read of 512 bytes (1 sector
> multiplied by 512 current code in paio_submit()), which is wrong for a
> O_DIRECT opened file, and produces the error.

So this sounds like the real problem: bdrv_pread/pwrite assume 512 byte
sectors. May it's better to fix it there instead of just fixing one code
path in one backend.

In any case this patch as submitted is wrong as it overflows the buffer
passed to paio_submit. Test it with this patch:

--- a/qemu-io.c
+++ b/qemu-io.c
@@ -1718,6 +1718,8 @@ static int openfile(char *name, int flags, int
growable)
             bs = NULL;
             return 1;
         }
+
+        bdrv_set_buffer_alignment(bs, 4096);
     }

     return 0;


$ ./qemu-io -n -c 'read -p 0 512' /tmp/foo
read 512/512 bytes at offset 0
512 bytes, 1 ops; 0.0001 sec (3.727 MiB/sec and 7633.5878 ops/sec)
*** glibc detected *** ./qemu-io: double free or corruption (out):
0x00007fa22349b000 ***

Kevin

  reply	other threads:[~2012-12-11 10:31 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-21  8:58 [Qemu-devel] [PATCH/RFC] block: Ensure that block size constraints are considered Christian Borntraeger
2012-11-21  9:15 ` Kevin Wolf
2012-11-21 10:00   ` Christian Borntraeger
2012-11-21 11:24     ` Heinz Graalfs
2012-11-21 16:03   ` Paolo Bonzini
2012-11-22 12:03     ` Christian Borntraeger
2012-11-23 10:45   ` Heinz Graalfs
2012-12-07 20:26   ` Heinz Graalfs
2012-12-10  8:55     ` Kevin Wolf
2012-12-11  9:58       ` Heinz Graalfs
2012-12-11 10:30         ` Kevin Wolf [this message]
2012-12-11 13:53           ` Heinz Graalfs

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=50C70B4D.1000505@redhat.com \
    --to=kwolf@redhat.com \
    --cc=agraf@suse.de \
    --cc=borntraeger@de.ibm.com \
    --cc=graalfs@linux.vnet.ibm.com \
    --cc=jfrei@linux.vnet.ibm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /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).