From nobody Sun Feb 8 20:53:11 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=1591203748; cv=none; d=zohomail.com; s=zohoarc; b=C4D+lZPtwJzF1H3Ewu6ZT6fdEb8fXD2+qXV3hk07My6GcEXm61YKaqNAjr7/+mgbhAowenBZ99NplTkv1wfLYNOXKjR5EjR44b4UqNlCGfWP5kD1C9t+1XhHxzRLpFV9Z/pcpBE5RbErL7767OnR2FI46/nIVbmOFrCTJXK0Dzw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591203748; 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=PqjrjzYDM7Ya+nvjz4wLIJ9FhkgdkjAvIUabTNTDvHA=; b=LM8dB0Vo/KetWIGNJGrdFu1jBnPUr+pVEpMn5HplNOHx0zA81WYaM2msq7AMgEXb52DlFymcIm5FrbQ2WFZ67G1bUXFxLktqfrV7JKGpuekl+1iZhUPPoEvl6ENLTENqCRraTy9f1uLCI+PAEZ6k4Kj69FhhVT+sYAOk5fuT4Bg= 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 159120374825483.59450408141652; Wed, 3 Jun 2020 10:02:28 -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-482-S1OWmL9eN8aeFF3J-OK-Lg-1; Wed, 03 Jun 2020 13:02:14 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D2DDC1902EA1; Wed, 3 Jun 2020 17:02:08 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B45D198FF1; Wed, 3 Jun 2020 17:02:08 +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 80A5A1809554; Wed, 3 Jun 2020 17:02:08 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 053H1qxu006307 for ; Wed, 3 Jun 2020 13:01:52 -0400 Received: by smtp.corp.redhat.com (Postfix) id DA33560C81; Wed, 3 Jun 2020 17:01:52 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.193.222]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5B12460BF4 for ; Wed, 3 Jun 2020 17:01:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591203746; 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=PqjrjzYDM7Ya+nvjz4wLIJ9FhkgdkjAvIUabTNTDvHA=; b=YXXA9fmUOOHrxH4q3oxuUR+NKMsqsfL7r2cmlfwkdjbIdSET1/fp4PneYUPU9qPIaIuLMt EOQhMJ7rmRDwgjMEBcK0vFxcaz+vbC0dUoEfcG5kclzbfa1P0utmiiP4JycMZzJn4FU/gw cQzWkmh3fgaMQ4DGuHSVorKWwqm/5Ig= X-MC-Unique: S1OWmL9eN8aeFF3J-OK-Lg-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 3/6] qemu: Validate firmware blob configuration Date: Wed, 3 Jun 2020 19:01:35 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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.11 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 | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index 584d1375b8..1274159b39 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 +qemuValidateDomainDefFWCfg(const virDomainDef *def, + virQEMUCapsPtr qemuCaps G_GNUC_UNUSED) +{ + size_t i; + + for (i =3D 0; i < def->nfw_cfgs; i++) { + const virDomainFWCfgDef *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,9 @@ qemuValidateDomainDef(const virDomainDef *def, } } =20 + if (qemuValidateDomainDefFWCfg(def, qemuCaps) < 0) + return -1; + return 0; } =20 --=20 2.26.2