From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg1-f170.google.com (mail-pg1-f170.google.com [209.85.215.170]) by mx.groups.io with SMTP id smtpd.web12.55874.1638815739198632269 for ; Mon, 06 Dec 2021 10:35:39 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20210112 header.b=p8GQbiaW; spf=pass (domain: gmail.com, ip: 209.85.215.170, mailfrom: kuqin12@gmail.com) Received: by mail-pg1-f170.google.com with SMTP id s137so11314130pgs.5 for ; Mon, 06 Dec 2021 10:35:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :cc:references:from:in-reply-to:content-transfer-encoding; bh=7vkSfilrTd+mOYF8vxWC1gcJNd2oJ6f4yL0V3WwI97Y=; b=p8GQbiaWmVeZnfAmk1DO1YE5xdee10yPjweYXAIV7Djhbfp6463/Pf9t4l94ZY5TkD q5c5W4xorIBOpFOyO2/h8ZVwtSbfHgBUcm2ByGr8nVzWANY4XzCpwpW5nwmZnzWiCDxg t69SrUUTUhfXV1vundi7DEYoUUCIkKI5hM39+8WdMYfJh3OA2HrLsHOxGSdNJH63OC2U nlmqXXQQgKoCiXdcOrh6Zxv6Z1+7Fc1qUKbnbCp07WBLPWVrrNvWmhuoecYnG+2gNAKY 5uEYdraYnv7ZCtJODHOs+1WnBo1SpvapbA6ON5OnwWXb8mxnhVBJvZzxzpfHm8NeAIEl kk7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=7vkSfilrTd+mOYF8vxWC1gcJNd2oJ6f4yL0V3WwI97Y=; b=L0oS7heTYPpS3HZeuxUUKMxw8+qiFMcFoWLGqPrOHdO7JowITp/KQVC/p2Tt7gOqXY rENk1AKPovAzdTdEJ6SjA6uXr0UytG1bAMJMrBoDQ3N1dradaeKRFjBEJ4HlG5Y37+LX pzQUDqHnc95AdfzUbCiADGbR30QygpZAIUIsuAzwTv6puEWpyIcssCrrDLuQkue9wgZs AguLKi8rSn7g9hAZzh9rUBHiZUcEHiLUiOBmZykLCMx689t27PQFeShg6ti2hkjcRltu Ma6ldUzZ4vk0G0oXuHp6Lw3z7sRCyIqb/vvTQAbPoQH8Icqp0wR7G4uTS2GcaIJm2nCg ELkQ== X-Gm-Message-State: AOAM531PAh5N3bGdyoduHXVmTu3RRj/FR5sYzZ/ajLvLXcmgLW1eQqLk Q+xyFM+kY9Ncozqr2/38N3EHC31kiDMUxQ== X-Google-Smtp-Source: ABdhPJztCwlveGak0wXasm4uDQ7GDmo35wKq/aP7YgmQYX+EmrIxtlMYAJXwMRn5GBlzaWOBzc3+9w== X-Received: by 2002:aa7:9d81:0:b0:49f:e072:bfc7 with SMTP id f1-20020aa79d81000000b0049fe072bfc7mr38329454pfq.48.1638815728404; Mon, 06 Dec 2021 10:35:28 -0800 (PST) Return-Path: Received: from [192.168.1.18] ([50.35.70.63]) by smtp.gmail.com with ESMTPSA id i1sm10630229pgs.50.2021.12.06.10.35.27 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 06 Dec 2021 10:35:27 -0800 (PST) Message-ID: <6fcb7f10-c113-1c9d-2b4d-264b81ed6ad1@gmail.com> Date: Mon, 6 Dec 2021 10:35:27 -0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.3.2 Subject: Re: [edk2-devel] [PATCH v1 0/2] MM communicate functionality in variable policy To: devel@edk2.groups.io Cc: Jian J Wang , Liming Gao , Hao A Wu , Leif Lindholm , Ard Biesheuvel , Bret Barkelew , Michael Kubacki References: <16BC2C06E438B403.26361@groups.io> From: "Kun Qin" In-Reply-To: <16BC2C06E438B403.26361@groups.io> Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Hi ArmPkg and MdeModulePkg maintainers, It has been a week since the patches were sent. Could you please review the changes and let me know if there is any feedback? Any input is appreciated. Regards, Kun On 11/29/2021 16:39, Kun Qin via groups.io wrote: > 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 > Cc: Liming Gao > Cc: Hao A Wu > Cc: Leif Lindholm > Cc: Ard Biesheuvel > Cc: Bret Barkelew > Cc: Michael Kubacki > > 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(-) >