From: "Konstantin Aladyshev" <aladyshev22@gmail.com>
To: devel@edk2.groups.io
Cc: abner.chang@amd.com, isaac.w.oram@intel.com,
AbdulLateef.Attar@amd.com, nicklew@nvidia.com,
Konstantin Aladyshev <aladyshev22@gmail.com>
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 [thread overview]
Message-ID: <20231020125302.1459-5-aladyshev22@gmail.com> (raw)
In-Reply-To: <20231020125302.1459-1-aladyshev22@gmail.com>
Add checks for the MCTP header fields in the MCTP response.
Signed-off-by: Konstantin Aladyshev <aladyshev22@gmail.com>
---
.../MctpProtocol/Common/MctpProtocolCommon.c | 82 +++++++++++++++++++
1 file changed, 82 insertions(+)
diff --git a/Features/ManageabilityPkg/Universal/MctpProtocol/Common/MctpProtocolCommon.c b/Features/ManageabilityPkg/Universal/MctpProtocol/Common/MctpProtocolCommon.c
index e560c638d5..5844d54eb2 100644
--- a/Features/ManageabilityPkg/Universal/MctpProtocol/Common/MctpProtocolCommon.c
+++ b/Features/ManageabilityPkg/Universal/MctpProtocol/Common/MctpProtocolCommon.c
@@ -461,6 +461,88 @@ CommonMctpSubmitMessage (
&TransferToken
);
+ MctpTransportResponseHeader = (MCTP_TRANSPORT_HEADER *)ResponseBuffer;
+ if (MctpTransportResponseHeader->Bits.HeaderVersion != MCTP_KCS_HEADER_VERSION) {
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: Error! Response HeaderVersion (0x%02x) doesn't match MCTP_KCS_HEADER_VERSION (0x%02x)\n",
+ __func__,
+ MctpTransportResponseHeader->Bits.HeaderVersion,
+ MCTP_KCS_HEADER_VERSION
+ ));
+ FreePool (ResponseBuffer);
+ return EFI_DEVICE_ERROR;
+ }
+ if (MctpTransportResponseHeader->Bits.MessageTag != 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 != MCTP_MESSAGE_TAG_OWNER_RESPONSE) {
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: Error! Response TagOwner (0x%02x) doesn't match MCTP_MESSAGE_TAG_OWNER_RESPONSE (0x%02x)\n",
+ __func__,
+ MctpTransportResponseHeader->Bits.TagOwner,
+ MCTP_MESSAGE_TAG_OWNER_RESPONSE
+ ));
+ FreePool (ResponseBuffer);
+ return EFI_DEVICE_ERROR;
+ }
+ if (MctpTransportResponseHeader->Bits.SourceEndpointId != MctpDestinationEndpointId) {
+ 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 != MctpSourceEndpointId) {
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: Error! Response DestEID (0x%02x) doesn't match local EID (0x%02x)\n",
+ __func__,
+ MctpTransportResponseHeader->Bits.DestinationEndpointId,
+ MctpSourceEndpointId
+ ));
+ FreePool (ResponseBuffer);
+ return EFI_DEVICE_ERROR;
+ }
+
+ MctpMessageResponseHeader = (MCTP_MESSAGE_HEADER *)(MctpTransportResponseHeader + 1);
+ if (MctpMessageResponseHeader->Bits.MessageType != MctpType) {
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: Error! Response MessageType (0x%02x) doesn't match sent MessageType (0x%02x)\n",
+ __func__,
+ MctpMessageResponseHeader->Bits.MessageType,
+ MctpType
+ ));
+ FreePool (ResponseBuffer);
+ return EFI_DEVICE_ERROR;
+ }
+
+ if (MctpMessageResponseHeader->Bits.IntegrityCheck != (UINT8)RequestDataIntegrityCheck) {
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: Error! Response IntegrityCheck (%d) doesn't match sent IntegrityCheck (%d)\n",
+ __func__,
+ MctpMessageResponseHeader->Bits.IntegrityCheck,
+ (UINT8)RequestDataIntegrityCheck
+ ));
+ FreePool (ResponseBuffer);
+ return EFI_DEVICE_ERROR;
+ }
+
//
// Return transfer status.
//
--
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]
-=-=-=-=-=-=-=-=-=-=-=-
next prev parent reply other threads:[~2023-10-20 12:53 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-20 12:52 [edk2-devel] [PATCH edk2-platforms v2 00/15] MTCP-over-KCS support Konstantin Aladyshev
2023-10-20 12:52 ` [edk2-devel] [PATCH edk2-platforms v2 01/15] ManageabilityPkg: Add definition for the MCTP KCS TRAILER structure Konstantin Aladyshev
2023-10-20 12:52 ` [edk2-devel] [PATCH edk2-platforms v2 02/15] ManageabilityPkg: Check MCTP EIDs for reserved values Konstantin Aladyshev
2023-10-20 12:52 ` [edk2-devel] [PATCH edk2-platforms v2 03/15] ManageabilityPkg: Support both MCTP and IPMI in KCS tranport library Konstantin Aladyshev
2023-10-20 12:52 ` Konstantin Aladyshev [this message]
2023-10-20 12:52 ` [edk2-devel] [PATCH edk2-platforms v2 05/15] ManageabilityPkg: Correct typo in MCTP destination EID field Konstantin Aladyshev
2023-10-20 12:52 ` [edk2-devel] [PATCH edk2-platforms v2 06/15] ManageabilityPkg: Update the algorithm of using MCTP endpoint ID PCD Konstantin Aladyshev
2023-10-20 12:52 ` [edk2-devel] [PATCH edk2-platforms v2 07/15] ManageabilityPkg: Correct value for the MCTP TAG_OWNER response bit Konstantin Aladyshev
2023-10-20 12:52 ` [edk2-devel] [PATCH edk2-platforms v2 08/15] ManageabilityPkg: Don't check MCTP header fields if transfer has failed Konstantin Aladyshev
2023-10-20 12:52 ` [edk2-devel] [PATCH edk2-platforms v2 09/15] ManageabilityPkg: Use correct constants for PLDM header checks Konstantin Aladyshev
2023-10-20 12:52 ` [edk2-devel] [PATCH edk2-platforms v2 10/15] ManageabilityPkg: Return error on multiple-packet MCTP responses Konstantin Aladyshev
2023-10-20 12:52 ` [edk2-devel] [PATCH edk2-platforms v2 11/15] ManageabilityPkg: Add PLDM terminus PCDs Konstantin Aladyshev
2023-10-20 12:52 ` [edk2-devel] [PATCH edk2-platforms v2 12/15] PldmProtocolDxe: Correct TID argument usage Konstantin Aladyshev
2023-10-20 12:53 ` [edk2-devel] [PATCH edk2-platforms v2 13/15] ManageabilityPkg/PldmProtocol: Remove PLDM command table Konstantin Aladyshev
2023-10-20 12:53 ` [edk2-devel] [PATCH edk2-platforms v2 14/15] ManageabilityPkg: Return error on PLDM header check fails Konstantin Aladyshev
2023-10-20 12:53 ` [edk2-devel] [PATCH edk2-platforms v2 15/15] PldmSmbiosTransferDxe: Implement Set PLDM terminus ID API Konstantin Aladyshev
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231020125302.1459-5-aladyshev22@gmail.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox