From nobody Thu Dec 18 23:22:11 2025 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=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1765899575; cv=none; d=zohomail.com; s=zohoarc; b=in31bGPWMWR7KS7GuJzdieDMF9FddigXRzNh/VRDvJhJj0sIIpjoxKqdmRVx8/zKhgi8VJ3bvV57/2zPQJaUANvtT9iXLsmKczsvGxJNSLzy57TOhvEFd2R5h9ExbrvJgeyyOMTVKv0wROU/YZJsiJ01IaEGub2r8HhLGV42JTk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1765899575; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:Subject:Subject:To:To:Message-Id:Cc; bh=vK9k5jl1ToPMuKceiCs1s8do/1RQk9v2S7K5cMdVLVE=; b=fSDaumrNOK20928Uvzp/gH96oOAX8BXrQ7FGavIj7K05TKsrGnuefzxx+T37jQjOi09qgoQ/zLSR5IdZRuj2h5BNLVXAnzep1eBgGwGrMbz0lAQURCBwJ7gMefxbK98y1/geF6Tj69LkBK8AwAe6TisyrVSWF4qsuqjwugcs37A= ARC-Authentication-Results: i=1; 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=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1765899575867513.567667353751; Tue, 16 Dec 2025 07:39:35 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 993) id 69614418F5; Tue, 16 Dec 2025 10:39:30 -0500 (EST) Received: from [172.19.199.80] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id 9270841AFA; Tue, 16 Dec 2025 10:38:42 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 993) id 194AA418F2; Tue, 16 Dec 2025 10:38:27 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 1C91A41878 for ; Tue, 16 Dec 2025 10:38:24 -0500 (EST) Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-351-qDRiqRuDOMOAKbr4NuyfBQ-1; Tue, 16 Dec 2025 10:38:22 -0500 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E965C1801211 for ; Tue, 16 Dec 2025 15:38:21 +0000 (UTC) Received: from moe (unknown [10.43.3.236]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 551EF18004D8 for ; Tue, 16 Dec 2025 15:38:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1765899504; 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; bh=vK9k5jl1ToPMuKceiCs1s8do/1RQk9v2S7K5cMdVLVE=; b=EcRCNmzTXQ/TqZKNQHj0Q01D+6HNsZi+OgN+mCT6Ab4w7urwSysmAmkXaXsisK9+oh4Ebo KKJ1sujOiU8gvWaFQj02Vn2p0Vx54Q1TsV9xHlEX0qubUo8ASzz9hCWkqe+OW4OzGogVJ7 V+RvLXmhGtNHvymKRjbEwjdtoD/s5r8= X-MC-Unique: qDRiqRuDOMOAKbr4NuyfBQ-1 X-Mimecast-MFC-AGG-ID: qDRiqRuDOMOAKbr4NuyfBQ_1765899502 To: devel@lists.libvirt.org Subject: [PATCH] qemu_dbus: Escape path to dbus-daemon socket if needed Date: Tue, 16 Dec 2025 16:37:17 +0100 Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: s6Ci3u4AxLGQAM2bR32qecSMkaBjd-H0fVTbFuu9jQ4_1765899502 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: ZOUA43FZLALSRKOS5WHCDO37JA2BJM3U X-Message-ID-Hash: ZOUA43FZLALSRKOS5WHCDO37JA2BJM3U X-MailFrom: mprivozn@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Michal Privoznik via Devel Reply-To: Michal Privoznik X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1765899581599154100 Content-Type: text/plain; charset="utf-8"; x-default="true" From: Michal Privoznik According to [1] there are only few characters allowed in the path to the daemon socket (alphanum and some punctuation; notably, space is missing on the list). The rest must be escaped by '%NN' notation. Fortunately, g_uri_escape_string() with some carefully selected input values is able to escape the path. Almost - it considers tilde valid but DBus doesn't. Well, let's hope nobody has tilde in domain name. 1: https://gitlab.freedesktop.org/dbus/dbus/-/blob/2dee5236088bcf690ba92b74= 3a584720b8cb6f55/dbus/dbus-address.c#L332 Closes: https://gitlab.com/libvirt/libvirt/-/issues/834 Signed-off-by: Michal Privoznik --- src/qemu/qemu_dbus.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_dbus.c b/src/qemu/qemu_dbus.c index 625884ad46..db0757b71d 100644 --- a/src/qemu/qemu_dbus.c +++ b/src/qemu/qemu_dbus.c @@ -119,6 +119,12 @@ static int qemuDBusWriteConfig(const char *filename, const char *path, bool privilege= d) { g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; + /* Escape @path pointing to socket where the dbus-daemon is going to l= isten + * to. Valid characters are alphanumeric, '-', '_', '/', '\\', '*' and= '.'. + * The rest must be URI escaped. g_uri_escape_string() treads alphanum= eric, + * '-', '.', '_' and '~' as valid. + */ + g_autofree char *escapedPath =3D g_uri_escape_string(path, "/\\*", fal= se); g_autofree char *config =3D NULL; =20 virBufferAddLit(&buf, "org.libvirt.qemu\n"); - virBufferAsprintf(&buf, "unix:path=3D%s\n", path); + virBufferAsprintf(&buf, "unix:path=3D%s\n", escapedPa= th); virBufferAddLit(&buf, "EXTERNAL\n"); =20 virBufferAddLit(&buf, "\n"); --=20 2.51.2