From nobody Mon Feb 9 08:34:11 2026 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+61597+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+61597+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1592911147; cv=none; d=zohomail.com; s=zohoarc; b=FK8JZ5Vtcc5nq4MCYINK71ugQk8j/eAMx3ISw+SvglIgpzf6st34e+YlrKBr0sroZYJ91Tu0JV6zD318OCCQhLgaAFANGmiEYnDGmFQq1seCbi+Ain/jnWQQOTJxuY6GaCN5oLEWfu8IEYm7CHGtZNWcu/dd3BNd8OC33KDDLlI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592911147; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=OS0gZHh0x+Ts+2o0aMs5MB9Q2FytbHZ/i/CCSpSigZk=; b=Plyb4WWD29DtjUQePL+rAUylQ/258wZJZSH5SkPwGZnclUBJnrUt82ePJtqOsBSKEZNmCGJO0AUjeg8gXUHj6hhj9886WdJMb6kuWY721BSusS34agEnqzsTKeDceHCNB9A/1nKayklLD/3yqyOyEVp2ZogXkH6U96cIez7lgKM= 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+61597+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1592911147565307.8735827586921; Tue, 23 Jun 2020 04:19:07 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id Dv3fYY1788612xWKyhfpsE9j; Tue, 23 Jun 2020 04:19:07 -0700 X-Received: from mail-pl1-f196.google.com (mail-pl1-f196.google.com [209.85.214.196]) by mx.groups.io with SMTP id smtpd.web12.1799.1592894705234590671 for ; Mon, 22 Jun 2020 23:45:05 -0700 X-Received: by mail-pl1-f196.google.com with SMTP id 35so8723829ple.0 for ; Mon, 22 Jun 2020 23:45:05 -0700 (PDT) X-Gm-Message-State: ssGugK3wdHqdJ7uhbeDlUnppx1787277AA= X-Google-Smtp-Source: ABdhPJyhFTL0Q07FBdN4/9FLksVJWbPb6m8eWUzs27T6cvpU4muaAOGooeNs6xSO7Fqv7nQjZ89cfA== X-Received: by 2002:a17:902:201:: with SMTP id 1mr23184018plc.195.1592894704608; Mon, 22 Jun 2020 23:45:04 -0700 (PDT) X-Received: from localhost.localdomain (174-21-80-75.tukw.qwest.net. [174.21.80.75]) by smtp.gmail.com with ESMTPSA id d6sm1383818pjh.5.2020.06.22.23.45.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jun 2020 23:45:04 -0700 (PDT) From: "Bret Barkelew" X-Google-Original-From: Bret Barkelew To: devel@edk2.groups.io Cc: Jiewen Yao , Jian J Wang , Chao Zhang Subject: [edk2-devel] [PATCH v6 11/14] SecurityPkg: Allow VariablePolicy state to delete authenticated variables Date: Mon, 22 Jun 2020 23:41:01 -0700 Message-Id: <20200623064104.1908-12-brbarkel@microsoft.com> In-Reply-To: <20200623064104.1908-1-brbarkel@microsoft.com> References: <20200623064104.1908-1-brbarkel@microsoft.com> MIME-Version: 1.0 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,bret@corthon.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1592911147; bh=MaJ3R7FCOjhR55rhFDeqYeNa1Fhyx9Imo8fZ+qEY6Do=; h=Cc:Date:From:Reply-To:Subject:To; b=oWWXaWoXEjQczoNBBL/zEyTe7Bc1Z1tfuYftivSBIWfn+GcY4ZgwNmJ71/SNu2WNJ2T 6xjotm4OSjqRQVI+fvE1ozScRA96/VSCtgZDKcg6R8sfR9lYYqFakRFdO2ZzrUEpwYZi7 4gEXDMjxvWsxxCFA83jpTUwBbbiOgi21lps= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" https://bugzilla.tianocore.org/show_bug.cgi?id=3D2522 Causes AuthService to check IsVariablePolicyEnabled() before enforcing write protections to allow variable deletion when policy engine is disabled. Only allows deletion, not modification. Cc: Jiewen Yao Cc: Jian J Wang Cc: Chao Zhang Cc: Bret Barkelew Signed-off-by: Bret Barkelew --- SecurityPkg/Library/AuthVariableLib/AuthService.c | 22 +++++++++++++= +++---- SecurityPkg/Library/AuthVariableLib/AuthVariableLib.inf | 2 ++ 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/SecurityPkg/Library/AuthVariableLib/AuthService.c b/SecurityPk= g/Library/AuthVariableLib/AuthService.c index 2f60331f2c04..aca9a5620c28 100644 --- a/SecurityPkg/Library/AuthVariableLib/AuthService.c +++ b/SecurityPkg/Library/AuthVariableLib/AuthService.c @@ -19,12 +19,16 @@ to verify the signature. =20 Copyright (c) 2009 - 2019, Intel Corporation. All rights reserved.
+Copyright (c) Microsoft Corporation. SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ =20 #include "AuthServiceInternal.h" =20 +#include +#include + // // Public Exponent of RSA Key. // @@ -217,9 +221,12 @@ NeedPhysicallyPresent( IN EFI_GUID *VendorGuid ) { - if ((CompareGuid (VendorGuid, &gEfiSecureBootEnableDisableGuid) && (StrC= mp (VariableName, EFI_SECURE_BOOT_ENABLE_NAME) =3D=3D 0)) - || (CompareGuid (VendorGuid, &gEfiCustomModeEnableGuid) && (StrCmp (Va= riableName, EFI_CUSTOM_MODE_NAME) =3D=3D 0))) { - return TRUE; + // If the VariablePolicy engine is disabled, allow deletion of any authe= nticated variables. + if (IsVariablePolicyEnabled()) { + if ((CompareGuid (VendorGuid, &gEfiSecureBootEnableDisableGuid) && (St= rCmp (VariableName, EFI_SECURE_BOOT_ENABLE_NAME) =3D=3D 0)) + || (CompareGuid (VendorGuid, &gEfiCustomModeEnableGuid) && (StrCmp (= VariableName, EFI_CUSTOM_MODE_NAME) =3D=3D 0))) { + return TRUE; + } } =20 return FALSE; @@ -842,7 +849,8 @@ ProcessVariable ( &OrgVariableInfo ); =20 - if ((!EFI_ERROR (Status)) && IsDeleteAuthVariable (OrgVariableInfo.Attri= butes, Data, DataSize, Attributes) && UserPhysicalPresent()) { + // If the VariablePolicy engine is disabled, allow deletion of any authe= nticated variables. + if ((!EFI_ERROR (Status)) && IsDeleteAuthVariable (OrgVariableInfo.Attri= butes, Data, DataSize, Attributes) && (UserPhysicalPresent() || !IsVariable= PolicyEnabled())) { // // Allow the delete operation of common authenticated variable(AT or A= W) at user physical presence. // @@ -1960,6 +1968,12 @@ VerifyTimeBasedPayload ( =20 CopyMem (Buffer, PayloadPtr, PayloadSize); =20 + // If the VariablePolicy engine is disabled, allow deletion of any authe= nticated variables. + if (PayloadSize =3D=3D 0 && (Attributes & EFI_VARIABLE_APPEND_WRITE) =3D= =3D 0 && !IsVariablePolicyEnabled()) { + VerifyStatus =3D TRUE; + goto Exit; + } + if (AuthVarType =3D=3D AuthVarTypePk) { // // Verify that the signature has been made with the current Platform K= ey (no chaining for PK). diff --git a/SecurityPkg/Library/AuthVariableLib/AuthVariableLib.inf b/Secu= rityPkg/Library/AuthVariableLib/AuthVariableLib.inf index 8d4ce14df494..8eadeebcebd7 100644 --- a/SecurityPkg/Library/AuthVariableLib/AuthVariableLib.inf +++ b/SecurityPkg/Library/AuthVariableLib/AuthVariableLib.inf @@ -3,6 +3,7 @@ # # Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
# Copyright (c) 2018, ARM Limited. All rights reserved.
+# Copyright (c) Microsoft Corporation. # # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -41,6 +42,7 @@ [LibraryClasses] MemoryAllocationLib BaseCryptLib PlatformSecureLib + VariablePolicyLib =20 [Guids] ## CONSUMES ## Variable:L"SetupMode" --=20 2.26.2.windows.1.8.g01c50adf56.20200515075929 -=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 (#61597): https://edk2.groups.io/g/devel/message/61597 Mute This Topic: https://groups.io/mt/75057707/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-