From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg1-f169.google.com (mail-pg1-f169.google.com [209.85.215.169]) by mx.groups.io with SMTP id smtpd.web11.2065.1643139556106848812 for ; Tue, 25 Jan 2022 11:39:16 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20210112 header.b=EtMl/l61; spf=pass (domain: gmail.com, ip: 209.85.215.169, mailfrom: kuqin12@gmail.com) Received: by mail-pg1-f169.google.com with SMTP id p125so19142850pga.2 for ; Tue, 25 Jan 2022 11:39:16 -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=96DqpsTokVDit2wFgX+UA97G0Cq1e415HPS+rkcxsx8=; b=EtMl/l61ZFIAmHFmFMxR+CSZh4jU/E+hrPQJKHCmaJjAm8ljT+iF5D6UpDJKIqDkd/ LmEkUGtOuRiYhsA/AIIHHD0Fvyl1Q7QybpNJvxurWGFKzwbBBJAtTWdGVpj6EXm8VfRx tt2MVq6sX2DcbCkLUz6QbU9NEhiXQIFoD5KAiMY4TKW9Zu/4lrj8+4kecSbX74mx8PH8 RsWAlnmt9OgnIQuN6wyTkQtEQnTLNmZRbQLIQnKqKvmglfEU7HHLM8ald/4lU3WQQWSR 2E4lhldk2r/+19k+tdbrdwIx541pS5AM6lSRGCKjX769Kb6lFzDNly+noThDwCVay6pb pG/g== 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=96DqpsTokVDit2wFgX+UA97G0Cq1e415HPS+rkcxsx8=; b=DhLQN10jOB15WJv8yXl3Jt1AerEycBlIBFNP3Wevgo2qc5qz99v1KCfxpj/WAPD7dB va859Fkbt4KZXAO7YU+EOv3L6x6wAWBqfCueWhlx8Y8uxrG3yjjb7CQPEqTyLKFaKEUD kjd7Cbs6XeU43rbGGO09ewru3S3JGOLY094F86HkxeFIG9gK6HG9JYVX0HsBnS8y5RAH RULzCJp6IBxZBiF83Nt4MPjQ8flq8UmPLbqzSDcAMpEY5S33Hd8J8HCx+F6ze4aocWnV kuiuIHv2YtxLBwvLKpr9ZGwlcLu15j7+eejAzKm4TBwd4Bs9CVwpWpytvahceuYsHcZB n7FA== X-Gm-Message-State: AOAM531v5mzmrPtGJJ+Epxq/n26DvdpWiaawNxnalKhi/v/nlj6BgEOr va1uBq3fpBJLMyK2JD1Mk/H3jkUhNm4= X-Google-Smtp-Source: ABdhPJzEi4mm1++9OK9wLlfxJ7te64bHuMKLdUeDd3SvkN8rXN3/9j5XO0Zv+bh8+4zG7uH1Ugs7MA== X-Received: by 2002:a05:6a00:1946:b0:492:64f1:61b5 with SMTP id s6-20020a056a00194600b0049264f161b5mr19828667pfk.52.1643139555437; Tue, 25 Jan 2022 11:39:15 -0800 (PST) Return-Path: Received: from gem-name-lb-02.localdomain ([50.35.74.198]) by smtp.gmail.com with ESMTPSA id v8sm1036929pju.51.2022.01.25.11.39.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jan 2022 11:39:15 -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 v3 1/6] MdeModulePkg: VariableSmmRuntimeDxe: Fix Variable Policy Message Length Date: Tue, 25 Jan 2022 11:39:04 -0800 Message-Id: <20220125193909.491-2-kuqin12@gmail.com> X-Mailer: git-send-email 2.34.1.windows.1 In-Reply-To: <20220125193909.491-1-kuqin12@gmail.com> References: <20220125193909.491-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 Reviewed-by: Liming Gao --- Notes: v2: - No review, no updates v3: - Added reviewed-by tag [Liming] 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.34.1.windows.1