From nobody Sun Feb 8 22:03:03 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 172664895522396.6706470213361; Wed, 18 Sep 2024 01:42:35 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 0FAA9BB1; Wed, 18 Sep 2024 04:42:34 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 7744C1B83; Wed, 18 Sep 2024 04:41:44 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id AA0CA14B5; Wed, 18 Sep 2024 04:41:40 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 30CBA1497 for ; Wed, 18 Sep 2024 04:41:40 -0400 (EDT) Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-468-tIzG-r5xPwqvA_1WEHhQ5Q-1; Wed, 18 Sep 2024 04:41:38 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id BC3361955D59 for ; Wed, 18 Sep 2024 08:41:37 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.5]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id D650919560AA for ; Wed, 18 Sep 2024 08:41:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.5 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1726648899; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4A++Q2m4mPv9BEb/k+5lxHBicMUkN79l8+RdAiu0dTM=; b=KRwe5G3kVPwuA+xARmJ+sG2pH9mgUDZ7zkMm8g7ayNTg2H9+a6B/69GitEqJr9Y+kovFKA sIRSJjhYI80USOd+D7tqD5+60V/oF7pXQONPPqJ04OLWttvJnH8pb4xOhYUaVj/kxctBtv 44gPPos9/PSMavO1CLt4+2FsVpgZCQY= X-MC-Unique: tIzG-r5xPwqvA_1WEHhQ5Q-1 From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH 2/2] qemu: Reject unsupported chardev backend protocols Date: Wed, 18 Sep 2024 10:41:32 +0200 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: VH6ZBY56BA577Z5MZ3XU4LIISO3BP53I X-Message-ID-Hash: VH6ZBY56BA577Z5MZ3XU4LIISO3BP53I X-MailFrom: pkrempa@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1726648956123116600 Content-Type: text/plain; charset="utf-8" QEMU supports only 'raw' and 'telnet' in the element. Reject 'telnets' and 'tls'. TLS transport for qemu chardevs is configured via "tls=3D'yes'" attribute added to the "" element instead, so this prevents potential misconfig as the value would be silently accepted. Closes: https://gitlab.com/libvirt/libvirt/-/issues/412 Signed-off-by: Peter Krempa --- src/qemu/qemu_validate.c | 19 +++++++++++++++ ...rial-tcp-chardev-telnets.x86_64-latest.err | 1 + .../serial-tcp-chardev-telnets.xml | 23 +++++++++++++++++++ tests/qemuxmlconftest.c | 1 + 4 files changed, 44 insertions(+) create mode 100644 tests/qemuxmlconfdata/serial-tcp-chardev-telnets.x86_64= -latest.err create mode 100644 tests/qemuxmlconfdata/serial-tcp-chardev-telnets.xml diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index 1954daea52..fa23c5f973 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -2044,6 +2044,25 @@ qemuValidateDomainChrSourceDef(const virDomainChrSou= rceDef *def, { switch ((virDomainChrType)def->type) { case VIR_DOMAIN_CHR_TYPE_TCP: + switch (def->data.tcp.protocol) { + case VIR_DOMAIN_CHR_TCP_PROTOCOL_RAW: + case VIR_DOMAIN_CHR_TCP_PROTOCOL_TELNET: + break; + + case VIR_DOMAIN_CHR_TCP_PROTOCOL_TELNETS: + case VIR_DOMAIN_CHR_TCP_PROTOCOL_TLS: + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("tcp chardev protocol '%1$s' not supported"), + virDomainChrTcpProtocolTypeToString(def->data.t= cp.protocol)); + return -1; + + case VIR_DOMAIN_CHR_TCP_PROTOCOL_LAST: + default: + virReportEnumRangeError(virDomainChrTcpProtocol, def->data.tcp= .protocol); + return -1; + + } + if (qemuValidateDomainChrSourceReconnectDef(&def->data.tcp.reconne= ct) < 0) return -1; break; diff --git a/tests/qemuxmlconfdata/serial-tcp-chardev-telnets.x86_64-latest= .err b/tests/qemuxmlconfdata/serial-tcp-chardev-telnets.x86_64-latest.err new file mode 100644 index 0000000000..6447c96cd9 --- /dev/null +++ b/tests/qemuxmlconfdata/serial-tcp-chardev-telnets.x86_64-latest.err @@ -0,0 +1 @@ +unsupported configuration: tcp chardev protocol 'tls' not supported diff --git a/tests/qemuxmlconfdata/serial-tcp-chardev-telnets.xml b/tests/q= emuxmlconfdata/serial-tcp-chardev-telnets.xml new file mode 100644 index 0000000000..07c36e0fa0 --- /dev/null +++ b/tests/qemuxmlconfdata/serial-tcp-chardev-telnets.xml @@ -0,0 +1,23 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 1 + + hvm + + + /usr/bin/qemu-system-x86_64 + + + + + + + + + + + + + diff --git a/tests/qemuxmlconftest.c b/tests/qemuxmlconftest.c index 323fd9d721..821b8da25a 100644 --- a/tests/qemuxmlconftest.c +++ b/tests/qemuxmlconftest.c @@ -1838,6 +1838,7 @@ mymain(void) DO_TEST_CAPS_LATEST("serial-unix-chardev"); DO_TEST_CAPS_LATEST_PARSE_ERROR("serial-unix-missing-source"); DO_TEST_CAPS_LATEST("serial-tcp-chardev"); + DO_TEST_CAPS_LATEST_PARSE_ERROR("serial-tcp-chardev-telnets"); DO_TEST_CAPS_LATEST("serial-udp-chardev"); DO_TEST_CAPS_LATEST("serial-tcp-telnet-chardev"); driver.config->chardevTLS =3D 1; --=20 2.46.0