All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gonglei <arei.gonglei@huawei.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: "qemu-trivial@nongnu.org" <qemu-trivial@nongnu.org>,
	"Huangweidong \(C\)" <weidong.huang@huawei.com>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
	"lcapitulino@redhat.com" <lcapitulino@redhat.com>
Subject: Re: [Qemu-trivial] [Qemu-devel] [PATCH] dump: fix use-after-free for s->fd
Date: Thu, 30 Oct 2014 08:54:57 +0800	[thread overview]
Message-ID: <54518C61.9020405@huawei.com> (raw)
In-Reply-To: <87vbn2apjx.fsf@blackfin.pond.sub.org>

On 2014/10/29 23:00, Markus Armbruster wrote:

> <arei.gonglei@huawei.com> writes:
> 
>> From: Gonglei <arei.gonglei@huawei.com>
>>
>> After commit 4c7e251a (), when dump memory completed,
>> the s->fd will be closed twice. We should return
>> directly when dump completed.
>>
>> Signed-off-by: Gonglei <arei.gonglei@huawei.com>
>> ---
>>  dump.c | 1 +
>>  1 file changed, 1 insertion(+)
>>
>> diff --git a/dump.c b/dump.c
>> index 06a4915..9d9a409 100644
>> --- a/dump.c
>> +++ b/dump.c
>> @@ -626,6 +626,7 @@ static void dump_iterate(DumpState *s, Error **errp)
>>          ret = get_next_block(s, block);
>>          if (ret == 1) {
>>              dump_completed(s);
>> +            return;
>>          }
>>      }
>>  }
> 
> What about less tortuous control structure?
> 
>     do {
>         block = s->next_block;
> 
>         size = block->target_end - block->target_start;
>         if (s->has_filter) {
>             size -= s->start;
>             if (s->begin + s->length < block->target_end) {
>                 size -= block->target_end - (s->begin + s->length);
>             }
>         }
>         write_memory(s, block, s->start, size, &local_err);
>         if (local_err) {
>             error_propagate(errp, local_err);
>             return;
>         }
> 
>     } while (!get_next_block(s, block))
> 
>     dump_completed();
> 
> Makes the badly chosen return values of of get_next_block() more
> visible.  Easy enough to fix if it bothers you.

Looks better. v2 will be posted, thanks :)

Best regards,
-Gonglei



WARNING: multiple messages have this Message-ID (diff)
From: Gonglei <arei.gonglei@huawei.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: "qemu-trivial@nongnu.org" <qemu-trivial@nongnu.org>,
	"Huangweidong (C)" <weidong.huang@huawei.com>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
	"lcapitulino@redhat.com" <lcapitulino@redhat.com>
Subject: Re: [Qemu-devel] [PATCH] dump: fix use-after-free for s->fd
Date: Thu, 30 Oct 2014 08:54:57 +0800	[thread overview]
Message-ID: <54518C61.9020405@huawei.com> (raw)
In-Reply-To: <87vbn2apjx.fsf@blackfin.pond.sub.org>

On 2014/10/29 23:00, Markus Armbruster wrote:

> <arei.gonglei@huawei.com> writes:
> 
>> From: Gonglei <arei.gonglei@huawei.com>
>>
>> After commit 4c7e251a (), when dump memory completed,
>> the s->fd will be closed twice. We should return
>> directly when dump completed.
>>
>> Signed-off-by: Gonglei <arei.gonglei@huawei.com>
>> ---
>>  dump.c | 1 +
>>  1 file changed, 1 insertion(+)
>>
>> diff --git a/dump.c b/dump.c
>> index 06a4915..9d9a409 100644
>> --- a/dump.c
>> +++ b/dump.c
>> @@ -626,6 +626,7 @@ static void dump_iterate(DumpState *s, Error **errp)
>>          ret = get_next_block(s, block);
>>          if (ret == 1) {
>>              dump_completed(s);
>> +            return;
>>          }
>>      }
>>  }
> 
> What about less tortuous control structure?
> 
>     do {
>         block = s->next_block;
> 
>         size = block->target_end - block->target_start;
>         if (s->has_filter) {
>             size -= s->start;
>             if (s->begin + s->length < block->target_end) {
>                 size -= block->target_end - (s->begin + s->length);
>             }
>         }
>         write_memory(s, block, s->start, size, &local_err);
>         if (local_err) {
>             error_propagate(errp, local_err);
>             return;
>         }
> 
>     } while (!get_next_block(s, block))
> 
>     dump_completed();
> 
> Makes the badly chosen return values of of get_next_block() more
> visible.  Easy enough to fix if it bothers you.

Looks better. v2 will be posted, thanks :)

Best regards,
-Gonglei

  reply	other threads:[~2014-10-30  0:55 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-29 10:28 [Qemu-trivial] [PATCH] dump: fix use-after-free for s->fd arei.gonglei
2014-10-29 10:28 ` [Qemu-devel] " arei.gonglei
2014-10-29 15:00 ` [Qemu-trivial] " Markus Armbruster
2014-10-29 15:00   ` Markus Armbruster
2014-10-30  0:54   ` Gonglei [this message]
2014-10-30  0:54     ` Gonglei

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=54518C61.9020405@huawei.com \
    --to=arei.gonglei@huawei.com \
    --cc=armbru@redhat.com \
    --cc=lcapitulino@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    --cc=weidong.huang@huawei.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 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.