public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH v1 0/2] MM communicate functionality in variable policy
@ 2021-11-30  0:39 Kun Qin
  2021-11-30  0:39 ` [PATCH v1 1/2] MdeModulePkg: VariableSmmRuntimeDxe: Fix Variable Policy Message Length Kun Qin
  2021-11-30  0:39 ` [PATCH v1 2/2] ArmPkg: MmCommunicationDxe: Update MM communicate input arguments checks Kun Qin
  0 siblings, 2 replies; 7+ messages in thread
From: Kun Qin @ 2021-11-30  0:39 UTC (permalink / raw)
  To: devel
  Cc: Jian J Wang, Liming Gao, Hao A Wu, Leif Lindholm, Ard Biesheuvel,
	Bret Barkelew, Michael Kubacki

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3709
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3751

Currently, setups with variable policy operations used together with MM
communicate from ArmPkg could fail with `EFI_INVALID_PARAMETER`. This was
due to the errors from 2 following aspects: 

1. For variable policy implementations in MdeModulePkg, the DXE runtime
agent would communicate to MM to disable, register or query policies.
However, during these operations, the MessageLength calculation is
including MM communicate header. This could lead to MM agent read data
across the given buffer boundary and/or trigger other errors.

2. On the other hand, current MM communicate routine from ArmPkg would
fail the function if the input message length does not equal to input
buffer size.

As defined in PI specification, the `CommSize`, when as input, should
stand for "The size of the data buffer being passed in", which would mean
the maximal number of bytes `CommBuffer` can hold. In turn, the value of
this input parameter can be used for MM handlers to determine whether the
output data is too large to fit in this buffer. Enforcing the incoming
buffer to hold exactly the number of used bytes mismatches with the PI
spec description.

This change fix MessageLength field calculation from variable policy and
updated input argument inspections from MM communicate routine in ArmPkg
to match PI spec descriptions.

Patch v1 branch: https://github.com/kuqin12/edk2/tree/mm_communicate_check

Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Leif Lindholm <leif@nuviainc.com>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
Cc: Michael Kubacki <michael.kubacki@microsoft.com>

Kun Qin (2):
  MdeModulePkg: VariableSmmRuntimeDxe: Fix Variable Policy Message
    Length
  ArmPkg: MmCommunicationDxe: Update MM communicate input arguments
    checks

 ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c               | 44 ++++++++++++--------
 MdeModulePkg/Universal/Variable/RuntimeDxe/VariablePolicySmmDxe.c | 10 ++---
 2 files changed, 32 insertions(+), 22 deletions(-)

-- 
2.32.0.windows.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-12-21  1:38 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-11-30  0:39 [PATCH v1 0/2] MM communicate functionality in variable policy Kun Qin
2021-11-30  0:39 ` [PATCH v1 1/2] MdeModulePkg: VariableSmmRuntimeDxe: Fix Variable Policy Message Length Kun Qin
2021-11-30  0:39 ` [PATCH v1 2/2] ArmPkg: MmCommunicationDxe: Update MM communicate input arguments checks Kun Qin
2021-12-13 21:03   ` [edk2-devel] " Sami Mujawar
2021-12-21  1:38     ` Kun Qin
2021-12-15  8:52   ` Ard Biesheuvel
2021-12-21  1:36     ` Kun Qin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox