From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f65.google.com (mail-wm1-f65.google.com [209.85.128.65]) by mx.groups.io with SMTP id smtpd.web12.10946.1583134197792851718 for ; Sun, 01 Mar 2020 23:29:58 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@linaro.org header.s=google header.b=s1+ZJ1KL; spf=pass (domain: linaro.org, ip: 209.85.128.65, mailfrom: ard.biesheuvel@linaro.org) Received: by mail-wm1-f65.google.com with SMTP id 6so1382820wmi.5 for ; Sun, 01 Mar 2020 23:29:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=zQkz7EDO/mHEl/Qic1yqgw9FS1Tbt9D4RCo9yWdrp1E=; b=s1+ZJ1KLikhFMdaK0A05Jrf2ind72WPKzuS97ZFOfd4roaM8oohZOp+HXNK2VvytWC d0wyIzRHho9j7HjcGD3zv58BRHglmbKnRt7sq8MlTFZZYUAyAD8TtrKU6ETZR7k0s+xO WK8fx7PS0qjApkiiFEfCwbPrCx209lVWniFQinOueXZxQJYiza6DtDTDZo7Grm38Qh3F 2GlrVddrB/8zhED8/ha7J8/1LuQtMUh8PSNyIzNhM/is4VgNQ2y7gt2sOQ3uWbjpolv3 9dt5ZjDwBWCeqYm5V6MoOHkopWpaESQtAMKSq4n8RIA49+Fm9avKQklPkIllIb6Aapb3 MfOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=zQkz7EDO/mHEl/Qic1yqgw9FS1Tbt9D4RCo9yWdrp1E=; b=Y9pTfORiNfYpfsPPN4+v4x8D94xR3lODbJk5FNXIWQ1RM85DvXKkxMIHg6aZ3f8fAc VUN34Wi94VCqTx1gzEJj2OFJtUbfl2ZO+Mg/kyyTiWsI2p4wzXiSmdzuKWSsdH6YUIMo LyQ9H6xf8n1TyK5sc/aWo61YC9pREuSyp6b0Kr1FEFlcCxmPt0sJMWOPi4wussR4xbSY tJ8VLa92UReEx/Q9OgRYcIuIASl+s8Q4jH+f6n6WNJGHAlaISSQ6sv8DwnP9OHPnCS5j +/6mvPoFjVIjMy0vavcRFIhfG5r5AXyPpoqpiiSrqKaAg9r8PhKhszUdVgEJ96mQQs3Z jZLA== X-Gm-Message-State: APjAAAXFWWNq0JKayYFSn74FVzf4PCykzzyHulu0P7bI6saGLXhVJspp +x2UTIOurcqV0jK2MFLMv1y/Ko6j3pCe/g== X-Google-Smtp-Source: APXvYqwPAquq3xOBqjJJHubST5N165ldzyObbr5U8OnW8M8PZaO1PpuHNEvscJQRuub5kPCzPfyuiA== X-Received: by 2002:a7b:c257:: with SMTP id b23mr17864673wmj.70.1583134196058; Sun, 01 Mar 2020 23:29:56 -0800 (PST) Return-Path: Received: from e123331-lin.home ([2a01:cb1d:112:6f00:816e:ff0d:fb69:f613]) by smtp.gmail.com with ESMTPSA id z131sm6347153wmg.25.2020.03.01.23.29.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Mar 2020 23:29:55 -0800 (PST) From: "Ard Biesheuvel" To: devel@edk2.groups.io Cc: lersek@redhat.com, Ard Biesheuvel Subject: [PATCH 13/13] OvmfPkg: use generic QEMU image loader for secure boot enabled builds Date: Mon, 2 Mar 2020 08:29:36 +0100 Message-Id: <20200302072936.29221-14-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200302072936.29221-1-ard.biesheuvel@linaro.org> References: <20200302072936.29221-1-ard.biesheuvel@linaro.org> The QemuLoadImageLib implementation we currently use for all OVMF builds copies the behavior of the QEMU loader code that precedes it, which is to disregard UEFI secure boot policies entirely when it comes to loading kernel images that have been specified on the QEMU command line. This behavior deviates from ArmVirtQemu based builds, which do take UEFI secure boot policies into account, and refuse to load images from the command line that cannot be authenticated. The disparity was originally due to the fact that the QEMU command line kernel loader did not use LoadImage and StartImage at all, but this changed recently, and now, there are only a couple of reasons left to stick with the legacy loader: - it permits loading images that lack a valid PE/COFF header, - it permits loading X64 kernels on IA32 firmware running on a X64 capable system. Since every non-authentic PE/COFF image can trivially be converted into an image that lacks a valid PE/COFF header, the former case can simply not be supported in a UEFI secure boot context. The latter case is highly theoretical, given that one could easily switch to native X64 firmware in a VM scenario. That leaves us with little justification to use the legacy loader at all when UEFI secure boot policies are in effect, so let's switch to the generic loader for UEFI secure boot enabled builds. Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=2566 Signed-off-by: Ard Biesheuvel --- OvmfPkg/OvmfPkgIa32.dsc | 4 ++++ OvmfPkg/OvmfPkgIa32X64.dsc | 4 ++++ OvmfPkg/OvmfPkgX64.dsc | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc index 2cc924a6986a..eceddb71948f 100644 --- a/OvmfPkg/OvmfPkgIa32.dsc +++ b/OvmfPkg/OvmfPkgIa32.dsc @@ -361,7 +361,11 @@ [LibraryClasses.common.DXE_DRIVER] PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf MpInitLib|UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf QemuFwCfgS3Lib|OvmfPkg/Library/QemuFwCfgS3Lib/DxeQemuFwCfgS3LibFwCfg.inf +!if $(SECURE_BOOT_ENABLE) == TRUE + QemuLoadImageLib|OvmfPkg/Library/GenericQemuLoadImageLib/GenericQemuLoadImageLib.inf +!else QemuLoadImageLib|OvmfPkg/Library/X86QemuLoadImageLib/X86QemuLoadImageLib.inf +!endif !if $(TPM2_ENABLE) == TRUE Tpm2DeviceLib|SecurityPkg/Library/Tpm2DeviceLibTcg2/Tpm2DeviceLibTcg2.inf !endif diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc index 21d1f156973b..8bdf2e692b00 100644 --- a/OvmfPkg/OvmfPkgIa32X64.dsc +++ b/OvmfPkg/OvmfPkgIa32X64.dsc @@ -365,7 +365,11 @@ [LibraryClasses.common.DXE_DRIVER] PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf MpInitLib|UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf QemuFwCfgS3Lib|OvmfPkg/Library/QemuFwCfgS3Lib/DxeQemuFwCfgS3LibFwCfg.inf +!if $(SECURE_BOOT_ENABLE) == TRUE + QemuLoadImageLib|OvmfPkg/Library/GenericQemuLoadImageLib/GenericQemuLoadImageLib.inf +!else QemuLoadImageLib|OvmfPkg/Library/X86QemuLoadImageLib/X86QemuLoadImageLib.inf +!endif !if $(TPM2_ENABLE) == TRUE Tpm2DeviceLib|SecurityPkg/Library/Tpm2DeviceLibTcg2/Tpm2DeviceLibTcg2.inf !endif diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc index f3d0f18db7e2..bc0a3e438d2a 100644 --- a/OvmfPkg/OvmfPkgX64.dsc +++ b/OvmfPkg/OvmfPkgX64.dsc @@ -365,7 +365,11 @@ [LibraryClasses.common.DXE_DRIVER] PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf MpInitLib|UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf QemuFwCfgS3Lib|OvmfPkg/Library/QemuFwCfgS3Lib/DxeQemuFwCfgS3LibFwCfg.inf +!if $(SECURE_BOOT_ENABLE) == TRUE + QemuLoadImageLib|OvmfPkg/Library/GenericQemuLoadImageLib/GenericQemuLoadImageLib.inf +!else QemuLoadImageLib|OvmfPkg/Library/X86QemuLoadImageLib/X86QemuLoadImageLib.inf +!endif !if $(TPM2_ENABLE) == TRUE Tpm2DeviceLib|SecurityPkg/Library/Tpm2DeviceLibTcg2/Tpm2DeviceLibTcg2.inf !endif -- 2.17.1