From nobody Fri Apr 26 06:09:56 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+85574+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+85574+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1641937080; cv=none; d=zohomail.com; s=zohoarc; b=kTessD8I247WjG7PEcIwxeI7Z2PeNDknjJgb7n8ZWJGnsWGJq+1s1Cm0E7kDw2YYWf0TgbbZeCGvPk+7ZN2G3bFDNqVqFIgJ/aP9LmzYeeeVuz8JasOcKAyx8S3/fxiOMH03vKy/8J/04zFSU1+LUs/JAVi6WhdiwDO5kzvcVaw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641937080; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=qtu7MtIGcMpTvlhwLHcSKCT2S97m5sCPzTDqJVuD/NA=; b=Og4Lz/IzsWBM+4RiOnL1TN7rlzsdEXo2FZcyTh3PR6MWY8OFhcib8MVcENNTNIpuabxH+CHM4+RXw2QI1yHZ574+YeQF6l0e5aWuFOpFiiYueowTW7JqiiHvr/ZFtUr/C3c+jBHKJzigLFmK0dyJ5KRBL+bknowhJYbwa3drj+g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+85574+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1641937080666147.3106961831014; Tue, 11 Jan 2022 13:38:00 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id HjUWYY1788612xuu5GkN9lNX; Tue, 11 Jan 2022 13:38:00 -0800 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web12.14681.1641937079159543274 for ; Tue, 11 Jan 2022 13:37:59 -0800 X-Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 764AA1FB; Tue, 11 Jan 2022 13:37:58 -0800 (PST) X-Received: from localhost.localdomain (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 246E33F774; Tue, 11 Jan 2022 13:37:56 -0800 (PST) From: "Sunny Wang" To: devel@edk2.groups.io Cc: Sunny Wang , Liming Gao , Heinrich Schuchardt , G Edhaya Chandran , Samer El-Haj-Mahmoud , Sunny Wang Subject: [edk2-devel] [PATCH] MdeModulePkg/Variable: Make only EFI_VARIABLE_NON_VOLATILE invalid Date: Tue, 11 Jan 2022 21:37:20 +0000 Message-Id: <20220111213720.1358-1-Sunny.Wang@arm.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: 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,Sunny.Wang@arm.com X-Gm-Message-State: kKG6FwikxIVsHc7O5Ss8n207x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1641937080; bh=0rJHyKHlsyoLhf8TJkO1fbFIokr6tsZsseCT61zegtU=; h=Cc:Date:From:Reply-To:Subject:To; b=HrTZFmBhsfDr8Mw/NjQJ8fSagQNoU16PWfmYllHcOkBiGMlzcpE4BLDuneteuF84Lwm GYeQtqSvy/2SESbcsyEF1m2ILLR6fXIsGdbXdjxocdW0obIcRSCIK6Lu9MkuoMeHH5eqt HrJmQcIbXFu8UGoSsAYz2P6sk3BOkM4KUIU= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1641937085242100001 Content-Type: text/plain; charset="utf-8" Only EFI_VARIABLE_NON_VOLATILE attribute is an invalid combination of attribute bits, so update the variable driver to return EFI_INVALID_PARAMETER so that we can prevent the invalid variable being created. This change also fixes the SCT failure below: - RT.QueryVariableInfo - With being an invalid combination -- FAILURE For details, please check the threads below: - https://edk2.groups.io/g/devel/topic/86486174 - https://edk2.groups.io/g/devel/message/82466 Cc: Liming Gao Cc: Heinrich Schuchardt Cc: G Edhaya Chandran Cc: Samer El-Haj-Mahmoud Signed-off-by: Sunny Wang Reviewed-by: Liming Gao --- .../Universal/Variable/RuntimeDxe/Variable.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c b/MdeMod= ulePkg/Universal/Variable/RuntimeDxe/Variable.c index 9722a94420..6c1a3440ac 100644 --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c @@ -19,6 +19,7 @@ Copyright (c) 2006 - 2020, Intel Corporation. All rights reserved.
(C) Copyright 2015-2018 Hewlett Packard Enterprise Development LP
Copyright (c) Microsoft Corporation.
+Copyright (c) 2022, ARM Limited. All rights reserved.
=20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -2660,14 +2661,22 @@ VariableServiceSetVariable ( } =20 // - // Make sure if runtime bit is set, boot service bit is set also. + // Check if the combination of attribute bits is valid. // if ((Attributes & (EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVIC= E_ACCESS)) =3D=3D EFI_VARIABLE_RUNTIME_ACCESS) { + // + // Make sure if runtime bit is set, boot service bit is set also. + // if ((Attributes & EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS) !=3D 0) { return EFI_UNSUPPORTED; } else { return EFI_INVALID_PARAMETER; } + } else if ((Attributes & EFI_VARIABLE_ATTRIBUTES_MASK) =3D=3D EFI_VARIAB= LE_NON_VOLATILE) { + // + // Only EFI_VARIABLE_NON_VOLATILE attribute is invalid + // + return EFI_INVALID_PARAMETER; } else if ((Attributes & VARIABLE_ATTRIBUTE_AT_AW) !=3D 0) { if (!mVariableModuleGlobal->VariableGlobal.AuthSupport) { // @@ -3142,6 +3151,11 @@ VariableServiceQueryVariableInfo ( // Make sure the Attributes combination is supported by the platform. // return EFI_UNSUPPORTED; + } else if ((Attributes & EFI_VARIABLE_ATTRIBUTES_MASK) =3D=3D EFI_VARIAB= LE_NON_VOLATILE) { + // + // Only EFI_VARIABLE_NON_VOLATILE attribute is invalid + // + return EFI_INVALID_PARAMETER; } else if ((Attributes & (EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOO= TSERVICE_ACCESS)) =3D=3D EFI_VARIABLE_RUNTIME_ACCESS) { // // Make sure if runtime bit is set, boot service bit is set also. --=20 2.33.0.windows.2 -=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 (#85574): https://edk2.groups.io/g/devel/message/85574 Mute This Topic: https://groups.io/mt/88359863/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-