Reviewed-by: Liming Gao <gaolim...@byosoft.com.cn>

> -----邮件原件-----
> 发件人: devel@edk2.groups.io <devel@edk2.groups.io> 代表 Kun Qin
> 发送时间: 2021年12月21日 9:33
> 收件人: devel@edk2.groups.io
> 抄送: Jian J Wang <jian.j.w...@intel.com>; Liming Gao
> <gaolim...@byosoft.com.cn>; Hao A Wu <hao.a...@intel.com>; Bret
> Barkelew <bret.barke...@microsoft.com>; Michael Kubacki
> <michael.kuba...@microsoft.com>
> 主题: [edk2-devel] [PATCH v2 1/6] MdeModulePkg: VariableSmmRuntimeDxe:
> Fix Variable Policy Message Length
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3709
> 
> In EDKII implementation of variable policy, the DXE runtime agent would
> communicate to MM to disable, register or query policies. However, these
> operations populate the value of MessageLength that includes communicate
> header to include MM communicate header, which mismatches with the
> description of PI specification.
> 
> This fix will correct the MessageLength field calculation to exclude
> the size of MM_COMMUNICATE_HEADER.
> 
> Cc: Jian J Wang <jian.j.w...@intel.com>
> Cc: Liming Gao <gaolim...@byosoft.com.cn>
> Cc: Hao A Wu <hao.a...@intel.com>
> Cc: Bret Barkelew <bret.barke...@microsoft.com>
> Cc: Michael Kubacki <michael.kuba...@microsoft.com>
> 
> Signed-off-by: Kun Qin <kuqi...@gmail.com>
> ---
> 
> Notes:
>     v2:
>     - No review, no updates
> 
>  MdeModulePkg/Universal/Variable/RuntimeDxe/VariablePolicySmmDxe.c |
> 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git
> a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariablePolicySmmDxe.c
> b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariablePolicySmmDxe.c
> index 672a2293bcb1..b2094fbcd6ea 100644
> ---
> a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariablePolicySmmDxe.c
> +++
> b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariablePolicySmmDxe.c
> @@ -89,7 +89,7 @@ ProtocolDisableVariablePolicy (
>    CommHeader   = mMmCommunicationBuffer;
>    PolicyHeader = (VAR_CHECK_POLICY_COMM_HEADER
> *)&CommHeader->Data;
>    CopyGuid (&CommHeader->HeaderGuid,
> &gVarCheckPolicyLibMmiHandlerGuid);
> -  CommHeader->MessageLength = BufferSize;
> +  CommHeader->MessageLength = BufferSize - OFFSET_OF
> (EFI_MM_COMMUNICATE_HEADER, Data);
>    PolicyHeader->Signature   = VAR_CHECK_POLICY_COMM_SIG;
>    PolicyHeader->Revision    = VAR_CHECK_POLICY_COMM_REVISION;
>    PolicyHeader->Command     =
> VAR_CHECK_POLICY_COMMAND_DISABLE;
> @@ -138,7 +138,7 @@ ProtocolIsVariablePolicyEnabled (
>    PolicyHeader  = (VAR_CHECK_POLICY_COMM_HEADER
> *)&CommHeader->Data;
>    CommandParams = (VAR_CHECK_POLICY_COMM_IS_ENABLED_PARAMS
> *)(PolicyHeader + 1);
>    CopyGuid (&CommHeader->HeaderGuid,
> &gVarCheckPolicyLibMmiHandlerGuid);
> -  CommHeader->MessageLength = BufferSize;
> +  CommHeader->MessageLength = BufferSize - OFFSET_OF
> (EFI_MM_COMMUNICATE_HEADER, Data);
>    PolicyHeader->Signature   = VAR_CHECK_POLICY_COMM_SIG;
>    PolicyHeader->Revision    = VAR_CHECK_POLICY_COMM_REVISION;
>    PolicyHeader->Command     =
> VAR_CHECK_POLICY_COMMAND_IS_ENABLED;
> @@ -213,7 +213,7 @@ ProtocolRegisterVariablePolicy (
>    PolicyHeader = (VAR_CHECK_POLICY_COMM_HEADER
> *)&CommHeader->Data;
>    PolicyBuffer = (VOID *)(PolicyHeader + 1);
>    CopyGuid (&CommHeader->HeaderGuid,
> &gVarCheckPolicyLibMmiHandlerGuid);
> -  CommHeader->MessageLength = BufferSize;
> +  CommHeader->MessageLength = BufferSize - OFFSET_OF
> (EFI_MM_COMMUNICATE_HEADER, Data);
>    PolicyHeader->Signature   = VAR_CHECK_POLICY_COMM_SIG;
>    PolicyHeader->Revision    = VAR_CHECK_POLICY_COMM_REVISION;
>    PolicyHeader->Command     =
> VAR_CHECK_POLICY_COMMAND_REGISTER;
> @@ -270,7 +270,7 @@ DumpVariablePolicyHelper (
>    PolicyHeader  = (VAR_CHECK_POLICY_COMM_HEADER
> *)&CommHeader->Data;
>    CommandParams = (VAR_CHECK_POLICY_COMM_DUMP_PARAMS
> *)(PolicyHeader + 1);
>    CopyGuid (&CommHeader->HeaderGuid,
> &gVarCheckPolicyLibMmiHandlerGuid);
> -  CommHeader->MessageLength = BufferSize;
> +  CommHeader->MessageLength = BufferSize - OFFSET_OF
> (EFI_MM_COMMUNICATE_HEADER, Data);
>    PolicyHeader->Signature   = VAR_CHECK_POLICY_COMM_SIG;
>    PolicyHeader->Revision    = VAR_CHECK_POLICY_COMM_REVISION;
>    PolicyHeader->Command     =
> VAR_CHECK_POLICY_COMMAND_DUMP;
> @@ -397,7 +397,7 @@ ProtocolLockVariablePolicy (
>    CommHeader   = mMmCommunicationBuffer;
>    PolicyHeader = (VAR_CHECK_POLICY_COMM_HEADER
> *)&CommHeader->Data;
>    CopyGuid (&CommHeader->HeaderGuid,
> &gVarCheckPolicyLibMmiHandlerGuid);
> -  CommHeader->MessageLength = BufferSize;
> +  CommHeader->MessageLength = BufferSize - OFFSET_OF
> (EFI_MM_COMMUNICATE_HEADER, Data);
>    PolicyHeader->Signature   = VAR_CHECK_POLICY_COMM_SIG;
>    PolicyHeader->Revision    = VAR_CHECK_POLICY_COMM_REVISION;
>    PolicyHeader->Command     =
> VAR_CHECK_POLICY_COMMAND_LOCK;
> --
> 2.32.0.windows.1
> 
> 
> 
> 
> 





-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#85503): https://edk2.groups.io/g/devel/message/85503
Mute This Topic: https://groups.io/mt/88339549/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-


Reply via email to