From: "Chang, Abner via groups.io" <abner.chang=amd.com@groups.io>
To: <devel@edk2.groups.io>
Cc: Nickle Wang <nicklew@nvidia.com>,
Igor Kulchytskyy <igork@ami.com>,
Mike Maslenkin <mike.maslenkin@gmail.com>
Subject: [edk2-devel] [PATCH V3 6/9] RedfishPkg/RedfishDiscovery: Refine SMBIOS 42h code
Date: Mon, 27 Nov 2023 13:31:04 +0800 [thread overview]
Message-ID: <20231127053107.1686-7-abner.chang@amd.com> (raw)
In-Reply-To: <20231127053107.1686-1-abner.chang@amd.com>
From: Abner Chang <abner.chang@amd.com>
Refine SMBIOS 42h code add mode debug message
for the error conditions.
Signed-off-by: Abner Chang <abner.chang@amd.com>
Cc: Nickle Wang <nicklew@nvidia.com>
Cc: Igor Kulchytskyy <igork@ami.com>
Cc: Mike Maslenkin <mike.maslenkin@gmail.com>
---
.../RedfishDiscoverInternal.h | 2 ++
.../RedfishSmbiosHostInterface.c | 20 +++++++++++++++++--
2 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverInternal.h b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverInternal.h
index e27cfa76e39..de7faa4f975 100644
--- a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverInternal.h
+++ b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverInternal.h
@@ -42,6 +42,8 @@
#define MAC_COMPARE(This, Target) (CompareMem ((VOID *)&(This)->MacAddress, &(Target)->MacAddress, (This)->HwAddressSize) == 0)
#define VALID_TCP6(Target, This) ((Target)->IsIpv6 && ((This)->NetworkProtocolType == ProtocolTypeTcp6))
#define VALID_TCP4(Target, This) (!(Target)->IsIpv6 && ((This)->NetworkProtocolType == ProtocolTypeTcp4))
+#define REDFISH_HI_ITERFACE_SPECIFIC_DATA_LENGTH_OFFSET ((UINT16)(UINTN)(&((SMBIOS_TABLE_TYPE42 *)0)->InterfaceTypeSpecificDataLength))
+#define REDFISH_HI_PROTOCOL_HOSTNAME_LENGTH_OFFSET ((UINT16)(UINTN)(&((REDFISH_OVER_IP_PROTOCOL_DATA *)0)->RedfishServiceHostnameLength))
//
// GUID definitions
diff --git a/RedfishPkg/RedfishDiscoverDxe/RedfishSmbiosHostInterface.c b/RedfishPkg/RedfishDiscoverDxe/RedfishSmbiosHostInterface.c
index 0d6edc7dc35..57665f367be 100644
--- a/RedfishPkg/RedfishDiscoverDxe/RedfishSmbiosHostInterface.c
+++ b/RedfishPkg/RedfishDiscoverDxe/RedfishSmbiosHostInterface.c
@@ -56,7 +56,7 @@ RedfishGetHostInterfaceProtocolData (
mType42Record = (SMBIOS_TABLE_TYPE42 *)Record;
if (mType42Record->InterfaceType == MCHostInterfaceTypeNetworkHostInterface) {
ASSERT (Record->Length >= 9);
- Offset = 5;
+ Offset = REDFISH_HI_ITERFACE_SPECIFIC_DATA_LENGTH_OFFSET;
RecordTmp = (UINT8 *)Record + Offset;
//
// Get interface specific data length.
@@ -70,11 +70,13 @@ RedfishGetHostInterfaceProtocolData (
//
if ((*RecordTmp == REDFISH_HOST_INTERFACE_DEVICE_TYPE_PCI_PCIE_V2) || (*RecordTmp == REDFISH_HOST_INTERFACE_DEVICE_TYPE_USB_V2)) {
if (*RecordTmp == REDFISH_HOST_INTERFACE_DEVICE_TYPE_PCI_PCIE_V2) {
+ // According to Redfish Host Interface specification, add additional one byte for Device Type field.
if (SpecificDataLen != sizeof (PCI_OR_PCIE_INTERFACE_DEVICE_DESCRIPTOR_V2) + 1) {
ASSERT (SpecificDataLen == sizeof (PCI_OR_PCIE_INTERFACE_DEVICE_DESCRIPTOR_V2) + 1);
return EFI_VOLUME_CORRUPTED;
}
} else {
+ // According to Redfish Host Interface specification, add additional one byte for Device Type field.
if (SpecificDataLen != sizeof (USB_INTERFACE_DEVICE_DESCRIPTOR_V2) + 1) {
ASSERT (SpecificDataLen == sizeof (USB_INTERFACE_DEVICE_DESCRIPTOR_V2) + 1);
return EFI_VOLUME_CORRUPTED;
@@ -105,7 +107,14 @@ RedfishGetHostInterfaceProtocolData (
// This SMBIOS record is invalid, if the length of protocol specific data for
// Redfish Over IP protocol is wrong.
//
- if ((*(RecordTmp + 90) + sizeof (REDFISH_OVER_IP_PROTOCOL_DATA) - 1) != ProtocolLength) {
+ if ((*(RecordTmp + REDFISH_HI_PROTOCOL_HOSTNAME_LENGTH_OFFSET) + sizeof (REDFISH_OVER_IP_PROTOCOL_DATA) - 1) != ProtocolLength) {
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: Length of protocol specific data is not match: %d != ProtocolLength(%d).\n",
+ __func__,
+ *(RecordTmp + REDFISH_HI_PROTOCOL_HOSTNAME_LENGTH_OFFSET) + sizeof (REDFISH_OVER_IP_PROTOCOL_DATA) - 1,
+ ProtocolLength
+ ));
return EFI_SECURITY_VIOLATION;
}
@@ -114,6 +123,13 @@ RedfishGetHostInterfaceProtocolData (
// This SMBIOS record is invalid, if the length is smaller than the offset.
//
if (Offset > mType42Record->Hdr.Length) {
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: Offset (%d) > mType42Record->Hdr.Length (%d).\n",
+ __func__,
+ Offset,
+ mType42Record->Hdr.Length
+ ));
return EFI_SECURITY_VIOLATION;
}
--
2.37.1.windows.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#111723): https://edk2.groups.io/g/devel/message/111723
Mute This Topic: https://groups.io/mt/102824323/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-11-27 5:31 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-27 5:30 [edk2-devel] [PATCH V3 0/9] Refine BMC USB NIC discovery and Redfish service enablement Chang, Abner via groups.io
2023-11-27 5:30 ` [edk2-devel] [PATCH V3 1/9] RedfishPkg/BmcUsbNicLib: Update BMC USB NIC searching algorithm Chang, Abner via groups.io
2023-12-01 23:27 ` Igor Kulchytskyy via groups.io
2023-11-27 5:31 ` [edk2-devel] [PATCH V3 2/9] RedfishPkg/RedfishHostInterfaceDxe: Add Redfish HI readiness notification Chang, Abner via groups.io
2023-12-04 7:16 ` Nickle Wang via groups.io
2023-11-27 5:31 ` [edk2-devel] [PATCH V3 3/9] RedfishPkg/RedfishConfigHandler: Use " Chang, Abner via groups.io
2023-12-04 7:17 ` Nickle Wang via groups.io
2023-11-27 5:31 ` [edk2-devel] [PATCH V3 4/9] RedfishPkg/RedfishConfigHandler: Correct the prototype of callback function Chang, Abner via groups.io
2023-12-04 7:17 ` Nickle Wang via groups.io
2023-11-27 5:31 ` [edk2-devel] [PATCH V3 5/9] RedfishPkg/RedfishDiscovery: Add more debug message Chang, Abner via groups.io
2023-12-04 7:18 ` Nickle Wang via groups.io
2023-11-27 5:31 ` Chang, Abner via groups.io [this message]
2023-12-04 7:18 ` [edk2-devel] [PATCH V3 6/9] RedfishPkg/RedfishDiscovery: Refine SMBIOS 42h code Nickle Wang via groups.io
2023-11-27 5:31 ` [edk2-devel] [PATCH V3 7/9] RedfishPkg/HostInterfaceBmcUsbNic: Fix incorrect reference of MAC address pointer Chang, Abner via groups.io
2023-12-04 7:19 ` Nickle Wang via groups.io
2023-11-27 5:31 ` [edk2-devel] [PATCH V3 8/9] RedfishPkg/HostInterfaceBmcUsbNic: Fix incorrect HI protocol record size Chang, Abner via groups.io
2023-12-04 7:19 ` Nickle Wang via groups.io
2023-11-27 5:31 ` [edk2-devel] [PATCH V3 9/9] RedfishPkg/HostInterfaceBmcUsbNic: Fix potential memory corruption issue Chang, Abner via groups.io
2023-12-04 7:20 ` Nickle Wang via groups.io
[not found] ` <179B63DFD0330B10.32091@groups.io>
2023-12-04 7:14 ` [edk2-devel] [PATCH V3 1/9] RedfishPkg/BmcUsbNicLib: Update BMC USB NIC searching algorithm Nickle Wang via groups.io
2023-12-04 7:18 ` [edk2-devel] [PATCH V3 0/9] Refine BMC USB NIC discovery and Redfish service enablement Mike Maslenkin
2023-12-04 9:08 ` Chang, Abner via groups.io
2023-12-04 10:59 ` Mike Maslenkin
2023-12-05 1:49 ` Chang, Abner via groups.io
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=20231127053107.1686-7-abner.chang@amd.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