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 07265AC0CB0 for ; Thu, 23 Nov 2023 06:48:19 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=9EPuRQ1w4gjmYxT+Y0dfllGr7OnmPXLFWDkkVCtVM2A=; c=relaxed/simple; d=groups.io; h=ARC-Seal:ARC-Message-Signature:ARC-Authentication-Results:Received-SPF: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:Content-Type; s=20140610; t=1700722098; v=1; b=xBbg3fQDnLh/WXB+2BGE2YIeeI+dYWDRWX95m4jbFewi6UHEufaJRFBvnAKWLqv4LStuwMUV 6fdVWzB+Iq/pFpKcEunGwaCg8DZXniV4kliuvXXzPyvW7dHvqJOhbFccLTPR4GUTsYUd2tM9gEK z4mioILFDjkEYLueUcEj4mi8= X-Received: by 127.0.0.2 with SMTP id F1pbYY7687511xd0YI6XyvJh; Wed, 22 Nov 2023 22:48:18 -0800 X-Received: from NAM12-BN8-obe.outbound.protection.outlook.com (NAM12-BN8-obe.outbound.protection.outlook.com [40.107.237.51]) by mx.groups.io with SMTP id smtpd.web11.86155.1700722097770600370 for ; Wed, 22 Nov 2023 22:48:17 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nF0rhBu38eXZ3xBz6211wxdkbmPjxIeIZAuaGeIb/7AhoGfrI1ENYa+HYLtIz+7ZFyXCX2ggNsdbl0synW/vQLKLNg5ajkXvX4o9HlYEx+I2UFjQiAB0SG+9tLD9w2vecbKHSjoRO4TTBE9/8ntc0/rayYj8+3NBuDiPXmdweLhIRdcrX2/X1vjMZTUVBc2Q4mRfno5TCLOx2l5m0iyMVGHVCqXun8m8wRtWNUr+ntYngkzAkAwztqeeR8MJEpv1vdkLz4iV7hZJSHJfSLEFWJfUnCzV5Ql/jQV7q6KaRbMf5Qp5gpv7jDpmYltqoVBeeJ7welZHOeHWqcWOk0Y2ew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=+RBfbNXnAX9ZF54r68/ys7DVXUHO72MsJoh15v2+Mi0=; b=Hj7x9ywibUUJilIaNvsmJswCBHhljXsxIRVAlnaUDwDlJABkw4UUggJ55W5pBs1av41AjElzm3hXETY87tsJUfWL4RRONSVNBoa32swcU4d9DGxPfHGRRU9ZIVhs87AOa0kahpDnpTe0BeFKgzYfVv3kGJ06ht4KWeREI2ioHUfzYRDydHsrTMVdBOd77sXNqzGXvUXhlUlJnIO1Ra9y2cShGWw2kuUMKjZ+hCgk03FAThDUhbsnDxi23jnc4VCaSDSNN/nl9nKF8QJpzrDqoR537nUJSqrafnNazstSzJ6ENy72OtEzSmJorcJb9xkTpOlgaT8k2YGXElQ0rCtYaA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) X-Received: from DM6PR07CA0046.namprd07.prod.outlook.com (2603:10b6:5:74::23) by CH3PR12MB9121.namprd12.prod.outlook.com (2603:10b6:610:1a1::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.19; Thu, 23 Nov 2023 06:48:13 +0000 X-Received: from DS1PEPF00017094.namprd03.prod.outlook.com (2603:10b6:5:74:cafe::51) by DM6PR07CA0046.outlook.office365.com (2603:10b6:5:74::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.18 via Frontend Transport; Thu, 23 Nov 2023 06:48:13 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C X-Received: from SATLEXMB04.amd.com (165.204.84.17) by DS1PEPF00017094.mail.protection.outlook.com (10.167.17.137) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7025.12 via Frontend Transport; Thu, 23 Nov 2023 06:48:13 +0000 X-Received: from TPE-L1-ABNCHANG.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Thu, 23 Nov 2023 00:48:07 -0600 From: "Chang, Abner via groups.io" To: CC: Nickle Wang , Igor Kulchytskyy , Mike Maslenkin Subject: [edk2-devel] [PATCH V2 6/8] RedfishPkg/RedfishDiscovery: Refine SMBIOS 42h code Date: Thu, 23 Nov 2023 14:47:16 +0800 Message-ID: <20231123064719.1248-7-abner.chang@amd.com> In-Reply-To: <20231123064719.1248-1-abner.chang@amd.com> References: <20231123064719.1248-1-abner.chang@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF00017094:EE_|CH3PR12MB9121:EE_ X-MS-Office365-Filtering-Correlation-Id: 4e9260a8-ab16-48e9-99d8-08dbebf02a0b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: FzIU9o/pWnuqYTJI56bHXMAp9kI5pwv7m2gUuOsEmuew5Al3sQUNTAj3bMbEjPT68jFspl0f+BooqOFIUKffskIbGMVFRhL4VYaWG33pDORc5AR4bY++xlMzPMypS8V/Bl+A95xP8jcYDQ7JIqgnZV5xDJ1cfXB+dgdt5bqC8aAgFfFkJ42zD86NRSheaSAg8ghYrJ1TovcLP26oICMGrQ9yRH5KFKnAJ7QUM7PkQKBKJJxh5AFUg6nK92rJJJsUoMaG6PlwHRsv7Ej+aMHOjMy21h0vLPq3tMsbJskIlItYQJesnZzF4L5xcxPDP9qeU3ZskqfKWT7cNOkNTV0EqKU4BM/LQ5tAsGbg+nayJi0c05YCNyIJWq9uIJTgkIqWj74wxIg00lj6Rpk4EV0iIqUtP6Wf0+3wtnMsfwCEaiVhJgry5nwSpfPuSgBx28T0d+jsFjDQC5mxhZrHBwdviGBd2DXRLr+hA9LFeV4i963AMkjMluoygPpDkfNVpjiv9KJN8INEd6+QRPNMne812mYKtIns5aGzuGZEOQ+qQGXRTljhX8pqWZohhPOlso4OKWhLamkXBnie+6dxuYxuJrWM2eAQEDaLeI2Z66GfVPyEXSUlZykh/6FLE4KGM5+010c3M2G8BaQBXRpmjk4dg/6UqECqlNNlCmBAfUZFNqDGjeQuHA1LDpGf+pNED93AVdYD7jG5dQvALdm8YmGR8xhlOeXaVHghXWZJvrg0vgss9A7GYf0ixFsvtIBcnyClX0pkQlpkrnOci/e5wMLnzmjmiVRzyo4+RGOKcbU5+7E= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Nov 2023 06:48:13.1263 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4e9260a8-ab16-48e9-99d8-08dbebf02a0b X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DS1PEPF00017094.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB9121 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,abner.chang@amd.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: YVchcInDkxN91QyDE75luv92x7686176AA= Content-Transfer-Encoding: quoted-printable Content-Type: text/plain X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=xBbg3fQD; arc=reject ("signature check failed: fail, {[1] = sig:microsoft.com:reject}"); dmarc=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 From: Abner Chang Refine SMBIOS 42h code add mode debug message for the error conditions. Signed-off-by: Abner Chang Cc: Nickle Wang Cc: Igor Kulchytskyy Cc: Mike Maslenkin --- .../RedfishDiscoverInternal.h | 2 ++ .../RedfishSmbiosHostInterface.c | 20 +++++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverInternal.h b/Redf= ishPkg/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)->MacAddres= s, &(Target)->MacAddress, (This)->HwAddressSize) =3D=3D 0) #define VALID_TCP6(Target, This) ((Target)->IsIpv6 && ((This)->NetworkPr= otocolType =3D=3D ProtocolTypeTcp6)) #define VALID_TCP4(Target, This) (!(Target)->IsIpv6 && ((This)->NetworkP= rotocolType =3D=3D 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)) =20 // // GUID definitions diff --git a/RedfishPkg/RedfishDiscoverDxe/RedfishSmbiosHostInterface.c b/R= edfishPkg/RedfishDiscoverDxe/RedfishSmbiosHostInterface.c index 0d6edc7dc35..57665f367be 100644 --- a/RedfishPkg/RedfishDiscoverDxe/RedfishSmbiosHostInterface.c +++ b/RedfishPkg/RedfishDiscoverDxe/RedfishSmbiosHostInterface.c @@ -56,7 +56,7 @@ RedfishGetHostInterfaceProtocolData ( mType42Record =3D (SMBIOS_TABLE_TYPE42 *)Record; if (mType42Record->InterfaceType =3D=3D MCHostInterfaceTypeNetworkHo= stInterface) { ASSERT (Record->Length >=3D 9); - Offset =3D 5; + Offset =3D REDFISH_HI_ITERFACE_SPECIFIC_DATA_LENGTH_OFFSET; RecordTmp =3D (UINT8 *)Record + Offset; // // Get interface specific data length. @@ -70,11 +70,13 @@ RedfishGetHostInterfaceProtocolData ( // if ((*RecordTmp =3D=3D REDFISH_HOST_INTERFACE_DEVICE_TYPE_PCI_PCIE= _V2) || (*RecordTmp =3D=3D REDFISH_HOST_INTERFACE_DEVICE_TYPE_USB_V2)) { if (*RecordTmp =3D=3D REDFISH_HOST_INTERFACE_DEVICE_TYPE_PCI_PCI= E_V2) { + // According to Redfish Host Interface specification, add addi= tional one byte for Device Type field. if (SpecificDataLen !=3D sizeof (PCI_OR_PCIE_INTERFACE_DEVICE_= DESCRIPTOR_V2) + 1) { ASSERT (SpecificDataLen =3D=3D sizeof (PCI_OR_PCIE_INTERFACE= _DEVICE_DESCRIPTOR_V2) + 1); return EFI_VOLUME_CORRUPTED; } } else { + // According to Redfish Host Interface specification, add addi= tional one byte for Device Type field. if (SpecificDataLen !=3D sizeof (USB_INTERFACE_DEVICE_DESCRIPT= OR_V2) + 1) { ASSERT (SpecificDataLen =3D=3D 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 sp= ecific data for // Redfish Over IP protocol is wrong. // - if ((*(RecordTmp + 90) + sizeof (REDFISH_OVER_IP_PROTOCOL_DATA= ) - 1) !=3D ProtocolLength) { + if ((*(RecordTmp + REDFISH_HI_PROTOCOL_HOSTNAME_LENGTH_OFFSET)= + sizeof (REDFISH_OVER_IP_PROTOCOL_DATA) - 1) !=3D ProtocolLength) { + DEBUG (( + DEBUG_ERROR, + "%a: Length of protocol specific data is not match: %d != =3D ProtocolLength(%d).\n", + __func__, + *(RecordTmp + REDFISH_HI_PROTOCOL_HOSTNAME_LENGTH_OFFSET) = + sizeof (REDFISH_OVER_IP_PROTOCOL_DATA) - 1, + ProtocolLength + )); return EFI_SECURITY_VIOLATION; } =20 @@ -114,6 +123,13 @@ RedfishGetHostInterfaceProtocolData ( // This SMBIOS record is invalid, if the length is smaller tha= n 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; } =20 --=20 2.37.1.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 (#111662): https://edk2.groups.io/g/devel/message/111662 Mute This Topic: https://groups.io/mt/102763124/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-