From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f49.google.com (mail-pj1-f49.google.com [209.85.216.49]) by mx.groups.io with SMTP id smtpd.web09.706.1640050451790656732 for ; Mon, 20 Dec 2021 17:34:11 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20210112 header.b=oPBOaos3; spf=pass (domain: gmail.com, ip: 209.85.216.49, mailfrom: kuqin12@gmail.com) Received: by mail-pj1-f49.google.com with SMTP id n15-20020a17090a394f00b001b0f6d6468eso931342pjf.3 for ; Mon, 20 Dec 2021 17:34:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=uYPOKkNCX/oq35Gzn3vm78Y55pVQa6CjmhD76LqaDn4=; b=oPBOaos3jQzEwI8YIEy7dhN0nOmgTG3C/0RXfgtrzZWxpTiQEvM6dazlgV8ViZXEjO cWTGbT8ehrSrF+PLTOfpg2gZrAEetbHTcYFrDB295+B9LMb2BmzClbxfEs77/Geydy75 gW01CG8uKymuaPXSoVLpyrw/3ClEmlWukU6cYJIIrfvbMxh7HVhYaW2S1BfhD0rkR/oa q00axeby9mYma5UtdM2h+uwGjN2199pU5sOQX/7rEQWWEm0HhFDD5CKbmQ1CA31/aGxS yi2RDv9FW7+lpGqXZBLUF/asyaGjAQcBmTZ/nq89vjBaHjdNLkXPfiAmIXYMKcgtIDDB yqNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=uYPOKkNCX/oq35Gzn3vm78Y55pVQa6CjmhD76LqaDn4=; b=uj6Wxhbjg/LXvwM5OAX10Gg0J/fkdlWTuWlXFNksaPTIQ0CLPzvTyhxzNw74NteQxo 4TOYrwNThSFnnpfjwWYafxqOGInJz3IH393NmTmDtpOtJEgWMO9tUUKm603HrNYIBTSa do17BALE5Mx7RKLdfZgQQkGK+yDykxLpJlZ+ytQlnJXlUsfOo6ElZ2x2a7Ee7UM5AeBu T58q2UjHGz/2Inda6uj+QWEVXeSkGrM8faI1bQR0SIteA5VB+foSVOKHO0ptO1dWebhS UYZ5W7CNo2JFPlQmffFkw7WF+8nkRXYzd+A0ucXABmolJUiFhtZ+xUGNgtMUFFQyarnx Ij0A== X-Gm-Message-State: AOAM530I/Yp2nrlTQqwdQc19JfxOaYmgWQtPFZ5sGa5z8axlrsfEAhSy +h8CY8KwQi5OgilaqqM6stF1/UVlvC8= X-Google-Smtp-Source: ABdhPJyEvY5EY+UIHIGHQ0/Q4EHFDJ8+J2igVaeLYEIu9NoKLDK6M4m8PjUo+zMfiOCO8IeXI102fQ== X-Received: by 2002:a17:90a:d195:: with SMTP id fu21mr1014915pjb.106.1640050451241; Mon, 20 Dec 2021 17:34:11 -0800 (PST) Return-Path: Received: from localhost.localdomain ([50.35.74.198]) by smtp.gmail.com with ESMTPSA id m10sm17389189pgv.75.2021.12.20.17.34.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Dec 2021 17:34:11 -0800 (PST) From: "Kun Qin" To: devel@edk2.groups.io Cc: Jian J Wang , Liming Gao , Hao A Wu , Bret Barkelew , Michael Kubacki Subject: [PATCH v2 1/6] MdeModulePkg: VariableSmmRuntimeDxe: Fix Variable Policy Message Length Date: Mon, 20 Dec 2021 17:33:29 -0800 Message-Id: <20211221013334.1751-2-kuqin12@gmail.com> X-Mailer: git-send-email 2.32.0.windows.1 In-Reply-To: <20211221013334.1751-1-kuqin12@gmail.com> References: <20211221013334.1751-1-kuqin12@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Cc: Liming Gao Cc: Hao A Wu Cc: Bret Barkelew Cc: Michael Kubacki Signed-off-by: Kun Qin --- 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