From: Michael Tokarev <mjt@tls.msk.ru>
To: Markus Armbruster <armbru@redhat.com>, arei.gonglei@huawei.com
Cc: qemu-trivial@nongnu.org, peter.huangpeng@huawei.com,
qemu-devel@nongnu.org, lcapitulino@redhat.com
Subject: Re: [Qemu-trivial] [Qemu-devel] [PATCH v2] dump: fix use-after-free for s->fd
Date: Thu, 30 Oct 2014 16:54:44 +0300 [thread overview]
Message-ID: <54524324.9070202@msgid.tls.msk.ru> (raw)
In-Reply-To: <87a94e6ni4.fsf@blackfin.pond.sub.org>
30.10.2014 10:10, Markus Armbruster wrote:
[]
> I'm afraid the commit message is a bit misleading. Let's examine what
> exactly happens.
>
> dump_iterate() dumps blocks in a loop. Eventually, get_next_block()
> returns "no more". We then call dump_completed(). But we neglect to
> break the loop! Broken in commit 4c7e251a.
>
> Because of that, we dump the last block again. This attempts to write
> to s->fd, which fails if we're lucky. The error makes dump_iterate()
> return unsuccessfully. It's the only way it can ever return.
>
> Theoretical: if we're not so lucky, something else has opened something
> for writing and got the same fd. dump_iterate() then keeps looping,
> messing up the something else's output, until a write fails, or the
> process mercifully terminates.
>
> Is this correct?
>
> If yes, let's use this commit message:
>
> dump: Fix dump-guest-memory termination and use-after-close
>
> dump_iterate() dumps blocks in a loop. Eventually, get_next_block()
> returns "no more". We then call dump_completed(). But we neglect to
> break the loop! Broken in commit 4c7e251a.
>
> Because of that, we dump the last block again. This attempts to write
> to s->fd, which fails if we're lucky. The error makes dump_iterate()
> return failure. It's the only way it can ever return.
>
> Theoretical: if we're not so lucky, something else has opened something
> for writing and got the same fd. dump_iterate() then keeps looping,
> messing up the something else's output, until a write fails, or the
> process mercifully terminates.
>
> The obvious fix is to restore the return lost in commit 4c7e251a. But
> the root cause of the bug is needlessly opaque loop control. Replace it
> by a clean do ... while loop.
>
> This makes the badly chosen return values of get_next_block() more
> visible. Cleaning that up is outside the scope of this bug fix.
>
> You can then add my R-by.
So I'm applying this -- which is your patch and your commit message, and
I really wonder why this is Reviewed-by and not Signed-off-by, with your
authorship? It really should be...
Thanks,
/mjt
WARNING: multiple messages have this Message-ID (diff)
From: Michael Tokarev <mjt@tls.msk.ru>
To: Markus Armbruster <armbru@redhat.com>, arei.gonglei@huawei.com
Cc: qemu-trivial@nongnu.org, peter.huangpeng@huawei.com,
qemu-devel@nongnu.org, lcapitulino@redhat.com
Subject: Re: [Qemu-devel] [Qemu-trivial] [PATCH v2] dump: fix use-after-free for s->fd
Date: Thu, 30 Oct 2014 16:54:44 +0300 [thread overview]
Message-ID: <54524324.9070202@msgid.tls.msk.ru> (raw)
In-Reply-To: <87a94e6ni4.fsf@blackfin.pond.sub.org>
30.10.2014 10:10, Markus Armbruster wrote:
[]
> I'm afraid the commit message is a bit misleading. Let's examine what
> exactly happens.
>
> dump_iterate() dumps blocks in a loop. Eventually, get_next_block()
> returns "no more". We then call dump_completed(). But we neglect to
> break the loop! Broken in commit 4c7e251a.
>
> Because of that, we dump the last block again. This attempts to write
> to s->fd, which fails if we're lucky. The error makes dump_iterate()
> return unsuccessfully. It's the only way it can ever return.
>
> Theoretical: if we're not so lucky, something else has opened something
> for writing and got the same fd. dump_iterate() then keeps looping,
> messing up the something else's output, until a write fails, or the
> process mercifully terminates.
>
> Is this correct?
>
> If yes, let's use this commit message:
>
> dump: Fix dump-guest-memory termination and use-after-close
>
> dump_iterate() dumps blocks in a loop. Eventually, get_next_block()
> returns "no more". We then call dump_completed(). But we neglect to
> break the loop! Broken in commit 4c7e251a.
>
> Because of that, we dump the last block again. This attempts to write
> to s->fd, which fails if we're lucky. The error makes dump_iterate()
> return failure. It's the only way it can ever return.
>
> Theoretical: if we're not so lucky, something else has opened something
> for writing and got the same fd. dump_iterate() then keeps looping,
> messing up the something else's output, until a write fails, or the
> process mercifully terminates.
>
> The obvious fix is to restore the return lost in commit 4c7e251a. But
> the root cause of the bug is needlessly opaque loop control. Replace it
> by a clean do ... while loop.
>
> This makes the badly chosen return values of get_next_block() more
> visible. Cleaning that up is outside the scope of this bug fix.
>
> You can then add my R-by.
So I'm applying this -- which is your patch and your commit message, and
I really wonder why this is Reviewed-by and not Signed-off-by, with your
authorship? It really should be...
Thanks,
/mjt
next prev parent reply other threads:[~2014-10-31 15:48 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-30 6:01 [Qemu-trivial] [PATCH v2] dump: fix use-after-free for s->fd arei.gonglei
2014-10-30 6:01 ` [Qemu-devel] " arei.gonglei
2014-10-30 7:10 ` [Qemu-trivial] " Markus Armbruster
2014-10-30 7:10 ` Markus Armbruster
2014-10-30 7:33 ` [Qemu-trivial] " zhanghailiang
2014-10-30 7:33 ` zhanghailiang
2014-10-30 7:42 ` [Qemu-trivial] " Michael Tokarev
2014-10-30 7:42 ` [Qemu-devel] [Qemu-trivial] " Michael Tokarev
2014-10-30 9:23 ` [Qemu-trivial] [Qemu-devel] " Markus Armbruster
2014-10-30 9:23 ` [Qemu-devel] [Qemu-trivial] " Markus Armbruster
2014-10-30 10:50 ` [Qemu-trivial] [Qemu-devel] " Gonglei
2014-10-30 10:50 ` [Qemu-devel] [Qemu-trivial] " Gonglei
2014-10-30 13:54 ` Michael Tokarev [this message]
2014-10-30 13:54 ` Michael Tokarev
2014-10-31 1:43 ` [Qemu-trivial] [Qemu-devel] " Gonglei
2014-10-31 1:43 ` [Qemu-devel] [Qemu-trivial] " Gonglei
2014-10-31 7:18 ` [Qemu-trivial] [Qemu-devel] " Michael Tokarev
2014-10-31 7:18 ` [Qemu-devel] [Qemu-trivial] " Michael Tokarev
2014-10-31 7:40 ` [Qemu-trivial] [Qemu-devel] " Gonglei
2014-10-31 7:40 ` [Qemu-devel] [Qemu-trivial] " Gonglei
2014-10-31 6:51 ` [Qemu-trivial] [Qemu-devel] " Markus Armbruster
2014-10-31 6:51 ` [Qemu-devel] [Qemu-trivial] " Markus Armbruster
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=54524324.9070202@msgid.tls.msk.ru \
--to=mjt@tls.msk.ru \
--cc=arei.gonglei@huawei.com \
--cc=armbru@redhat.com \
--cc=lcapitulino@redhat.com \
--cc=peter.huangpeng@huawei.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-trivial@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.