From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 200F3AC1030 for ; Fri, 20 Oct 2023 12:53:15 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=MMj3+YtDxzf0LXaKgGNv6sHk3sY4MxuXFer06LNRAxM=; 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=1697806394; v=1; b=Z0HWYjFJIEzYCpd+UDQxaDYiAzbO4Iq9KYHzXaGp9ElrJ2tjtH9ISsxLifmmrzAbrKSGrBFR qS7Ei043MDbuTSpQHZe65Hajx5EpgXehxrjcU08COb2Qsm6a/jctjl3fVI0F88tpVLovl7BttAR 2Odhk/OqRpa197UKmLhKos2E= X-Received: by 127.0.0.2 with SMTP id Wkb1YY7687511xqahApUZYJk; Fri, 20 Oct 2023 05:53:14 -0700 X-Received: from mail-lj1-f171.google.com (mail-lj1-f171.google.com [209.85.208.171]) by mx.groups.io with SMTP id smtpd.web10.53378.1697806393923337168 for ; Fri, 20 Oct 2023 05:53:14 -0700 X-Received: by mail-lj1-f171.google.com with SMTP id 38308e7fff4ca-2c514cbbe7eso11185501fa.1 for ; Fri, 20 Oct 2023 05:53:13 -0700 (PDT) X-Gm-Message-State: NodkdTPzwYoZrTP0a8085UXJx7686176AA= X-Google-Smtp-Source: AGHT+IEgQsb+QR+BT0sj5hKVfAwTKXhcJY/3dE+tBxfKBcO7EmrNIrpobbgSp2HGsppsxSgE0Jcceg== X-Received: by 2002:a05:651c:222c:b0:2c5:d3e:2f46 with SMTP id y44-20020a05651c222c00b002c50d3e2f46mr1303075ljq.11.1697806391849; Fri, 20 Oct 2023 05:53:11 -0700 (PDT) X-Received: from PC10319.67 ([82.97.198.254]) by smtp.googlemail.com with ESMTPSA id x22-20020a05651c105600b002b9e5fe86dasm350853ljm.81.2023.10.20.05.53.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 05:53:11 -0700 (PDT) From: "Konstantin Aladyshev" To: devel@edk2.groups.io Cc: abner.chang@amd.com, isaac.w.oram@intel.com, AbdulLateef.Attar@amd.com, nicklew@nvidia.com, Konstantin Aladyshev Subject: [edk2-devel] [PATCH edk2-platforms v2 04/15] ManageabilityPkg: Check header fields in the MCTP response Date: Fri, 20 Oct 2023 15:52:51 +0300 Message-Id: <20231020125302.1459-5-aladyshev22@gmail.com> In-Reply-To: <20231020125302.1459-1-aladyshev22@gmail.com> References: <20231020125302.1459-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-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=Z0HWYjFJ; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io 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=0D );=0D =0D + MctpTransportResponseHeader =3D (MCTP_TRANSPORT_HEADER *)ResponseBuffer;= =0D + if (MctpTransportResponseHeader->Bits.HeaderVersion !=3D MCTP_KCS_HEADER= _VERSION) {=0D + DEBUG ((=0D + DEBUG_ERROR,=0D + "%a: Error! Response HeaderVersion (0x%02x) doesn't match MCTP_KCS_H= EADER_VERSION (0x%02x)\n",=0D + __func__,=0D + MctpTransportResponseHeader->Bits.HeaderVersion,=0D + MCTP_KCS_HEADER_VERSION=0D + ));=0D + FreePool (ResponseBuffer);=0D + return EFI_DEVICE_ERROR;=0D + }=0D + if (MctpTransportResponseHeader->Bits.MessageTag !=3D MCTP_MESSAGE_TAG) = {=0D + DEBUG ((=0D + DEBUG_ERROR,=0D + "%a: Error! Response MessageTag (0x%02x) doesn't match MCTP_MESSAGE_= TAG (0x%02x)\n",=0D + __func__,=0D + MctpTransportResponseHeader->Bits.MessageTag,=0D + MCTP_MESSAGE_TAG=0D + ));=0D + FreePool (ResponseBuffer);=0D + return EFI_DEVICE_ERROR;=0D + }=0D + if (MctpTransportResponseHeader->Bits.TagOwner !=3D MCTP_MESSAGE_TAG_OWN= ER_RESPONSE) {=0D + DEBUG ((=0D + DEBUG_ERROR,=0D + "%a: Error! Response TagOwner (0x%02x) doesn't match MCTP_MESSAGE_TA= G_OWNER_RESPONSE (0x%02x)\n",=0D + __func__,=0D + MctpTransportResponseHeader->Bits.TagOwner,=0D + MCTP_MESSAGE_TAG_OWNER_RESPONSE=0D + ));=0D + FreePool (ResponseBuffer);=0D + return EFI_DEVICE_ERROR;=0D + }=0D + if (MctpTransportResponseHeader->Bits.SourceEndpointId !=3D MctpDestinat= ionEndpointId) {=0D + DEBUG ((=0D + DEBUG_ERROR,=0D + "%a: Error! Response SrcEID (0x%02x) doesn't match sent EID (0x%02x)= \n",=0D + __func__,=0D + MctpTransportResponseHeader->Bits.SourceEndpointId,=0D + MctpDestinationEndpointId=0D + ));=0D + FreePool (ResponseBuffer);=0D + return EFI_DEVICE_ERROR;=0D + }=0D + if (MctpTransportResponseHeader->Bits.DestinationEndpointId !=3D MctpSou= rceEndpointId) {=0D + DEBUG ((=0D + DEBUG_ERROR,=0D + "%a: Error! Response DestEID (0x%02x) doesn't match local EID (0x%02= x)\n",=0D + __func__,=0D + MctpTransportResponseHeader->Bits.DestinationEndpointId,=0D + MctpSourceEndpointId=0D + ));=0D + FreePool (ResponseBuffer);=0D + return EFI_DEVICE_ERROR;=0D + }=0D +=0D + MctpMessageResponseHeader =3D (MCTP_MESSAGE_HEADER *)(MctpTransportRespo= nseHeader + 1);=0D + if (MctpMessageResponseHeader->Bits.MessageType !=3D MctpType) {=0D + DEBUG ((=0D + DEBUG_ERROR,=0D + "%a: Error! Response MessageType (0x%02x) doesn't match sent Message= Type (0x%02x)\n",=0D + __func__,=0D + MctpMessageResponseHeader->Bits.MessageType,=0D + MctpType=0D + ));=0D + FreePool (ResponseBuffer);=0D + return EFI_DEVICE_ERROR;=0D + }=0D +=0D + if (MctpMessageResponseHeader->Bits.IntegrityCheck !=3D (UINT8)RequestDa= taIntegrityCheck) {=0D + DEBUG ((=0D + DEBUG_ERROR,=0D + "%a: Error! Response IntegrityCheck (%d) doesn't match sent Integrit= yCheck (%d)\n",=0D + __func__,=0D + MctpMessageResponseHeader->Bits.IntegrityCheck,=0D + (UINT8)RequestDataIntegrityCheck=0D + ));=0D + FreePool (ResponseBuffer);=0D + return EFI_DEVICE_ERROR;=0D + }=0D +=0D //=0D // Return transfer status.=0D //=0D --=20 2.34.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#109854): https://edk2.groups.io/g/devel/message/109854 Mute This Topic: https://groups.io/mt/102080231/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-