From nobody Mon Feb 9 10:58:21 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+109912+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+109912+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1698066322; cv=none; d=zohomail.com; s=zohoarc; b=PdNgeL2N337DxWFrUvXEp3sG5Cn7TlN8gBRANwqBext3fpu4TZqLp/UoqQadUn31g/h3RQa7G0mllM9cbE0y5WAv8SxfGJ78xSO7usiDtS6vKgtUQj6N3ib5usFk7pjCnqGVGAqmjeK+0j9eqeXbXF8V4EntkDlNxbqcOsassFQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698066322; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=HPbfe3tR1m+quf2ZA+MK44ROky+jQcDP5zMmg/QeO0E=; b=iV15+UhMspB0KEtIER3OKIB1UB+FQwfZBMjPqgJWgz7+k4op60ODocWC3/VqoziNdm1tSTUCeaCJJC2Em5Nq8/weDke9W9jOd+1vkCJUyOY+YKKCWF3B01k891UZ9yIYuRLEm68wwvLSPc8i/dHy6ttgnYbZUV/rhPGKTWb1BZE= 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+109912+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 1698066322564829.7992106468517; Mon, 23 Oct 2023 06:05:22 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=elYrdlvSi/25VP0y7g602Dc3cOQ6zm/poRAiquudj20=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1698066321; v=1; b=shIQqUGY3pIuL2dqPiHZ4mkUGJKvpQWHO/tnb1asOJ/EIkG9t6pZekuDKleAOZH3HD0/y0Cc g9KG2JKDFJcuEy9BZC+ymdnYism2d5YpNPY3XQWSqGWBdnH0WfY9MLpjjgbgPnPtaKryxHL8xbW kVo82KRlZNEhggHOmep39x20= X-Received: by 127.0.0.2 with SMTP id 92WVYY1788612x76IjSeiRyV; Mon, 23 Oct 2023 06:05:21 -0700 X-Received: from mail-lf1-f44.google.com (mail-lf1-f44.google.com [209.85.167.44]) by mx.groups.io with SMTP id smtpd.web11.120283.1698066321141455304 for ; Mon, 23 Oct 2023 06:05:21 -0700 X-Received: by mail-lf1-f44.google.com with SMTP id 2adb3069b0e04-507a55302e0so4412857e87.0 for ; Mon, 23 Oct 2023 06:05:20 -0700 (PDT) X-Gm-Message-State: KGFW1z6HrNBFvwpZOq1f3zMIx1787277AA= X-Google-Smtp-Source: AGHT+IEgPPoiRqFEPj/TI1uLxDDfwJv3rRtJgP3oxFhJMc+8qHodLq9L6znLRsP3xnc5G82bGLGY1Q== X-Received: by 2002:a2e:8718:0:b0:2c1:9a8b:f67 with SMTP id m24-20020a2e8718000000b002c19a8b0f67mr6996096lji.1.1698066318949; Mon, 23 Oct 2023 06:05:18 -0700 (PDT) X-Received: from PC10319.67 ([82.97.198.254]) by smtp.googlemail.com with ESMTPSA id r11-20020a2e994b000000b002b9e0d19644sm1550081ljj.106.2023.10.23.06.05.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 06:05:18 -0700 (PDT) From: "Konstantin Aladyshev" To: devel@edk2.groups.io Cc: abner.chang@amd.com, AbdulLateef.Attar@amd.com, nicklew@nvidia.com, Konstantin Aladyshev Subject: [edk2-devel] [PATCH edk2-platforms v3 04/16] ManageabilityPkg: Check header fields in the MCTP response Date: Mon, 23 Oct 2023 16:04:59 +0300 Message-Id: <20231023130511.4521-5-aladyshev22@gmail.com> In-Reply-To: <20231023130511.4521-1-aladyshev22@gmail.com> References: <20231023130511.4521-1-aladyshev22@gmail.com> MIME-Version: 1.0 Precedence: Bulk 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,aladyshev22@gmail.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1698066324839100023 Content-Type: text/plain; charset="utf-8" Add checks for the MCTP header fields in the MCTP response. Signed-off-by: Konstantin Aladyshev --- .../MctpProtocol/Common/MctpProtocolCommon.c | 82 +++++++++++++++++++ 1 file changed, 82 insertions(+) diff --git a/Features/ManageabilityPkg/Universal/MctpProtocol/Common/MctpPr= otocolCommon.c b/Features/ManageabilityPkg/Universal/MctpProtocol/Common/Mc= tpProtocolCommon.c index e560c638d5..5844d54eb2 100644 --- a/Features/ManageabilityPkg/Universal/MctpProtocol/Common/MctpProtocolC= ommon.c +++ b/Features/ManageabilityPkg/Universal/MctpProtocol/Common/MctpProtocolC= ommon.c @@ -461,6 +461,88 @@ CommonMctpSubmitMessage ( &TransferToken ); =20 + MctpTransportResponseHeader =3D (MCTP_TRANSPORT_HEADER *)ResponseBuffer; + if (MctpTransportResponseHeader->Bits.HeaderVersion !=3D MCTP_KCS_HEADER= _VERSION) { + DEBUG (( + DEBUG_ERROR, + "%a: Error! Response HeaderVersion (0x%02x) doesn't match MCTP_KCS_H= EADER_VERSION (0x%02x)\n", + __func__, + MctpTransportResponseHeader->Bits.HeaderVersion, + MCTP_KCS_HEADER_VERSION + )); + FreePool (ResponseBuffer); + return EFI_DEVICE_ERROR; + } + if (MctpTransportResponseHeader->Bits.MessageTag !=3D MCTP_MESSAGE_TAG) { + DEBUG (( + DEBUG_ERROR, + "%a: Error! Response MessageTag (0x%02x) doesn't match MCTP_MESSAGE_= TAG (0x%02x)\n", + __func__, + MctpTransportResponseHeader->Bits.MessageTag, + MCTP_MESSAGE_TAG + )); + FreePool (ResponseBuffer); + return EFI_DEVICE_ERROR; + } + if (MctpTransportResponseHeader->Bits.TagOwner !=3D MCTP_MESSAGE_TAG_OWN= ER_RESPONSE) { + DEBUG (( + DEBUG_ERROR, + "%a: Error! Response TagOwner (0x%02x) doesn't match MCTP_MESSAGE_TA= G_OWNER_RESPONSE (0x%02x)\n", + __func__, + MctpTransportResponseHeader->Bits.TagOwner, + MCTP_MESSAGE_TAG_OWNER_RESPONSE + )); + FreePool (ResponseBuffer); + return EFI_DEVICE_ERROR; + } + if (MctpTransportResponseHeader->Bits.SourceEndpointId !=3D MctpDestinat= ionEndpointId) { + DEBUG (( + DEBUG_ERROR, + "%a: Error! Response SrcEID (0x%02x) doesn't match sent EID (0x%02x)= \n", + __func__, + MctpTransportResponseHeader->Bits.SourceEndpointId, + MctpDestinationEndpointId + )); + FreePool (ResponseBuffer); + return EFI_DEVICE_ERROR; + } + if (MctpTransportResponseHeader->Bits.DestinationEndpointId !=3D MctpSou= rceEndpointId) { + DEBUG (( + DEBUG_ERROR, + "%a: Error! Response DestEID (0x%02x) doesn't match local EID (0x%02= x)\n", + __func__, + MctpTransportResponseHeader->Bits.DestinationEndpointId, + MctpSourceEndpointId + )); + FreePool (ResponseBuffer); + return EFI_DEVICE_ERROR; + } + + MctpMessageResponseHeader =3D (MCTP_MESSAGE_HEADER *)(MctpTransportRespo= nseHeader + 1); + if (MctpMessageResponseHeader->Bits.MessageType !=3D MctpType) { + DEBUG (( + DEBUG_ERROR, + "%a: Error! Response MessageType (0x%02x) doesn't match sent Message= Type (0x%02x)\n", + __func__, + MctpMessageResponseHeader->Bits.MessageType, + MctpType + )); + FreePool (ResponseBuffer); + return EFI_DEVICE_ERROR; + } + + if (MctpMessageResponseHeader->Bits.IntegrityCheck !=3D (UINT8)RequestDa= taIntegrityCheck) { + DEBUG (( + DEBUG_ERROR, + "%a: Error! Response IntegrityCheck (%d) doesn't match sent Integrit= yCheck (%d)\n", + __func__, + MctpMessageResponseHeader->Bits.IntegrityCheck, + (UINT8)RequestDataIntegrityCheck + )); + FreePool (ResponseBuffer); + return EFI_DEVICE_ERROR; + } + // // Return transfer status. // --=20 2.34.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 (#109912): https://edk2.groups.io/g/devel/message/109912 Mute This Topic: https://groups.io/mt/102134652/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-