From nobody Tue Feb 10 01:16:06 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+85122+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+85122+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1640050456; cv=none; d=zohomail.com; s=zohoarc; b=iabZAloyfjsgj3keUIJflnEuzfxkw55+r/oV4KQOk8CDN7s9NiNS7W8gXeEN+lIRgdTfKV1wWTp7SAulinpNEwTB+BmniYzcNiesIcoYfGXbEnDskLJEbae41af5DzpKk5EFE7xw2xbMOSxBJ5bvjevwycypI4IQZScoy/cPwP0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1640050456; 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=0gBqR0CgE6hyK8T/LRb+mFQS2FQm151SdGuRCdM/weo=; b=AyNKMjxBThINcb4nU2l1PuDyybisqZV1cegPBesXTidVdFDc4w/k19a44uglAEyCa04/KkuSLnPD6CiC7pETS911+QJqAnQ0BNIdaoP4mItW4kxFKM4jOLeXWerkX5ec9x5Xefh137N3hV6V5aSbLyCtIAJ7U0UtmGNEqUhzwwM= 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+85122+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 1640050456073156.89635114611656; Mon, 20 Dec 2021 17:34:16 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id wM7iYY1788612xBtI6oQIy1g; Mon, 20 Dec 2021 17:34:15 -0800 X-Received: from mail-pj1-f53.google.com (mail-pj1-f53.google.com [209.85.216.53]) by mx.groups.io with SMTP id smtpd.web08.731.1640050454801596164 for ; Mon, 20 Dec 2021 17:34:14 -0800 X-Received: by mail-pj1-f53.google.com with SMTP id iy13so5610311pjb.5 for ; Mon, 20 Dec 2021 17:34:14 -0800 (PST) X-Gm-Message-State: z41Wqh9gmHkgWq70rt5B5rhOx1787277AA= X-Google-Smtp-Source: ABdhPJz6bWgTj9/98Id3II3c2m5nkLAs2GmBDTeBmdMK4NJZ4KnPvFtKTaczsfqfFi+TosC/KSQ5Ag== X-Received: by 2002:a17:90b:3d6:: with SMTP id go22mr966966pjb.221.1640050454263; Mon, 20 Dec 2021 17:34:14 -0800 (PST) X-Received: from localhost.localdomain ([50.35.74.198]) by smtp.gmail.com with ESMTPSA id m10sm17389189pgv.75.2021.12.20.17.34.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Dec 2021 17:34:14 -0800 (PST) From: "Kun Qin" To: devel@edk2.groups.io Cc: Leif Lindholm , Ard Biesheuvel , Bret Barkelew , Michael Kubacki Subject: [edk2-devel] [PATCH v2 6/6] ArmPkg: MmCommunicationDxe: Update MM communicate `MessageLength` check Date: Mon, 20 Dec 2021 17:33:34 -0800 Message-Id: <20211221013334.1751-7-kuqin12@gmail.com> In-Reply-To: <20211221013334.1751-1-kuqin12@gmail.com> References: <20211221013334.1751-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=1640050455; bh=S47e+/T/cs9vkXhUWXctY0HUEyOQKkxb6F+bVTeYqmI=; h=Cc:Date:From:Reply-To:Subject:To; b=SPewd1nPoSxXZ09RhltECJCiR4XTBXXAz7YVq1D2krbOu3cYi1kP2E1GDapciUu/6fB mEJJpNCi10gMWLSmW9GsIRnHZ3Cu3HsLDUPzdGyygs1cpcEtSKMJyXrNO1cUsl+o1omcz Wsn+bPAAv5kwI5iGyRcxqXPtBYdpHZexc2c= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1640050457535100028 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 that "if the `MessageLength` is zero, or too large for the MM implementation to manage, the MM implementation must update the `MessageLength` to reflect the size of the `Data` buffer that it can tolerate", as described by `EFI_MM_COMMUNICATION_PROTOCOL.Communicate()` section in PI specification. Cc: Leif Lindholm Cc: Ard Biesheuvel Cc: Bret Barkelew Cc: Michael Kubacki Signed-off-by: Kun Qin --- Notes: v2: - Splitting patch into 4 of 4 [Ard] - Uncrustify style update ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c b/ArmPkg/D= rivers/MmCommunicationDxe/MmCommunication.c index 2f89b7c5b6c4..85d9034555f0 100644 --- a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c +++ b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c @@ -92,6 +92,7 @@ MmCommunication2Communicate ( return EFI_INVALID_PARAMETER; } =20 + Status =3D EFI_SUCCESS; CommunicateHeader =3D CommBufferVirtual; // CommBuffer is a mandatory parameter. Hence, Rely on // MessageLength + Header to ascertain the @@ -109,28 +110,33 @@ MmCommunication2Communicate ( (*CommSize > mNsCommBuffMemRegion.Length)) { *CommSize =3D mNsCommBuffMemRegion.Length; - return EFI_BAD_BUFFER_SIZE; + Status =3D EFI_BAD_BUFFER_SIZE; } =20 // // CommSize should cover at least MessageLength + sizeof (EFI_MM_COMMU= NICATE_HEADER); // if (*CommSize < BufferSize) { - return EFI_INVALID_PARAMETER; + Status =3D EFI_INVALID_PARAMETER; } } =20 // - // If the buffer size is 0 or greater than what can be tolerated by the = MM + // If the message length is 0 or greater than what can be tolerated by t= he MM // environment then return the expected size. // - if ((BufferSize =3D=3D 0) || + if ((CommunicateHeader->MessageLength =3D=3D 0) || (BufferSize > mNsCommBuffMemRegion.Length)) { CommunicateHeader->MessageLength =3D mNsCommBuffMemRegion.Length - sizeof (CommunicateHeader->HeaderGu= id) - sizeof (CommunicateHeader->MessageL= ength); - return EFI_BAD_BUFFER_SIZE; + Status =3D EFI_BAD_BUFFER_SIZE; + } + + // MessageLength or CommSize check has failed, return here. + if (EFI_ERROR (Status)) { + return Status; } =20 // SMC Function ID --=20 2.32.0.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 (#85122): https://edk2.groups.io/g/devel/message/85122 Mute This Topic: https://groups.io/mt/87869778/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-