From nobody Sun Feb 8 20:13:40 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 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=1591777833; cv=none; d=zohomail.com; s=zohoarc; b=fbpPjMrSwGLtaiSVtKLtGACFcBnjO9fUmbVNnWm0PQ4lP3eGKouuATgLjVTFYmYtAn2L9UnlU0CmrBPd3JHjTabUbYizvJ4oW4CdBNohW2uAwKhm4vtgZV17M5T8/EokX56P5RF1BoUlS1+xqbzwHhfxazKGr6Tzn41KeXCZ9YQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591777833; 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=jBasgILozt2G1vqYVp0WZzQdXUn/Hnr89i7Z4AbZ2Tk=; b=GYbjwUmnZyH8qyTA6htg/AylNsfofpLfHCSQl9ws91cfWlY+abv6ym+DV8s0Rew8tpTBYBfccUvVXEdqszMujE022lsP73lfoCDmXZlEGo2S3gSqtuG2Y/KrWOMmhKzu+4zjuRhl03YBhvbw50KKxsfc8FFoRlDqmh7rR3lwo78= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 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-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1591777833677275.3130356503377; Wed, 10 Jun 2020 01:30:33 -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-237-K00DvRrnNw6BClTSSDkQBw-1; Wed, 10 Jun 2020 04:30:30 -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 A9136A0BDC; Wed, 10 Jun 2020 08:30:24 +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 834049F4B; Wed, 10 Jun 2020 08:30:24 +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 70FB91809547; Wed, 10 Jun 2020 08:30:23 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 05A8Ngiv006930 for ; Wed, 10 Jun 2020 04:23:42 -0400 Received: by smtp.corp.redhat.com (Postfix) id 538EF5C3FD; Wed, 10 Jun 2020 08:23:42 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.195.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id C8FA85C1BD for ; Wed, 10 Jun 2020 08:23:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591777832; 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=jBasgILozt2G1vqYVp0WZzQdXUn/Hnr89i7Z4AbZ2Tk=; b=IgrMhcYJDw5GLPFWoOW+tpqO1Lf/S6WmaKsGqqn3OKONGyg48CVvXHWgzZs640PRr367Ea 6v+mE34A6WPzk6DVw//doS2cDKJgI5EdOW8jdIiWgulNA9ZVLb7cizPNnWtSUSwemH26Hq rzBro3rKUmYXwuvbk7MjxpQ2+Z8K8qs= X-MC-Unique: K00DvRrnNw6BClTSSDkQBw-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v3 2/6] qemu: Validate firmware blob configuration Date: Wed, 10 Jun 2020 10:23:30 +0200 Message-Id: <2a44306d2163cb3b3df19477dc23fc1454ed9d29.1591776549.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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 Reviewed-by: Daniel P. Berrang=C3=A9 --- src/qemu/qemu_validate.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index 584d1375b8..b1a81ab193 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -762,6 +762,33 @@ qemuValidateDefGetVcpuHotplugGranularity(const virDoma= inDef *def) } =20 =20 +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; + } + } + + return 0; +} + + int qemuValidateDomainDef(const virDomainDef *def, void *opaque) @@ -978,6 +1005,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