From nobody Mon Feb 9 15:10:07 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+86070+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+86070+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1643139560; cv=none; d=zohomail.com; s=zohoarc; b=J0XZ3ny7faYegjN7L+YO+DQRUfkJfbQNHPMffq6Vk0FIP+eudRL/vHIQfydZvnSNyK4DiS052nsKRl2Lz3kmcyTb7VxU6ToySv/UDB0BQdFVP3VUAHZmlfSvUdu768DSpQUCzDQ/xX8JgY6DOAcZlNqJkpYoP/73C8MQClt5PhU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1643139560; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=NogAdV23qsbJdwVjEhm7qjhX6HkdoMTc1d9sxPjKDsI=; b=dLV1PWfOUWaVAWmZ4tLfjYkRgDWcFrWd45JkISdLPclx11+Wwk6zIiDOszzfFi7LrnHJhhSy90JBn/FKp22G60w7nF6Ts/OGkMCuk2O2spPbrRHrbyBUQ2aS6s7Zb7M/ZoOni3SyrGDFPuAURoG1EAOctEnAS/0lkQOblydfgLk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+86070+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 164313956003895.83867015363148; Tue, 25 Jan 2022 11:39:20 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id IZ1aYY1788612xhfFuIjXEvD; Tue, 25 Jan 2022 11:39:19 -0800 X-Received: from mail-pg1-f180.google.com (mail-pg1-f180.google.com [209.85.215.180]) by mx.groups.io with SMTP id smtpd.web12.1944.1643139558840333274 for ; Tue, 25 Jan 2022 11:39:18 -0800 X-Received: by mail-pg1-f180.google.com with SMTP id v3so13831585pgc.1 for ; Tue, 25 Jan 2022 11:39:18 -0800 (PST) X-Gm-Message-State: ywcZYyZgijqs2SgesRuUcxWPx1787277AA= X-Google-Smtp-Source: ABdhPJwAA/0PJdc+VvqM9RL1Pys7alRUwHFSGUq2UBxEI+8OmglQOvlvjLkhqRm7fDCJQhjng7Os/g== X-Received: by 2002:a62:33c7:0:b0:4bd:5aa4:1220 with SMTP id z190-20020a6233c7000000b004bd5aa41220mr19561934pfz.55.1643139558292; Tue, 25 Jan 2022 11:39:18 -0800 (PST) X-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.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jan 2022 11:39:18 -0800 (PST) From: "Kun Qin" To: devel@edk2.groups.io Cc: Leif Lindholm , Ard Biesheuvel , Bret Barkelew , Michael Kubacki , Sami Mujawar Subject: [edk2-devel] [PATCH v3 5/6] ArmPkg: MmCommunicationDxe: Update MM communicate `CommSize` check Date: Tue, 25 Jan 2022 11:39:08 -0800 Message-Id: <20220125193909.491-6-kuqin12@gmail.com> In-Reply-To: <20220125193909.491-1-kuqin12@gmail.com> References: <20220125193909.491-1-kuqin12@gmail.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,kuqin12@gmail.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1643139559; bh=9UoJGRwPyq/+Ty+mFJS5bzxUHM7biya9d0KByKhvtc0=; h=Cc:Date:From:Reply-To:Subject:To; b=wOeN1MFt1bWCG/ubhlv8iXFqaLTWULeNcq6arHnxCQa92peDCn40JAQudReCdVPHvwJ UkOBzQar63gAw+fOwSm6FKy8lLX/UEuO2ysji6QrykkiFo9E52Ym2Zro+xMdmxqNeDDmM qpdVQQ85B0teFK9JzVvLw7HkAt6OWhPjXmU= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1643139562329100022 Content-Type: text/plain; charset="utf-8" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3751 Current MM communicate routine from ArmPkg would conduct few checks prior to proceeding with SMC calls. However, the inspection step is different from PI specification. This patch updated MM communicate input argument inspection routine to assure `CommSize` represents "the size of the data buffer being passed in" instead of the size of the data being used from data buffer, as described by section `EFI_MM_COMMUNICATION2_PROTOCOL.Communicate()` in PI specification. Cc: Leif Lindholm Cc: Ard Biesheuvel Cc: Bret Barkelew Cc: Michael Kubacki Cc: Sami Mujawar Signed-off-by: Kun Qin Reviewed-by: Sami Mujawar --- Notes: v2: - Splitting patch into 3 of 4 [Ard] =20 v3: - Added cc entry and reviewed-by tag [Sami] ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c | 19 ++++++++++++-----= -- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c b/ArmPkg/D= rivers/MmCommunicationDxe/MmCommunication.c index 0283be430dff..2f89b7c5b6c4 100644 --- a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c +++ b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c @@ -44,13 +44,18 @@ STATIC EFI_HANDLE mMmCommunicateHandle; @param[in] This The EFI_MM_COMMUNICATION_PROTOCOL in= stance. @param[in, out] CommBufferPhysical Physical address of the MM communica= tion buffer @param[in, out] CommBufferVirtual Virtual address of the MM communicat= ion buffer - @param[in, out] CommSize The size of the data buffer being pa= ssed in. On exit, the - size of data being returned. Zero if= the handler does not + @param[in, out] CommSize The size of the data buffer being pa= ssed in. On input, + when not omitted, the buffer should = cover EFI_MM_COMMUNICATE_HEADER + and the value of MessageLength field= . On exit, the size + of data being returned. Zero if the = handler does not wish to reply with any data. This pa= rameter is optional and may be NULL. =20 @retval EFI_SUCCESS The message was successfully posted. - @retval EFI_INVALID_PARAMETER CommBufferPhysical was NULL or CommBuffer= Virtual was NULL. + @retval EFI_INVALID_PARAMETER CommBufferPhysical or CommBufferVirtual w= as NULL, or + integer value pointed by CommSize does no= t cover + EFI_MM_COMMUNICATE_HEADER and the value o= f MessageLength + field. @retval EFI_BAD_BUFFER_SIZE The buffer is too large for the MM implem= entation. If this error is returned, the MessageLen= gth field in the CommBuffer header or the integer p= ointed by @@ -96,8 +101,8 @@ MmCommunication2Communicate ( sizeof (CommunicateHeader->HeaderGuid) + sizeof (CommunicateHeader->MessageLength); =20 - // If the length of the CommBuffer is 0 then return the expected length. - if (CommSize !=3D 0) { + // If CommSize is not omitted, perform size inspection before proceeding. + if (CommSize !=3D NULL) { // This case can be used by the consumer of this driver to find out the // max size that can be used for allocating CommBuffer. if ((*CommSize =3D=3D 0) || @@ -108,9 +113,9 @@ MmCommunication2Communicate ( } =20 // - // CommSize must match MessageLength + sizeof (EFI_MM_COMMUNICATE_HEAD= ER); + // CommSize should cover at least MessageLength + sizeof (EFI_MM_COMMU= NICATE_HEADER); // - if (*CommSize !=3D BufferSize) { + if (*CommSize < BufferSize) { return EFI_INVALID_PARAMETER; } } --=20 2.34.1.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#86070): https://edk2.groups.io/g/devel/message/86070 Mute This Topic: https://groups.io/mt/88680224/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-