All of lore.kernel.org
 help / color / mirror / Atom feed
From: Fabiano Rosas <farosas@suse.de>
To: Peter Xu <peterx@redhat.com>,
	"Maciej S. Szmigiero" <mail@maciej.szmigiero.name>
Cc: Markus Armbruster <armbru@redhat.com>, qemu-devel@nongnu.org
Subject: Re: [PULL 19/31] migration: Normalize tls arguments
Date: Tue, 14 Apr 2026 16:34:30 -0300	[thread overview]
Message-ID: <87340xz67t.fsf@suse.de> (raw)
In-Reply-To: <ad6OcvW1II8Q3gO1@x1.local>

Peter Xu <peterx@redhat.com> writes:

> On Tue, Apr 14, 2026 at 06:56:27PM +0200, Maciej S. Szmigiero wrote:
>> On 23.12.2025 15:29, Peter Xu wrote:
>> > From: Fabiano Rosas <farosas@suse.de>
>> > 
>> > The migration parameters tls_creds, tls_authz and tls_hostname
>> > currently have a non-uniform handling. When used as arguments to
>> > migrate-set-parameters, their type is StrOrNull and when used as
>> > return value from query-migrate-parameters their type is a plain
>> > string.
>> > 
>> > Not only having to convert between the types is cumbersome, but it
>> > also creates the issue of requiring two different QAPI types to be
>> > used, one for each command. MigrateSetParameters is used for
>> > migrate-set-parameters with the TLS arguments as StrOrNull while
>> > MigrationParameters is used for query-migrate-parameters with the TLS
>> > arguments as str.
>> > 
>> > Since StrOrNull could be considered a superset of str, change the type
>> > of the TLS arguments in MigrationParameters to StrOrNull. Also ensure
>> > that QTYPE_QNULL is never used.
>> > 
>> > 1) migrate-set-parameters will always write QTYPE_QSTRING to
>> >    s->parameters, either an empty or non-empty string.
>> > 
>> > 2) query-migrate-parameters will always return a QTYPE_QSTRING, either
>> >    empty or non-empty.
>> > 
>> > 3) the migrate_tls_* helpers will always return a non-empty string or
>> >    NULL, for the internal migration code's consumption.
>> > 
>> > Points (1) and (2) above help simplify the parameters validation and
>> > the query command handling because s->parameters is already kept in
>> > the format that query-migrate-parameters (and info migrate_paramters)
>> > expect. Point (3) is so people don't need to care about StrOrNull in
>> > migration code.
>> > 
>> > This will allow the type duplication to be removed in the next
>> > patches.
>> > 
>> > Note that the type of @tls_creds, @tls-hostname, @tls-authz changes
>> > from str to StrOrNull in introspection of the query-migrate-parameters
>> > command. We accept this imprecision to enable de-duplication.
>> > 
>> > There's no need to free the TLS options in
>> > migration_instance_finalize() because they're freed by the qdev
>> > properties .release method.
>> > 
>> > Temporary in this patch:
>> > migrate_params_test_apply() copies s->parameters into a temporary
>> > structure, so it's necessary to drop the references to the TLS options
>> > if they were not set by the user to avoid double-free. This is fixed
>> > in the next patches.
>> > 
>> > Acked-by: Markus Armbruster <armbru@redhat.com>
>> > Signed-off-by: Fabiano Rosas <farosas@suse.de>
>> > Link: https://lore.kernel.org/r/20251215220041.12657-6-farosas@suse.de
>> > [peterx: in hmp_info_migrate_parameters(), remove an extra dump of
>> >   max_postcopy_bandwidth, introduced likely by accident]
>> > Signed-off-by: Peter Xu <peterx@redhat.com>
>> > ---
>> >   qapi/migration.json            |   6 +-
>> >   migration/options.h            |   1 +
>> >   migration/migration-hmp-cmds.c |   6 +-
>> >   migration/options.c            | 144 +++++++++++++++++++--------------
>> >   migration/tls.c                |   2 +-
>> >   5 files changed, 93 insertions(+), 66 deletions(-)
>> > 
>> > diff --git a/migration/options.c b/migration/options.c
>> > index d55f3104be..6ef3c56fb6 100644
>> > --- a/migration/options.c
>> > +++ b/migration/options.c
>> (..)
>> > @@ -1243,7 +1274,7 @@ bool migrate_params_check(MigrationParameters *params, Error **errp)
>> >   #ifdef CONFIG_LINUX
>> >       if (migrate_zero_copy_send() &&
>> >           ((params->has_multifd_compression && params->multifd_compression) ||
>> > -         (params->tls_creds && *params->tls_creds))) {
>> > +         *params->tls_creds->u.s)) {
>> >           error_setg(errp,
>> >                      "Zero copy only available for non-compressed non-TLS multifd migration");
>> >           return false;
>> The above change gives me easily triggerable NULL pointer dereference:
>> > $ qemu-system-x86_64 -monitor stdio -global migration.x-multifd=true -global migration.x-zero-copy-send=true
>> > QEMU 10.2.93 monitor - type 'help' for more information
>> > VNC server running on ::1:5900
>> > (qemu) migrate_set_parameter downtime-limit 500
>> > Segmentation fault
>
> Oops..
>

Why do you guys still let me touch this codebase?

>> 
>> I guess params->tls_creds really needs that NULL check before being accessed.
>
> Yeah, my gut feeling is we got this special casing of using a temp
> parameter object..  I'll leave Fabiano to double check on that and send
> patch..
>
> Thanks for the report!

Good that I write my bugs with matching fixes to go along.

https://lore.kernel.org/r/20260202224101.20568-3-farosas@suse.de

I'll repost with a better commit message.


  reply	other threads:[~2026-04-14 19:35 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-23 14:29 [PULL 00/31] Next patches Peter Xu
2025-12-23 14:29 ` [PULL 01/31] migration: fix parsing snapshots with x-ignore-shared flag Peter Xu
2025-12-23 14:29 ` [PULL 02/31] migration: Fix writing mapped_ram + ignore_shared snapshots Peter Xu
2025-12-23 14:29 ` [PULL 03/31] scripts/analyze-migration: Rename RAM_SAVE_FLAG_COMPRESS to RAM_SAVE_FLAG_ZERO Peter Xu
2025-12-23 14:29 ` [PULL 04/31] scripts/analyze-migration: Support mapped-ram snapshot format Peter Xu
2025-12-23 14:29 ` [PULL 05/31] migration: Use explicit error_free() instead of g_autoptr Peter Xu
2025-12-23 14:29 ` [PULL 06/31] Revert "error: define g_autoptr() cleanup function for the Error type" Peter Xu
2025-12-23 14:29 ` [PULL 07/31] error: Poison g_autoptr(Error) to prevent its use Peter Xu
2025-12-23 14:29 ` [PULL 08/31] migration: Make migration_connect_set_error() own the error Peter Xu
2025-12-23 14:29 ` [PULL 09/31] migration: Make multifd_send_set_error() " Peter Xu
2025-12-23 14:29 ` [PULL 10/31] migration: Make multifd_recv_terminate_threads() " Peter Xu
2025-12-23 14:29 ` [PULL 11/31] migration: Replace migrate_set_error() with migrate_error_propagate() Peter Xu
2025-12-23 14:29 ` [PULL 12/31] migration: Use error_propagate() in migrate_error_propagate() Peter Xu
2025-12-23 14:29 ` [PULL 13/31] migration/options: Add x-ignore-shared Peter Xu
2025-12-23 14:29 ` [PULL 14/31] MAINTAINERS: Update reviewers for CPR Peter Xu
2025-12-23 14:29 ` [PULL 15/31] migration: Fix leak of block_bitmap_mapping Peter Xu
2025-12-23 14:29 ` [PULL 16/31] migration: Fix leak of cpr_exec_command Peter Xu
2025-12-23 14:29 ` [PULL 17/31] migration: Add a qdev property for StrOrNull Peter Xu
2026-01-22 13:21   ` Peter Maydell
2026-01-22 13:23   ` Peter Maydell
2026-01-22 13:49     ` Fabiano Rosas
2025-12-23 14:29 ` [PULL 18/31] tests/qtest/migration: Add a NULL parameters test for TLS Peter Xu
2025-12-23 14:29 ` [PULL 19/31] migration: Normalize tls arguments Peter Xu
2026-04-14 16:56   ` Maciej S. Szmigiero
2026-04-14 18:58     ` Peter Xu
2026-04-14 19:34       ` Fabiano Rosas [this message]
2025-12-23 14:29 ` [PULL 20/31] migration: Remove MigrateSetParameters Peter Xu
2025-12-23 14:29 ` [PULL 21/31] qapi/migration: Don't document MigrationParameter Peter Xu
2025-12-23 14:29 ` [PULL 22/31] migration: Run a post update routine after setting parameters Peter Xu
2025-12-23 14:29 ` [PULL 23/31] migration: Add a flag to track block-bitmap-mapping input Peter Xu
2025-12-23 14:29 ` [PULL 24/31] migration: Remove checks for s->parameters has_* fields Peter Xu
2025-12-23 14:29 ` [PULL 25/31] migration: Do away with usage of QERR_INVALID_PARAMETER_VALUE Peter Xu
2025-12-23 14:29 ` [PULL 26/31] migration: Extract code to mark all parameters as present Peter Xu
2025-12-23 14:29 ` [PULL 27/31] migration: Use QAPI_CLONE_MEMBERS in query_migrate_parameters Peter Xu
2025-12-23 14:29 ` [PULL 28/31] tests/qtest/migration: Pass MigrateCommon into test functions Peter Xu
2025-12-23 14:29 ` [PULL 29/31] tests/qtest/migration: Pass MigrateStart into cancel tests Peter Xu
2025-12-23 14:29 ` [PULL 30/31] migration: merge fragmented clear_dirty ioctls Peter Xu
2025-12-23 14:29 ` [PULL 31/31] MAINTAINERS: remove David from "Memory API" section Peter Xu
2025-12-28 22:08 ` [PULL 00/31] Next patches Richard Henderson

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=87340xz67t.fsf@suse.de \
    --to=farosas@suse.de \
    --cc=armbru@redhat.com \
    --cc=mail@maciej.szmigiero.name \
    --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.