All of lore.kernel.org
 help / color / mirror / Atom feed
From: Fabiano Rosas <farosas@suse.de>
To: Peter Xu <peterx@redhat.com>, qemu-devel@nongnu.org
Cc: Arun Menon <armenon@redhat.com>,
	peterx@redhat.com, Peter Maydell <peter.maydell@linaro.org>,
	Juraj Marcin <jmarcin@redhat.com>
Subject: Re: [PATCH 1/3] migration: Fix error leak in postcopy_ram_listen_thread()
Date: Tue, 21 Oct 2025 17:45:12 -0300	[thread overview]
Message-ID: <87qzuwt25j.fsf@suse.de> (raw)
In-Reply-To: <20251021184132.2635958-2-peterx@redhat.com>

Peter Xu <peterx@redhat.com> writes:

> As reported and analyzed by Peter:
>
> https://lore.kernel.org/r/CAFEAcA9otBWtR7rPQ0Y9aBm+7ZWJzd4VWpXrAmGr8XspPn+zpw@mail.gmail.com
>
> Fix it by freeing the error.  When at it, always reset the local_err
> pointer in both paths.
>
> Cc: Arun Menon <armenon@redhat.com>
> Resolves: Coverity CID 1641390
> Fixes: 94272d9b45 ("migration: Capture error in postcopy_ram_listen_thread()")
> Signed-off-by: Peter Xu <peterx@redhat.com>
> ---
>  migration/savevm.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/migration/savevm.c b/migration/savevm.c
> index aafa40d779..635fa2f918 100644
> --- a/migration/savevm.c
> +++ b/migration/savevm.c
> @@ -2136,17 +2136,18 @@ static void *postcopy_ram_listen_thread(void *opaque)
>          if (postcopy_state_get() == POSTCOPY_INCOMING_RUNNING &&
>              !migrate_postcopy_ram() && migrate_dirty_bitmaps())
>          {
> -            error_report("%s: loadvm failed during postcopy: %d. All states "
> +            error_report("%s: loadvm failed during postcopy: %s. All states "

Do we want to keep the %d for consistency with the way we report the
error below?

loadvm failed during postcopy: %d: %s

>                           "are migrated except dirty bitmaps. Some dirty "
>                           "bitmaps may be lost, and present migrated dirty "
>                           "bitmaps are correctly migrated and valid.",
> -                         __func__, load_res);
> +                         __func__, error_get_pretty(local_err));
> +            g_clear_pointer(&local_err, error_free);
>              load_res = 0; /* prevent further exit() */
>          } else {
>              error_prepend(&local_err,
>                            "loadvm failed during postcopy: %d: ", load_res);
>              migrate_set_error(migr, local_err);
> -            error_report_err(local_err);
> +            g_clear_pointer(&local_err, error_report_err);
>              migrate_set_state(&mis->state, MIGRATION_STATUS_POSTCOPY_ACTIVE,
>                                             MIGRATION_STATUS_FAILED);
>          }


  reply	other threads:[~2025-10-21 20:46 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-21 18:41 [PATCH 0/3] migration: A few fixes on coverity reports Peter Xu
2025-10-21 18:41 ` [PATCH 1/3] migration: Fix error leak in postcopy_ram_listen_thread() Peter Xu
2025-10-21 20:45   ` Fabiano Rosas [this message]
2025-10-21 21:20     ` Peter Xu
2025-10-21 18:41 ` [PATCH 2/3] migration/cpr: Fix coverity report in cpr_exec_persist_state() Peter Xu
2025-10-21 20:49   ` Fabiano Rosas
2025-10-21 21:29     ` Peter Xu
2025-10-22 12:24       ` Fabiano Rosas
2025-10-22 12:51         ` Peter Xu
2025-10-22 13:41           ` Fabiano Rosas
2025-10-21 18:41 ` [PATCH 3/3] migration/cpr: Fix UAF in cpr_exec_cb() when execvp() fails Peter Xu
2025-10-21 20:49   ` Fabiano Rosas

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=87qzuwt25j.fsf@suse.de \
    --to=farosas@suse.de \
    --cc=armenon@redhat.com \
    --cc=jmarcin@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=peterx@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 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.