From: Darren Kenny <darren.kenny@oracle.com>
To: Max Reitz <mreitz@redhat.com>
Cc: qemu-block@nongnu.org, Kevin Wolf <kwolf@redhat.com>,
qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [Qemu-block] [PATCH for-2.11] qcow2: Fix overly broad madvise()
Date: Wed, 15 Nov 2017 11:04:19 +0000 [thread overview]
Message-ID: <20171115110419.k5vs4fghfzbu3f2c@starbug-vm.ie.oracle.com> (raw)
In-Reply-To: <20171114184127.24238-1-mreitz@redhat.com>
FWIW,
Reviewed-by: Darren Kenny <darren.kenny@oracle.com>
Thanks,
Darren.
On Tue, Nov 14, 2017 at 07:41:27PM +0100, Max Reitz wrote:
>@mem_size and @offset are both size_t, thus subtracting them from one
>another will just return a big size_t if mem_size < offset -- even more
>obvious here because the result is stored in another size_t.
>
>Checking that result to be positive is therefore not sufficient to
>excluse the case that offset > mem_size. Thus, we currently sometimes
>issue an madvise() over a very large address range.
>
>This is triggered by iotest 163, but with -m64, this does not result in
>tangible problems. But with -m32, this test produces three segfaults,
>all of which are fixed by this patch.
>
>Signed-off-by: Max Reitz <mreitz@redhat.com>
>---
> block/qcow2-cache.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/block/qcow2-cache.c b/block/qcow2-cache.c
>index 75746a7f43..5222a7b94d 100644
>--- a/block/qcow2-cache.c
>+++ b/block/qcow2-cache.c
>@@ -73,7 +73,7 @@ static void qcow2_cache_table_release(BlockDriverState *bs, Qcow2Cache *c,
> size_t mem_size = (size_t) s->cluster_size * num_tables;
> size_t offset = QEMU_ALIGN_UP((uintptr_t) t, align) - (uintptr_t) t;
> size_t length = QEMU_ALIGN_DOWN(mem_size - offset, align);
>- if (length > 0) {
>+ if (mem_size > offset && length > 0) {
> madvise((uint8_t *) t + offset, length, MADV_DONTNEED);
> }
> #endif
>--
>2.13.6
>
>
next prev parent reply other threads:[~2017-11-15 11:04 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-14 18:41 [Qemu-devel] [PATCH for-2.11] qcow2: Fix overly broad madvise() Max Reitz
2017-11-14 19:51 ` Eric Blake
2017-11-15 9:09 ` Alberto Garcia
2017-11-15 13:51 ` Max Reitz
2017-11-15 11:04 ` Darren Kenny [this message]
2017-11-15 11:09 ` [Qemu-devel] [Qemu-block] " Darren Kenny
2017-11-15 20:30 ` [Qemu-devel] " Max Reitz
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=20171115110419.k5vs4fghfzbu3f2c@starbug-vm.ie.oracle.com \
--to=darren.kenny@oracle.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--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).