From nobody Sun Feb 8 17:55:08 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1591402906; cv=none; d=zohomail.com; s=zohoarc; b=e762eKymy55d9uyxxSO5Vf9aIea7P6WndZpKmvo9S1D5jqfWNQT458pcN2FLOrUfZXHGxe5Of2x7EVFDXN92YNbbBfSiKmuWlgZl8DgVWuSLpPrnkopttEpWdNOoItxmgjRiWdS8cBEFuUQP4HPR7fmpjuWY1RT/UvxJmu8BjTc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591402906; h=Content-Type:Content-Transfer-Encoding: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=stlIKTexXb5w1f/TLB139ZV6U+sUn2jysT+YbH1Xhdw=; b=U3yHinlYqFSMNBs/ckXdx+OI2SsIRvDuDoiLEa1UBAd2naNuyKVz7ovgV6lBewkmjSqNh4I6PhQdtL0vZw8CfO3pOJ4If5AhCveSz9TT8ZGgP9k5NPwefa4HdHGtkRAGlXu7ijHSa7ESepzg35ZbdaLzowu3YhbJjhYb47qqoog= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1591402906032721.0903116537909; Fri, 5 Jun 2020 17:21:46 -0700 (PDT) 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-42-MdSDF-tQP4eydgWVZFsIVA-1; Fri, 05 Jun 2020 20:21:42 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3C36310506ED; Sat, 6 Jun 2020 00:21:37 +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 1B7B84149; Sat, 6 Jun 2020 00:21:37 +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 E43DD104859; Sat, 6 Jun 2020 00:21:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 054IiITp002467 for ; Thu, 4 Jun 2020 14:44:18 -0400 Received: by smtp.corp.redhat.com (Postfix) id 54A3D101E675; Thu, 4 Jun 2020 18:44:18 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.192.79]) by smtp.corp.redhat.com (Postfix) with ESMTP id C956910013D6 for ; Thu, 4 Jun 2020 18:44:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591402904; h=from:from:sender:sender: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=stlIKTexXb5w1f/TLB139ZV6U+sUn2jysT+YbH1Xhdw=; b=MfQ8I4+lXk6RRGwMOqDaJvddyUFPhP/1UY+ByRLlqv+JSOH1AiNGfMEaB8REmRKwIBI3ce b9CYho771qVSXfX3mOfOcRmU5LJV8N5LQXsTHgvuvJ7uSNB9uL+D+AZkV1WxLvB1TiEtYr G3N67sCcenEqCQgXkuZYKOP2wLSESgQ= X-MC-Unique: MdSDF-tQP4eydgWVZFsIVA-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v2 4/8] qemu: Validate firmware blob configuration Date: Thu, 4 Jun 2020 20:44:05 +0200 Message-Id: <0e6e4bd4b61374a3669824727ceaf12f1096e77e.1591296169.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" There are recommendations and limitations to the name of the config blobs we need to follow [1]. Firstly, we don't want users to change any value only add new blobs. This means, that the name must have "opt/" prefix and at the same time must not begin with "opt/ovmf" nor "opt/org.qemu" as these are reserved for OVMF or QEMU respectively. Secondly, there is a limit (FW_CFG_MAX_FILE_PATH in qemu.git) of 56 characters for filename. 1: docs/specs/fw_cfg.txt from qemu.git Signed-off-by: Michal Privoznik --- src/qemu/qemu_validate.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index 584d1375b8..56a7ebfd7f 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -762,6 +762,41 @@ qemuValidateDefGetVcpuHotplugGranularity(const virDoma= inDef *def) } =20 =20 +#define QEMU_FW_CFG_MAX_FILE_PATH 55 +static int +qemuValidateDomainDefSysinfo(const virSysinfoDef *def, + virQEMUCapsPtr qemuCaps G_GNUC_UNUSED) +{ + size_t i; + + for (i =3D 0; i < def->nfw_cfgs; i++) { + const virSysinfoFWCfgDef *f =3D &def->fw_cfgs[i]; + + if (!STRPREFIX(f->name, "opt/")) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Invalid firmware name")); + return -1; + } + + if (STRPREFIX(f->name, "opt/ovmf/") || + STRPREFIX(f->name, "opt/org.qemu/")) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("That firmware name is reserved")); + return -1; + } + + if (f->file && + strlen(f->file) > QEMU_FW_CFG_MAX_FILE_PATH) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("firmware file too long")); + return -1; + } + } + + return 0; +} + + int qemuValidateDomainDef(const virDomainDef *def, void *opaque) @@ -978,6 +1013,11 @@ qemuValidateDomainDef(const virDomainDef *def, } } =20 + for (i =3D 0; i < def->nsysinfo; i++) { + if (qemuValidateDomainDefSysinfo(def->sysinfo[i], qemuCaps) < 0) + return -1; + } + return 0; } =20 --=20 2.26.2