From nobody Mon Feb 9 07:55:37 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1605250599; cv=none; d=zohomail.com; s=zohoarc; b=NmWdZDkDlKWFILjolADQCpW1abRNLqOAYKcNMX6YVlN2O399/8m3iEOFuea/qw2PoBGICE+r1LkIZfvCG5xiX2laJJBJI4xKkNR7rW67srnkLU1b98S35D79/qhg+v1KRXAH0+OCw23QbKQX028ySi8S6zF/sKjqXR4SOfvHZOI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605250599; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=j1KuvpX+tCgUhZIK/rgs/gHcu3KBWyNP/amqjnIWs/A=; b=GedPP53f5lWm54+Lo+NsoA+dfqgIg5LwNXbU3vPtWVdQhWnDlQY+dXL0i1Gmq0r5faP/uP2lZ9ZbHceqhp8ezsDabQlYhtbQOxwTu7r38LtlTsLY8qywn5El7cmSBlTMyB4jdZFCkA3j4/A3AUhvemKA2W4M3AxB4iAhSLsr09M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1605250599467179.4660581437048; Thu, 12 Nov 2020 22:56:39 -0800 (PST) Received: from localhost ([::1]:34692 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kdT0g-0007g3-Em for importer@patchew.org; Fri, 13 Nov 2020 01:56:38 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:46768) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kdSwv-0003dq-2e for qemu-devel@nongnu.org; Fri, 13 Nov 2020 01:52:45 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:44107) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kdSws-0006EU-0W for qemu-devel@nongnu.org; Fri, 13 Nov 2020 01:52:44 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-21-u8HhlRY6MOuWy6APtgNwTg-1; Fri, 13 Nov 2020 01:52:38 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id F0AD15F9E3 for ; Fri, 13 Nov 2020 06:52:37 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-103.ams2.redhat.com [10.36.112.103]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 989EF19C66; Fri, 13 Nov 2020 06:52:37 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 21FCD11386A3; Fri, 13 Nov 2020 07:52:36 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605250361; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=j1KuvpX+tCgUhZIK/rgs/gHcu3KBWyNP/amqjnIWs/A=; b=Tj6uQ/FLaWVL575lZWQ3dmuXgfGcK+DbYKZqKYQzshjqevdlmPpeZvXEAQV52FPy3vsfoc hs1BhVKKrv9vHYSgWs1sdXZq57FWmdTt39wnxTbKa8+E95DxV87iN2llFvylLUD9VTEcHu UpJ3JNoQCdGWrYYlAjeyZDUImHa0GeI= X-MC-Unique: u8HhlRY6MOuWy6APtgNwTg-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 1/6] migration: Fix and clean up around @tls-authz Date: Fri, 13 Nov 2020 07:52:31 +0100 Message-Id: <20201113065236.2644169-2-armbru@redhat.com> In-Reply-To: <20201113065236.2644169-1-armbru@redhat.com> References: <20201113065236.2644169-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/12 08:00:44 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , dgilbert@redhat.com, quintela@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Commit d2f1d29b95 "migration: add support for a "tls-authz" migration parameter" added MigrationParameters member @tls-authz. Whereas the other members aren't really optional (see commit 1bda8b3c695), this one is genuinely optional: migration_instance_init() leaves it absent, and migration_tls_channel_process_incoming() passes it to qcrypto_tls_session_new(), which checks for null. Commit d2f1d29b95 has a number of issues, though: * When qmp_query_migrate_parameters() copies migration parameters into its reply, it ignores has_tls_authz, and assumes true instead. When it is false, - HMP info migrate_parameters prints the null pointer (crash bug on some systems), and - QMP query-migrate-parameters replies "tls-authz": "" (because the QObject output visitor silently maps null pointer to "", which it really shouldn't). The HMP defect was noticed and fixed in commit 7cd75cbdb8 'migration: use "" instead of (null) for tls-authz'. Unfortunately, the fix papered over the real bug: it made qmp_query_migrate_parameters() map null tls_authz to "". It also dropped the check for has_tls_authz from hmp_info_migrate_parameters(). Revert, and fix qmp_query_migrate_parameters() not to screw up has_tls_authz. No change to HMP. QMP now has "tls-authz" in the reply only when it's actually present in migrate_get_current()->parameters. If we prefer to remain bug-compatible, we should make tls_authz non-optional there. * migrate_params_test_apply() neglects to apply tls_authz. Currently harmless, because migrate_params_check() doesn't care. Fix it anyway. * qmp_migrate_set_parameters() crashes: {"execute": "migrate-set-parameters", "arguments": {"tls-authz": null}} Add the necessary rewrite of null to "". For background information, see commit 01fa559826 "migration: Use JSON null instead of "" to reset parameter to default". Fixes: d2f1d29b95aa45d13262b39153ff501ed6b1ac95 Cc: Daniel P. Berrang=C3=A9 Signed-off-by: Markus Armbruster Reviewed-by: Dr. David Alan Gilbert --- qapi/migration.json | 2 +- migration/migration.c | 17 ++++++++++++++--- monitor/hmp-cmds.c | 2 +- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/qapi/migration.json b/qapi/migration.json index 3c75820527..688e8da749 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -928,7 +928,7 @@ ## # @MigrationParameters: # -# The optional members aren't actually optional. +# The optional members aren't actually optional, except for @tls-authz. # # @announce-initial: Initial delay (in milliseconds) before sending the # first announce (Since 4.0) diff --git a/migration/migration.c b/migration/migration.c index 3263aa55a9..cad56fbf8c 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -855,9 +855,8 @@ MigrationParameters *qmp_query_migrate_parameters(Error= **errp) params->tls_creds =3D g_strdup(s->parameters.tls_creds); params->has_tls_hostname =3D true; params->tls_hostname =3D g_strdup(s->parameters.tls_hostname); - params->has_tls_authz =3D true; - params->tls_authz =3D g_strdup(s->parameters.tls_authz ? - s->parameters.tls_authz : ""); + params->has_tls_authz =3D s->parameters.has_tls_authz; + params->tls_authz =3D g_strdup(s->parameters.tls_authz); params->has_max_bandwidth =3D true; params->max_bandwidth =3D s->parameters.max_bandwidth; params->has_downtime_limit =3D true; @@ -1433,6 +1432,11 @@ static void migrate_params_test_apply(MigrateSetPara= meters *params, dest->tls_hostname =3D params->tls_hostname->u.s; } =20 + if (params->has_tls_authz) { + assert(params->tls_authz->type =3D=3D QTYPE_QSTRING); + dest->tls_authz =3D params->tls_authz->u.s; + } + if (params->has_max_bandwidth) { dest->max_bandwidth =3D params->max_bandwidth; } @@ -1622,6 +1626,13 @@ void qmp_migrate_set_parameters(MigrateSetParameters= *params, Error **errp) params->tls_hostname->type =3D QTYPE_QSTRING; params->tls_hostname->u.s =3D strdup(""); } + /* TODO Rewrite "" to null instead */ + if (params->has_tls_authz + && params->tls_authz->type =3D=3D QTYPE_QNULL) { + qobject_unref(params->tls_authz->u.n); + params->tls_authz->type =3D QTYPE_QSTRING; + params->tls_authz->u.s =3D strdup(""); + } =20 migrate_params_test_apply(params, &tmp); =20 diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index a6a6684df1..492789248f 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -476,7 +476,7 @@ void hmp_info_migrate_parameters(Monitor *mon, const QD= ict *qdict) params->max_postcopy_bandwidth); monitor_printf(mon, "%s: '%s'\n", MigrationParameter_str(MIGRATION_PARAMETER_TLS_AUTHZ), - params->tls_authz); + params->has_tls_authz ? params->tls_authz : ""); =20 if (params->has_block_bitmap_mapping) { const BitmapMigrationNodeAliasList *bmnal; --=20 2.26.2