From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f66.google.com (mail-wm1-f66.google.com [209.85.128.66]) by mx.groups.io with SMTP id smtpd.web10.9185.1583315580404892312 for ; Wed, 04 Mar 2020 01:53:00 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@linaro.org header.s=google header.b=Mk/17w6k; spf=pass (domain: linaro.org, ip: 209.85.128.66, mailfrom: ard.biesheuvel@linaro.org) Received: by mail-wm1-f66.google.com with SMTP id u9so1164465wml.3 for ; Wed, 04 Mar 2020 01:53:00 -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=/jpT5H+agNeYp/p9mJvangNdyUc352kDWPatqD3YYvE=; b=Mk/17w6kOQfEnXojGvE7XnAl7YxnwrQmC4ZRUGs+w0EdwGjs0PiazJ9XnZ6xUBs0GI w9OW3/K5u4EQplpLBynM/xqcjNTQ11xBwD7Jqe1L5NxTLbb0BdGnjDAynJ+caDt7ndSQ S0O+N5klJnmZURbk3BPJkMnvv/H/5GWtmzyWU1XzL8zNwmNivM0cRyYETvefSmq/MDOE b2xU6XGl7zVYAk2hWG6mg+vux6Omwvaukj+AhrkiK1Akwko2k57byWJ/qrE10hlAfto1 rKDfPC7CSDqR7FlPimyNUZ/7nvrhf9RNoadvVya7Vzx2GStZyuzFXEZzj3AbDgszVG9R HCuw== 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=/jpT5H+agNeYp/p9mJvangNdyUc352kDWPatqD3YYvE=; b=nNxHUnnlESZ0OQXJimLEhYr/yV1XPzoWfT/jYkPMr9NFlynE4FDgAVe5TU52SvWkXk dU/A4taEO4EWy38wzJBVH3LfoiCLnkGYo+JBVAiz3SNeGrP7z7eP9FjkSXA1FK7iGdwv 1vJjd34cgIz8aWricrZTK2IllfUHIPVkk6Y1680x9UR6mxk6WuGsUIkJeV5O41v3yIz1 VLVYrZ34o9IkwtHgNh4bgAWZJ8ijA/66F1vJFcR5nw2ZRsWR1LFOXW/T3gwAJZgQFNj2 lPyFaNpLNlRcrPaGL3xg1fUHN6w1TpxSgkH43ugRpwPLh/9HGaxHPLRAGJIzE3QWh0jb 1XAA== X-Gm-Message-State: ANhLgQ1lAaeB/FRsSNhSDURh8OxbSkDtdUwJk81cvMZ1XObMxtuo6Nsx KIbjuA2tp/yr4LZYsSP24DmKgA6GUM+8tA== X-Google-Smtp-Source: ADFU+vtUMrTQ0t69JAm271tNLYN4JW/5MHmMXot431xlTlw76cPGx+OmWowkBrtcPvejJmbf9wAZnw== X-Received: by 2002:a1c:c2c5:: with SMTP id s188mr2799025wmf.162.1583315578749; Wed, 04 Mar 2020 01:52:58 -0800 (PST) Return-Path: Received: from e123331-lin.home ([2a01:cb1d:112:6f00:816e:ff0d:fb69:f613]) by smtp.gmail.com with ESMTPSA id v16sm20781095wrp.84.2020.03.04.01.52.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Mar 2020 01:52:57 -0800 (PST) From: "Ard Biesheuvel" To: devel@edk2.groups.io Cc: lersek@redhat.com, Ard Biesheuvel Subject: [PATCH v2 14/14] OvmfPkg: use generic QEMU image loader for secure boot enabled builds Date: Wed, 4 Mar 2020 10:52:33 +0100 Message-Id: <20200304095233.21046-15-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200304095233.21046-1-ard.biesheuvel@linaro.org> References: <20200304095233.21046-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 Reviewed-by: Laszlo Ersek --- 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