From nobody Sat Feb 7 07:11:30 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1646704113; cv=none; d=zohomail.com; s=zohoarc; b=Zi+zvhAoPMI94KypsJ/g36UDQ8AeQxMRWzswkXw583hrVghF6di3buvUTWYz+z7Rd0I58PTeNfQTdQbdlenjV4vqQ9Eu58W5LplHRjraFABt+mE1VfrgdgLDCqYhTuT0P+Tnnq3j1WaWU2yHvuJHjAyZqarD1l5bPMWiOKUeHpU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1646704113; 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=+agItL/XUOQbbSqoHJElHeQQ7syR3OpEBARbARpSXuQ=; b=SW6oWsOUy2I7weJSaDXdnYiBWcOk11KW4wN74WctYXjuJd9VyHk1M6FMzuDKPc/sgZIjmMWpb8Ot9SkyqDFiJTpsMCK4lTrplgDvYejyHrNO4p+JlMvjF48JKH65RZ70vgO9A/V3KqlOYsLzoP8KwI3LugdDxHRltTBEB9AUOYY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1646704113726740.8361347044417; Mon, 7 Mar 2022 17:48:33 -0800 (PST) Received: from localhost ([::1]:48172 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nROxl-0002u8-2f for importer@patchew.org; Mon, 07 Mar 2022 20:48:33 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52718) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nROtp-0008Tp-L9 for qemu-devel@nongnu.org; Mon, 07 Mar 2022 20:44:29 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:36083) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nROtm-0006LI-T5 for qemu-devel@nongnu.org; Mon, 07 Mar 2022 20:44:28 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-501-_hn9rgWgPnub08K1ktJ1Ew-1; Mon, 07 Mar 2022 20:44:24 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 460F01800D50 for ; Tue, 8 Mar 2022 01:44:23 +0000 (UTC) Received: from blue.redhat.com (unknown [10.2.16.5]) by smtp.corp.redhat.com (Postfix) with ESMTP id CCDC045C8C; Tue, 8 Mar 2022 01:44:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646703865; 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=+agItL/XUOQbbSqoHJElHeQQ7syR3OpEBARbARpSXuQ=; b=XTeFLlt5slNMMpzXKjNroai1X+//ic+oSo/VhqTtCb6Iu9ZPZnRJyuJ+1nr0y2Bps7+JHX m1jVL7/ALRBkP3bXPWEPQX8jyu12hnrMFkmTT9Roi28MNA0nYT9Krr1pSdbx8KOJNNHn4v iQOu/9CACmbR1i+VlRwPf6IgV4S/p/k= X-MC-Unique: _hn9rgWgPnub08K1ktJ1Ew-1 From: Eric Blake To: qemu-devel@nongnu.org Subject: [PULL 01/15] crypto: mandate a hostname when checking x509 creds on a client Date: Mon, 7 Mar 2022 19:44:05 -0600 Message-Id: <20220308014419.3056549-2-eblake@redhat.com> In-Reply-To: <20220308014419.3056549-1-eblake@redhat.com> References: <20220308014419.3056549-1-eblake@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=eblake@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=170.10.129.124; envelope-from=eblake@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1646704116385100001 From: Daniel P. Berrang=C3=A9 Currently the TLS session object assumes that the caller will always provide a hostname when using x509 creds on a client endpoint. This relies on the caller to detect and report an error if the user has configured QEMU with x509 credentials on a UNIX socket. The migration code has such a check, but it is too broad, reporting an error when the user has configured QEMU with PSK credentials on a UNIX socket, where hostnames are irrelevant. Putting the check into the TLS session object credentials validation code ensures we report errors in only the scenario that matters. Reviewed-by: Eric Blake Signed-off-by: Daniel P. Berrang=C3=A9 Message-Id: <20220304193610.3293146-2-berrange@redhat.com> Signed-off-by: Eric Blake --- crypto/tlssession.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/crypto/tlssession.c b/crypto/tlssession.c index a8db8c76d138..b302d835d215 100644 --- a/crypto/tlssession.c +++ b/crypto/tlssession.c @@ -373,6 +373,12 @@ qcrypto_tls_session_check_certificate(QCryptoTLSSessio= n *session, session->hostname); goto error; } + } else { + if (session->creds->endpoint =3D=3D + QCRYPTO_TLS_CREDS_ENDPOINT_CLIENT) { + error_setg(errp, "No hostname for certificate validati= on"); + goto error; + } } } --=20 2.35.1