From nobody Thu May 9 00:15:12 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1533458728717301.2103623229341; Sun, 5 Aug 2018 01:45:28 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.25]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EC5F13082151; Sun, 5 Aug 2018 08:45:26 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B58442010CB5; Sun, 5 Aug 2018 08:45:26 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 671FA4EE0C; Sun, 5 Aug 2018 08:45:26 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w71Fo8Sx014117 for ; Wed, 1 Aug 2018 11:50:08 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1626F20180EB; Wed, 1 Aug 2018 15:50:08 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.43.2.122]) by smtp.corp.redhat.com (Postfix) with ESMTP id 853082026D68; Wed, 1 Aug 2018 15:50:07 +0000 (UTC) From: Simon Kobyda To: libvir-list@redhat.com Date: Wed, 1 Aug 2018 17:50:03 +0200 Message-Id: <20180801155003.23929-1-skobyda@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Cc: Simon Kobyda Subject: [libvirt] [PATCH v3] conf: virDomainDefValidateInternal prohibit some characters in shmem name X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.25 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Sun, 05 Aug 2018 08:45:27 +0000 (UTC) X-ZohoMail: RDMRC_0 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Validate that the provided XML shmem name is not directory specific "." or ".." names as well as ensuring that there is no path separator '/' in the name. https://bugzilla.redhat.com/show_bug.cgi?id=3D1192400 Signed-off-by: Simon Kobyda Reviewed-by: Martin Kletzander --- Changes in v3: - moved the functionality to virDomainDeviceDefValidateInternal - documented changes in docs/formatdomain.html.in docs/formatdomain.html.in | 4 +++- src/conf/domain_conf.c | 29 ++++++++++++++++++++++++++++- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index a3afe137bf..f18ca6fc64 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -8017,7 +8017,9 @@ qemu-kvm -net nic,model=3D? /dev/null
shmem
The shmem element has one mandatory attribute, - name to identify the shared memory. + name to identify the shared memory. This attribute cann= ot + be directory specific to . or .. as well as + it cannot involve path separator /.
model
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 7ab2953d83..415c03c56f 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -5696,6 +5696,31 @@ virDomainVsockDefValidate(const virDomainVsockDef *v= sock) } =20 =20 +static int +virDomainShmemDefValidate(const virDomainShmemDef *shmem) +{ + if (strchr(shmem->name, '/')) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("shmem name cannot include '/' character")); + return -1; + } + + if (STREQ(shmem->name, ".")) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("shmem name cannot be equal to '.'")); + return -1; + } + + if (STREQ(shmem->name, "..")) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("shmem name cannot be equal to '..'")); + return -1; + } + + return 0; +} + + static int virDomainDeviceDefValidateInternal(const virDomainDeviceDef *dev, const virDomainDef *def) @@ -5734,6 +5759,9 @@ virDomainDeviceDefValidateInternal(const virDomainDev= iceDef *dev, case VIR_DOMAIN_DEVICE_VSOCK: return virDomainVsockDefValidate(dev->data.vsock); =20 + case VIR_DOMAIN_DEVICE_SHMEM: + return virDomainShmemDefValidate(dev->data.shmem); + case VIR_DOMAIN_DEVICE_LEASE: case VIR_DOMAIN_DEVICE_FS: case VIR_DOMAIN_DEVICE_INPUT: @@ -5743,7 +5771,6 @@ virDomainDeviceDefValidateInternal(const virDomainDev= iceDef *dev, case VIR_DOMAIN_DEVICE_HUB: case VIR_DOMAIN_DEVICE_MEMBALLOON: case VIR_DOMAIN_DEVICE_NVRAM: - case VIR_DOMAIN_DEVICE_SHMEM: case VIR_DOMAIN_DEVICE_TPM: case VIR_DOMAIN_DEVICE_PANIC: case VIR_DOMAIN_DEVICE_IOMMU: --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list