From nobody Tue Feb 10 05:41:12 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=trmm.net ARC-Seal: i=1; a=rsa-sha256; t=1600357313; cv=none; d=zohomail.com; s=zohoarc; b=cdec93EEo+TsnJDCWuENwI829Cxw7YNJnKYwYzzmc/w4J8OESpOIoYVc5jHt2Vsx0hmf7W0kPvJIOa7m5/GGtA3LHmwCVkt2ILtzNnIlNZks0lUjC6KfN/uHid7WH3mPRnOPAhSiFeioLkNcUoUNyfx3YKDKGIj4GSqYuGU2/Cs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600357313; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=IdcZXqlHs5+EZNM22o6e1rKnN9WlSfpq/mEMv5WGsAU=; b=Og5JQMHqGiq915rUFuw6JB3QYAyhXSjJbqZbRIHKgxlpbbI8FfcFy2EyuFLUi4xdPiHeY6yLKLBSeI2Y61UuPdS1ZO14FiT5ytDp7tKrS0ESPIGA2BU6Lt1E7o1nS5mKfgSvJFplkX4S9iwUlQcVl43Ru3Dl0pqFgDj+dH5YACo= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1600357313152443.932205641009; Thu, 17 Sep 2020 08:41:53 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kIw2T-0003ZK-GC; Thu, 17 Sep 2020 15:41:37 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kIw2S-0003Z7-Jm for xen-devel@lists.xenproject.org; Thu, 17 Sep 2020 15:41:36 +0000 Received: from mx1a.swcp.com (unknown [216.184.2.64]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id cbbd5b5b-d89d-431b-9d2b-edb4508d8af6; Thu, 17 Sep 2020 15:41:35 +0000 (UTC) Received: from ame7.swcp.com (ame7.swcp.com [216.184.2.70]) by mx1a.swcp.com (8.14.4/8.14.4/Debian-4) with ESMTP id 08HFfYjE024992 for ; Thu, 17 Sep 2020 09:41:34 -0600 Received: from diamond.fritz.box (62-251-112-184.ip.xs4all.nl [62.251.112.184]) by ame7.swcp.com (8.15.2/8.15.2) with ESMTP id 08HFesRQ024558 for ; Thu, 17 Sep 2020 09:41:28 -0600 (MDT) (envelope-from hudson@trmm.net) X-Inumbo-ID: cbbd5b5b-d89d-431b-9d2b-edb4508d8af6 Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: neutral (ame7.swcp.com: 62.251.112.184 is neither permitted nor denied by domain of hudson@trmm.net) receiver=ame7.swcp.com; client-ip=62.251.112.184; helo=diamond.fritz.box; envelope-from=hudson@trmm.net; x-software=spfmilter 2.001 http://www.acme.com/software/spfmilter/ with libspf2-1.2.10; X-Authentication-Warning: ame7.swcp.com: Host 62-251-112-184.ip.xs4all.nl [62.251.112.184] claimed to be diamond.fritz.box From: Trammell Hudson To: xen-devel@lists.xenproject.org Subject: [PATCH v5 5/5] efi: Do not use command line if unified config is included Date: Thu, 17 Sep 2020 11:40:48 -0400 Message-Id: <20200917154048.1140580-6-hudson@trmm.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200917154048.1140580-1-hudson@trmm.net> References: <20200917154048.1140580-1-hudson@trmm.net> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.83 X-Greylist: Message whitelisted by DRAC access database, not delayed by milter-greylist-4.6.2 (ame7.swcp.com [216.184.2.128]); Thu, 17 Sep 2020 09:41:29 -0600 (MDT) X-Virus-Scanned: clamav-milter 0.100.2 at ame7 X-Virus-Status: Clean X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on ame7.swcp.com X-Spam-Status: No, hits=0.7 tests=NO_RECEIVED,NO_RELAYS,SPF_NEUTRAL version=3.4.2 X-Spam-Level: X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Content-Type: text/plain; charset="utf-8" If a unified Xen image is used, then the bundled configuration, Xen command line, dom0 kernel, and ramdisk are prefered over any files listed in the config file or provided on the command line. Unlike the shim based verification, the PE signature on a unified image covers all of the Xen+config+kernel+initrd modules linked into the unified image. This also ensures that, on properly configured UEFI Secure B= oot platforms, the entire runtime will be measured into the TPM for unsealing secrets or remote attestation. Signed-off-by: Trammell Hudson --- xen/common/efi/boot.c | 43 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 38 insertions(+), 5 deletions(-) diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c index c14e836640..6dc3f5ac94 100644 --- a/xen/common/efi/boot.c +++ b/xen/common/efi/boot.c @@ -952,6 +952,35 @@ static void __init setup_efi_pci(void) efi_bs->FreePool(handles); } =20 +/* + * Logic should remain sync'ed with linux/arch/x86/xen/efi.c + * Secure Boot is enabled iff 'SecureBoot' is set and the system is + * not in Setup Mode. + */ +static bool __init efi_secure_boot(void) +{ + static __initdata EFI_GUID global_guid =3D EFI_GLOBAL_VARIABLE; + uint8_t secboot, setupmode; + UINTN secboot_size =3D sizeof(secboot); + UINTN setupmode_size =3D sizeof(setupmode); + EFI_STATUS rc; + + rc =3D efi_rs->GetVariable(L"SecureBoot", &global_guid, + NULL, &secboot_size, &secboot); + if ( rc !=3D EFI_SUCCESS ) + return false; + + rc =3D efi_rs->GetVariable(L"SetupMode", &global_guid, + NULL, &setupmode_size, &setupmode); + if ( rc !=3D EFI_SUCCESS ) + return false; + + if ( secboot > 1 || setupmode > 1 ) + blexit(L"Invalid SecureBoot/SetupMode variables"); + + return secboot =3D=3D 1 && setupmode =3D=3D 0; +} + static void __init efi_variables(void) { EFI_STATUS status; @@ -1128,15 +1157,15 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE = *SystemTable) static EFI_GUID __initdata shim_lock_guid =3D SHIM_LOCK_PROTOCOL_GUID; EFI_LOADED_IMAGE *loaded_image; EFI_STATUS status; - unsigned int i, argc; - CHAR16 **argv, *file_name, *cfg_file_name =3D NULL, *options =3D NULL; + unsigned int i, argc =3D 0; + CHAR16 **argv =3D NULL, *file_name, *cfg_file_name =3D NULL, *options = =3D NULL; UINTN gop_mode =3D ~0; EFI_SHIM_LOCK_PROTOCOL *shim_lock; EFI_GRAPHICS_OUTPUT_PROTOCOL *gop =3D NULL; union string section =3D { NULL }, name; bool base_video =3D false; const char *option_str; - bool use_cfg_file; + bool use_cfg_file, secure; =20 __set_bit(EFI_BOOT, &efi_flags); __set_bit(EFI_LOADER, &efi_flags); @@ -1155,8 +1184,10 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *= SystemTable) PrintErrMesg(L"No Loaded Image Protocol", status); =20 efi_arch_load_addr_check(loaded_image); + secure =3D efi_secure_boot(); =20 - if ( use_cfg_file ) + if ( use_cfg_file && + !read_section(loaded_image, ".config", &cfg, NULL)) { UINTN offset =3D 0; =20 @@ -1214,6 +1245,8 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *S= ystemTable) =20 PrintStr(L"Xen " __stringify(XEN_VERSION) "." __stringify(XEN_SUBVERSI= ON) XEN_EXTRAVERSION " (c/s " XEN_CHANGESET ") EFI loader\r\n"); + if ( secure ) + PrintStr(L"UEFI Secure Boot enabled\r\n"); =20 efi_arch_relocate_image(0); =20 @@ -1233,7 +1266,7 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *S= ystemTable) /* Get the file system interface. */ dir_handle =3D get_parent_handle(loaded_image, &file_name); =20 - if ( read_section(loaded_image, ".config", &cfg, NULL) ) + if ( cfg.ptr ) PrintStr(L"Using unified config file\r\n"); else if ( !cfg_file_name ) { --=20 2.25.1