From nobody Mon Apr 29 03:50:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+60825+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+60825+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1591401184; cv=none; d=zohomail.com; s=zohoarc; b=hlf6gs6yUFykz+Kpq8dXM06a8+ubS7F5afDKjulnL76I/+vxs5SNlM2zaYQzL8aEt5YSPpCx15x43uAepX36FoPV8FcxBxX/WKwyWRWEUSuJpPzfv+9Fh6lc0dd0IedvfnD4bQwodOTprmaGZWMYUOqzX2NCMLTrulyrJ6vQmL8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591401184; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=lJow1t2Er7lN8Kmdp0EHM42HoUOERCWWHmfZpNkpkZY=; b=TRdYQ0PzA2YyAZlUQbi/3U9Fmi0nlfzd1dpJDIamkqT9e0x6BtX0fZjSHtuWnB4TyN3IaXmyAwwc8Qs6pgCS0tYl4gEn0fH4CU8mI30FBc5IBgD3TpDlcdp0HztlPgr1vaWmHl+KHGmpuWt6YTV7liSRLLjmThSzt6KGc7VXC2s= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+60825+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1591401184075354.87536573004604; Fri, 5 Jun 2020 16:53:04 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id ZtskYY1788612xA5HJYoCZ8W; Fri, 05 Jun 2020 16:53:03 -0700 X-Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.120]) by mx.groups.io with SMTP id smtpd.web12.885.1591401180704208375 for ; Fri, 05 Jun 2020 16:53:01 -0700 X-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-68-y6wvhmhyM_aKBvQjKJTDYg-1; Fri, 05 Jun 2020 19:52:46 -0400 X-MC-Unique: y6wvhmhyM_aKBvQjKJTDYg-1 X-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 3965F1005510; Fri, 5 Jun 2020 23:52:45 +0000 (UTC) X-Received: from lacos-laptop-7.usersys.redhat.com (ovpn-112-250.ams2.redhat.com [10.36.112.250]) by smtp.corp.redhat.com (Postfix) with ESMTP id E76727A8CD; Fri, 5 Jun 2020 23:52:43 +0000 (UTC) From: "Laszlo Ersek" To: edk2-devel-groups-io Cc: Ard Biesheuvel , Jordan Justen , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [edk2-devel] [PATCH] OvmfPkg/X86QemuLoadImageLib: handle EFI_ACCESS_DENIED from LoadImage() Date: Sat, 6 Jun 2020 01:52:42 +0200 Message-Id: <20200605235242.32442-1-lersek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,lersek@redhat.com X-Gm-Message-State: xxMGiIStBSp96qX3wc0NgG5xx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1591401183; bh=lJow1t2Er7lN8Kmdp0EHM42HoUOERCWWHmfZpNkpkZY=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=X7NdoGR9qZap8AWxakXbF2VcpEpcgXLP2zHbuiEIQIS3Dn2iCKbqN3VWqkngB0OB9eq VwKXOE99Ck7W5112TdlZda24Oxl+a+E4riTmZn57xd8LbnCTffP0ZSahqcNj/qsSrTerV 9rvz5XlgFCj3aSjWYzLhYRdd0fNlPoVP8us= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" When an image fails Secure Boot validation, LoadImage() returns EFI_SECURITY_VIOLATION if the platform policy is DEFER_EXECUTE_ON_SECURITY_VIOLATION. If the platform policy is DENY_EXECUTE_ON_SECURITY_VIOLATION, then LoadImage() returns EFI_ACCESS_DENIED (and the image does not remain loaded). (Before , this difference would be masked, as DxeImageVerificationLib would incorrectly return EFI_SECURITY_VIOLATION for DENY_EXECUTE_ON_SECURITY_VIOLATION as well.) In X86QemuLoadImageLib, proceed to the legacy Linux/x86 Boot Protocol upon seeing EFI_ACCESS_DENIED too. Cc: Ard Biesheuvel Cc: Jordan Justen Cc: Philippe Mathieu-Daud=C3=A9 Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2785 Signed-off-by: Laszlo Ersek Reviewed-by: Ard Biesheuvel Reviewed-by: Philippe Mathieu-Daude --- Notes: Repo: https://pagure.io/lersek/edk2.git Branch: x86_qlil_access_denied OvmfPkg/Library/X86QemuLoadImageLib/X86QemuLoadImageLib.c | 14 ++++++++++-= --- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/OvmfPkg/Library/X86QemuLoadImageLib/X86QemuLoadImageLib.c b/Ov= mfPkg/Library/X86QemuLoadImageLib/X86QemuLoadImageLib.c index ef753be7ea90..931553c0c1fb 100644 --- a/OvmfPkg/Library/X86QemuLoadImageLib/X86QemuLoadImageLib.c +++ b/OvmfPkg/Library/X86QemuLoadImageLib/X86QemuLoadImageLib.c @@ -319,13 +319,19 @@ QemuLoadKernelImage ( return EFI_NOT_FOUND; =20 case EFI_SECURITY_VIOLATION: + // + // Since the image has been loaded, we need to unload it before procee= ding + // to the EFI_ACCESS_DENIED case below. + // + gBS->UnloadImage (KernelImageHandle); + // + // Fall through + // + case EFI_ACCESS_DENIED: // // We are running with UEFI secure boot enabled, and the image failed = to // authenticate. For compatibility reasons, we fall back to the legacy - // loader in this case. Since the image has been loaded, we need to un= load - // it before proceeding - // - gBS->UnloadImage (KernelImageHandle); + // loader in this case. // // Fall through // --=20 2.19.1.3.g30247aa5d201 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#60825): https://edk2.groups.io/g/devel/message/60825 Mute This Topic: https://groups.io/mt/74705045/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-