From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (NAM10-DM6-obe.outbound.protection.outlook.com [40.92.41.71]) by mx.groups.io with SMTP id smtpd.web12.1209.1589266042194460562 for ; Mon, 11 May 2020 23:47:22 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@outlook.com header.s=selector1 header.b=mNcJb+GC; spf=pass (domain: outlook.com, ip: 40.92.41.71, mailfrom: michael.kubacki@outlook.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Oioqk2WkrQOU3tascjYFGelvGTDl0m2LXF+mSdjpSZQYnSHXtmQ2RhKibya2ogCuXlJk6D5PiBYij8XQAYriafqYZuwqUbyaA1whGX7qOmF7zr06QU3PS/ehXb+CTrz7SG/Sqz52fhcI7AIrQDC9meMo1oQkIN9sxvhoVA35Bj3mcJphK05aQrq48TL4Vr4FK+YVocSehAa94yzHkzlynZhF3UQVD/ZhbDDjsP+FJy5Dg3IWzFTbeZtRkdZBTSbdk0LUqovpcee9IvZNvDaNYudEI5JPDqoYQWG5MhSK+NlFF2BRyfEAee0GJz3YmTNwt9zKuPf3IYtcufb3QoVHuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=I/Q4FL1E/xW8QF3HyYgbRgnGGYk3umSwHi1eqjASMeM=; b=E2RcueXQlK8kf24sScYCTtcdAWTCLb/QbIF3XjIqdXRaUmxkRD1x8w5tfnChS/Xric7saHFx1ReGxwcOhfOYrtVHR+zcgg3Q+F2DKxVqh+V/vuRug6h2B3X6vc+e4pQvuU4lMO6ezY2Fk1Cjbd77J9Er/fimZhoXlC8c3LIvdAmWACENqSd7i1/3dW5M0gxfK6pNXinaUb6CbS+axfMTEkzUPfmesHm9okdQLOWCBIi9gh1Jossz//GHt9wCHTZ+5TgEb72rPGDsBCjHFNevnZDqRiAmn3JIG/c1GrBT34mlFfsT3fDsBJtY19lE4hBghg+fLP/oaMqY9QO8JYexhQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=outlook.com; dmarc=pass action=none header.from=outlook.com; dkim=pass header.d=outlook.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=I/Q4FL1E/xW8QF3HyYgbRgnGGYk3umSwHi1eqjASMeM=; b=mNcJb+GCjCM6y7XueBEecCoCpIvAawaNOhN5XVhoQwRHIOq2u4qKyVmYLKhtuq/NVSgMb1Wxphklm5sBLZyWrzlfUjlTAvCxXNRrxGskuSdqnFWULvEa1M82mIp7dFhbcMZ01bPitZk9twSWkh+ln9tKZSGwFRHwHc57r2WM5PD/+TU9RdBNC2CmD2CAksloZxAixLoEWsybn3HZLaYvMjSvaJETgh6vvJo3nZSKUNhRQwoJ5euiEqYq91FMQaCJpO+VlJy6259QK+J9nuOTqsuv8dd7qCj3rhbMSEbNgIZvOK+o9zSio+1W8nOBLjGE94zbEGzgrXcLWfDvNIbRXQ== Received: from BN7NAM10FT010.eop-nam10.prod.protection.outlook.com (2a01:111:e400:7e8f::47) by BN7NAM10HT235.eop-nam10.prod.protection.outlook.com (2a01:111:e400:7e8f::341) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2979.27; Tue, 12 May 2020 06:47:21 +0000 Received: from MWHPR07MB3440.namprd07.prod.outlook.com (2a01:111:e400:7e8f::4b) by BN7NAM10FT010.mail.protection.outlook.com (2a01:111:e400:7e8f::421) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2979.27 via Frontend Transport; Tue, 12 May 2020 06:47:21 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:2E9BCBC88198437095D3ECAD4C22563A7983A19A534819B14D85916ABA5B2DE7;UpperCasedChecksum:B3FAD1C63BBCB712C0FEF959ED0458AA15E64DD10057C239C10ED0BC94C728B9;SizeAsReceived:7772;Count:49 Received: from MWHPR07MB3440.namprd07.prod.outlook.com ([fe80::bcc9:271b:20db:52e3]) by MWHPR07MB3440.namprd07.prod.outlook.com ([fe80::bcc9:271b:20db:52e3%6]) with mapi id 15.20.2979.033; Tue, 12 May 2020 06:47:21 +0000 From: "Michael Kubacki" To: devel@edk2.groups.io Cc: Jian J Wang , Hao A Wu , Liming Gao Subject: [PATCH v2 06/12] MdeModulePkg: Allow VariablePolicy state to delete protected variables Date: Mon, 11 May 2020 23:46:29 -0700 Message-ID: X-Mailer: git-send-email 2.16.3.windows.1 In-Reply-To: <20200512064635.14640-1-michael.kubacki@outlook.com> References: <20200512064635.14640-1-michael.kubacki@outlook.com> X-ClientProxiedBy: MW2PR16CA0022.namprd16.prod.outlook.com (2603:10b6:907::35) To MWHPR07MB3440.namprd07.prod.outlook.com (2603:10b6:301:69::28) Return-Path: michael.kubacki@outlook.com X-Microsoft-Original-Message-ID: <20200512064635.14640-7-michael.kubacki@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (2001:4898:80e8:b:422:2743:5e95:81bb) by MW2PR16CA0022.namprd16.prod.outlook.com (2603:10b6:907::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2979.27 via Frontend Transport; Tue, 12 May 2020 06:47:20 +0000 X-Mailer: git-send-email 2.16.3.windows.1 X-Microsoft-Original-Message-ID: <20200512064635.14640-7-michael.kubacki@outlook.com> X-TMN: [bT++EAsRbKCvFxTKuANzu9etkbZxIhrmim4Rl65VqaKIQqiBy8I2THkyLbm0IWHT] X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 49 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 4435d1a2-0e18-4804-8640-08d7f64051da X-MS-TrafficTypeDiagnostic: BN7NAM10HT235: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: V7vVA36gZVQMUtFMX/J4FkbFOW658VAT9xVw2HrD1R5Qdton0/kebP5xQwMUMsgiV+28OiOFmCFigou9HxwrrN9b3NXjCzF4GMxHtJMHaWzSFmB7lg7/SGeANMq0vndEIy6wl6y+uXpfXORdbwYTQeOvlhWiLorIS30PMeAKmwjlLw0HWyoVGQt7w04sxVQjXACmsPN4i6SnRLMhNXGT2QLbVJepmPHo7Aeg+WkSs5r/roOqW8n3t6fpLjegbYer X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:0;SRV:;IPV:NLI;SFV:NSPM;H:MWHPR07MB3440.namprd07.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:;DIR:OUT;SFP:1901; X-MS-Exchange-AntiSpam-MessageData: kSv1u7mNfMcWN8y8Y6sg4tMugORTkfvddgabI+OGd0L4tstFtYQM/B/qgrUoWvTBIlxWnQUEw79SVmj/dmEI+0LgaA7epjfw6+gVmG1nEtnxdDXcxrd4GUpX5xIEam9SCr8xwaS4PpXdo/Gk6Z6cNJ8KcUO08pR1CuXQNrDl3A7mp7ddfqkFQMUk+X8hP4htgVuIyS4+7CIdlxkFZo526g== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4435d1a2-0e18-4804-8640-08d7f64051da X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 May 2020 06:47:20.9479 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN7NAM10HT235 Content-Type: text/plain From: Bret Barkelew https://bugzilla.tianocore.org/show_bug.cgi?id=2522 TcgMorLockSmm provides special protections for the TCG MOR variables. This will check IsVariablePolicyEnabled() before enforcing them to allow variable deletion when policy engine is disabled. Only allows deletion, not modification. Cc: Jian J Wang Cc: Hao A Wu Cc: Liming Gao Signed-off-by: Michael Kubacki --- MdeModulePkg/Universal/Variable/RuntimeDxe/TcgMorLockSmm.c | 10 ++++++++++ MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.inf | 2 ++ 2 files changed, 12 insertions(+) diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/TcgMorLockSmm.c b/MdeModulePkg/Universal/Variable/RuntimeDxe/TcgMorLockSmm.c index 6d80eb64341a..085f82035f4b 100644 --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/TcgMorLockSmm.c +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/TcgMorLockSmm.c @@ -5,6 +5,7 @@ This module adds Variable Hook and check MemoryOverwriteRequestControlLock. Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.
+Copyright (c) Microsoft Corporation. SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -17,6 +18,10 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include #include "Variable.h" +#include + +#include + typedef struct { CHAR16 *VariableName; EFI_GUID *VendorGuid; @@ -341,6 +346,11 @@ SetVariableCheckHandlerMor ( return EFI_SUCCESS; } + // Permit deletion when policy is disabled. + if (!IsVariablePolicyEnabled() && ((Attributes == 0) || (DataSize == 0))) { + return EFI_SUCCESS; + } + // // MorLock variable // diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.inf b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.inf index 6e17f6cdf588..d8f480be27cc 100644 --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.inf +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.inf @@ -20,6 +20,7 @@ # # Copyright (c) 2010 - 2019, Intel Corporation. All rights reserved.
# Copyright (c) 2018, Linaro, Ltd. All rights reserved.
+# Copyright (c) Microsoft Corporation. # SPDX-License-Identifier: BSD-2-Clause-Patent # ## @@ -74,6 +75,7 @@ StandaloneMmDriverEntryPoint SynchronizationLib VarCheckLib + VariablePolicyLib [Protocols] gEfiSmmFirmwareVolumeBlockProtocolGuid ## CONSUMES -- 2.16.3.windows.1