From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail05.groups.io (mail05.groups.io [45.79.224.7]) by spool.mail.gandi.net (Postfix) with ESMTPS id 634BB941102 for ; Fri, 24 May 2024 04:24:10 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=39QbhR9+9rFjlUf3ImUSS/X9tLO/0B9vONZGkJXrOCw=; c=relaxed/simple; d=groups.io; h=From:To:CC:Subject:Thread-Topic:Thread-Index:Date:Message-ID:References:In-Reply-To:Accept-Language:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Resent-Date:Resent-From:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type:Content-Transfer-Encoding; s=20240206; t=1716524648; v=1; b=LbdRy/SqbxWJud1Fayu4kgjqc4a3mILG2K0RtbPT+txBbdVksjxjIoCP2XQCOl9wUmN/5mMW 7MDa5N0U7GSZtzL34sb5VTcbill+VHru1m0XM1TdADHr1LCMHwVB34fZtDHPC+E60ad+brOKgt5 o0ZvKzRLzRS+010unPY5v2VlpP1+hIcUuXodOgpzokgejse9zYTEOZ3zfVBkUW4EcwzECmQPBNO cpGEwhfEXTc+x82TVtEQedsXjaHXeeRdBaEj1IT7Bu3IZr+paAW7CeBxs8eORDl0flo1EaC5r8q inkNZQhOT4y5S2MTQt/fi0LI9aCUYtPqHE9sYMpMWH27Q== X-Received: by 127.0.0.2 with SMTP id GRKoYY7687511xXw9XjyadJa; Thu, 23 May 2024 21:24:08 -0700 X-Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.19]) by mx.groups.io with SMTP id smtpd.web10.8417.1716524647900844643 for ; Thu, 23 May 2024 21:24:07 -0700 X-CSE-ConnectionGUID: hoPjqGvGS0Cbm4Wy6OwODA== X-CSE-MsgGUID: PJ9Gb4qfS4yDLM1c/KGLKQ== X-IronPort-AV: E=McAfee;i="6600,9927,11081"; a="12736501" X-IronPort-AV: E=Sophos;i="6.08,184,1712646000"; d="scan'208";a="12736501" X-Received: from orviesa005.jf.intel.com ([10.64.159.145]) by orvoesa111.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 May 2024 21:24:07 -0700 X-CSE-ConnectionGUID: kK4WaQC7T9KtgVKKICm+YA== X-CSE-MsgGUID: ucN7IHTETR6kO3KbMtbHpw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,184,1712646000"; d="scan'208";a="38752856" X-Received: from fmsmsx602.amr.corp.intel.com ([10.18.126.82]) by orviesa005.jf.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 23 May 2024 21:24:08 -0700 X-Received: from fmsmsx611.amr.corp.intel.com (10.18.126.91) by fmsmsx602.amr.corp.intel.com (10.18.126.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 23 May 2024 21:24:06 -0700 X-Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx611.amr.corp.intel.com (10.18.126.91) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 23 May 2024 21:24:06 -0700 X-Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) by fmsmsx610.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39 via Frontend Transport; Thu, 23 May 2024 21:24:06 -0700 X-Received: from NAM02-DM3-obe.outbound.protection.outlook.com (104.47.56.41) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Thu, 23 May 2024 21:24:06 -0700 X-Received: from MW4PR11MB8291.namprd11.prod.outlook.com (2603:10b6:303:20d::14) by IA0PR11MB7258.namprd11.prod.outlook.com (2603:10b6:208:43d::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.22; Fri, 24 May 2024 04:24:03 +0000 X-Received: from MW4PR11MB8291.namprd11.prod.outlook.com ([fe80::fd81:328b:63fd:46f6]) by MW4PR11MB8291.namprd11.prod.outlook.com ([fe80::fd81:328b:63fd:46f6%5]) with mapi id 15.20.7611.016; Fri, 24 May 2024 04:24:03 +0000 From: "Saloni Kasbekar" To: Doug Flick , "devel@edk2.groups.io" CC: "Clark-williams, Zachary" Subject: Re: [edk2-devel] [PATCH v2 13/13] NetworkPkg: Update the PxeBcDhcp6GoogleTest due to underlying changes Thread-Topic: [PATCH v2 13/13] NetworkPkg: Update the PxeBcDhcp6GoogleTest due to underlying changes Thread-Index: AQHaodW51ZBA0CXn1Uabdz2PH+IARrGl4K1Q Date: Fri, 24 May 2024 04:24:03 +0000 Message-ID: References: <20240509055633.828642-1-doug.edk2@gmail.com> <20240509055633.828642-14-doug.edk2@gmail.com> In-Reply-To: <20240509055633.828642-14-doug.edk2@gmail.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: MW4PR11MB8291:EE_|IA0PR11MB7258:EE_ x-ms-office365-filtering-correlation-id: 6f1ff97c-605c-437f-937a-08dc7ba95815 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam-message-info: =?us-ascii?Q?3U+xXYT5dzSJ0z5wUj/gFE/802g4I55VwOLD7VN/fTeObMj9mMwAeJNIaFJe?= =?us-ascii?Q?80D2Q2PDOWx79EOm2XSngId/PH8usaP4Pejjh8oae7AaTVq3X4PjOlRckQew?= =?us-ascii?Q?AjAzWg+HUA2NkxuCwyrf3BrLUSrQ7UdvG3HvxNmkxptiQ13/vTp2HAVGYKJz?= =?us-ascii?Q?Ofzrpgg2OFhYK7Yw25PqGGzSOzmwf7VAc4Ea9Q6+fGpGMZaqDH+q5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NgVa6iBmpWQyEBFjik+rs+k8IkrMvHqDAa?= =?us-ascii?Q?g4yo8IDKBD/f/QrEbS/D2Mq2s/LY+MgoZL0wAhBnPWFp/F+NmPkKzxfcGBp/?= =?us-ascii?Q?ZQV5xuqu56Qjf5/+4JOQmOL6kKAoqk8nEo9TZgvnmCBcAXuxwYncey4n4RwX?= =?us-ascii?Q?i8fT4DjXRhkhVX47fFfwAT/CRJDp7UUVHrF+7jTUIpRWaofH2uLkuRnIGqig?= =?us-ascii?Q?yZErZMU3ytmDzLJYcEBBID2W/ifQF6l4QQ9lQjr9gZOYmA=3D=3D?= x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?14yIhVTA579a5TspkWBUhfweVH8NJQLJx1zcBNdwfyOt0OO2iArgWlcNTxcs?= =?us-ascii?Q?nMb+ThftXOp9+O7bRgyHuEajQDF7ZvRK+9bmJWO/LEo86Z1Bzpv0qFKa8qYd?= =?us-ascii?Q?pWl0/S3wXfd+nvcCqLaevMPXyH0TvJDtkNuvjx8Ckh+yv4kkr3dzZYkizUkD?= =?us-ascii?Q?5Fi8R4nyeEakaMcPhtuvYjw4xuUofClGhHc2MFXiPcWeB9xt3ZHk1xVM3vnU?= =?us-ascii?Q?s7g5qrKL3W/PxOSuvMqyvZ/9EEeZ9Pa3s6guFRTd07JERzdJ/CxQ0yY2HuLV?= =?us-ascii?Q?ChMvThrd43xDbWfEexAQQ4C9u0qBd84t2h/GLGtSySD3k4qihqi3FxQkXran?= =?us-ascii?Q?U+PG3VueQJb9B30st4FTqZ2cuJWGBarZYL4w3X6pepqGVYJA4WHr5HVZN+Vv?= =?us-ascii?Q?yu1xfeutGnVdDx4blIc+WNr/1LVIfF5IvDrSEDbpLwebu7wkK2gW9VLHt83r?= =?us-ascii?Q?55Rag0tCmjPQIOnNyHhQKEcpgDv1yeT/O3AZp2/1nGLTNPkOorwhM571L2Kj?= =?us-ascii?Q?6qEu7KmAo9SjnlBo2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= =?us-ascii?Q?vi+h5insVIqz7aW42L3RFcXH2p96ReVDipMWq6MzSsQqUD0zxjM6RBgUdggx?= =?us-ascii?Q?GZ2JlLsDsNyvq32ootXF9s5pHOTo0ZEQ5K1kgAJr1C2nTFD2Q6JIykC1LfFY?= =?us-ascii?Q?52Vb1dWX/1DRa9mvkJ3O1i6WIjW8RiYHwl/jxQ+D?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MW4PR11MB8291.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6f1ff97c-605c-437f-937a-08dc7ba95815 X-MS-Exchange-CrossTenant-originalarrivaltime: 24 May 2024 04:24:03.6895 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: aGNIEWGl5KJlFLqX1kecL98xyUQ6Xlmhf4/cRa5lQC/JEgzgn4I4NpJN+m5zRrG9qVyU54La2vhTsq7Xf48zJyEiKdmNXiDmW4Zl9GpSw2Y= X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR11MB7258 X-OriginatorOrg: intel.com 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 Resent-Date: Thu, 23 May 2024 21:24:08 -0700 Resent-From: saloni.kasbekar@intel.com Reply-To: devel@edk2.groups.io,saloni.kasbekar@intel.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: 13autwo7MQD1UPgNijNwAcA1x7686176AA= Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20240206 header.b="LbdRy/Sq"; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=intel.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 45.79.224.7 as permitted sender) smtp.mailfrom=bounce@groups.io Reviewed-by: Saloni Kasbekar -----Original Message----- From: Doug Flick =20 Sent: Wednesday, May 8, 2024 10:57 PM To: devel@edk2.groups.io Cc: Kasbekar, Saloni ; Clark-williams, Zachary <= zachary.clark-williams@intel.com> Subject: [PATCH v2 13/13] NetworkPkg: Update the PxeBcDhcp6GoogleTest due t= o underlying changes From: Doug Flick This patch updates the PxeBcDhcp6GoogleTest due to the changes in the under= lying code. The changes are as follows: - Random now comes from the RngLib Protocol - The TCP ISN is now generated by the hash function Cc: Saloni Kasbekar Cc: Zachary Clark-williams Signed-off-by: Doug Flick [MSFT] --- NetworkPkg/Test/NetworkPkgHostTest.dsc | 1 + NetworkPkg/UefiPxeBcDxe/GoogleTest/UefiPxeBcDxeGoogleTest.inf | 3 +- NetworkPkg/UefiPxeBcDxe/GoogleTest/PxeBcDhcp6GoogleTest.cpp | 102 ++++++= +++++++++++++- 3 files changed, 100 insertions(+), 6 deletions(-) diff --git a/NetworkPkg/Test/NetworkPkgHostTest.dsc b/NetworkPkg/Test/Netwo= rkPkgHostTest.dsc index fa301a7a52ab..1772afb05815 100644 --- a/NetworkPkg/Test/NetworkPkgHostTest.dsc +++ b/NetworkPkg/Test/NetworkPkgHostTest.dsc @@ -30,6 +30,7 @@ [Components] NetworkPkg/UefiPxeBcDxe/GoogleTest/UefiPxeBcDxeGoogleTest.inf { UefiRuntimeServicesTableLib|MdePkg/Test/Mock/Library/Goo= gleTest/MockUefiRuntimeServicesTableLib/MockUefiRuntimeServicesTableLib.inf= + UefiBootServicesTableLib|MdePkg/Test/Mock/Library/GoogleTest/MockUef= iBootServicesTableLib/MockUefiBootServicesTableLib.inf } # Despite these= library classes being listed in [LibraryClasses] below, they are not neede= d for the host-based unit tests.diff --git a/NetworkPkg/UefiPxeBcDxe/Google= Test/UefiPxeBcDxeGoogleTest.inf b/NetworkPkg/UefiPxeBcDxe/GoogleTest/UefiPx= eBcDxeGoogleTest.inf index 301dcdf61109..8b092d9291d4 100644 --- a/NetworkPkg/UefiPxeBcDxe/GoogleTest/UefiPxeBcDxeGoogleTest.inf +++ b/NetworkPkg/UefiPxeBcDxe/GoogleTest/UefiPxeBcDxeGoogleTest.inf @@ -14,7 +14,7 @@ [Defines] # # The following information is for reference only and not required by th= e build tools. #-# VALID_ARCHITECTURES =3D IA32 X64+# VALID_ARC= HITECTURES =3D IA32 X64 AARCH64 # [Sources]@@ -23,6 +23,7 @@ [So= urces] PxeBcDhcp6GoogleTest.h ../PxeBcDhcp6.c ../PxeBcSupport.c+ ../../../= MdePkg/Test/Mock/Library/GoogleTest/Protocol/MockRng.cpp [Packages] MdeP= kg/MdePkg.decdiff --git a/NetworkPkg/UefiPxeBcDxe/GoogleTest/PxeBcDhcp6Goog= leTest.cpp b/NetworkPkg/UefiPxeBcDxe/GoogleTest/PxeBcDhcp6GoogleTest.cpp index bd423ebadfce..61736ff79e83 100644 --- a/NetworkPkg/UefiPxeBcDxe/GoogleTest/PxeBcDhcp6GoogleTest.cpp +++ b/NetworkPkg/UefiPxeBcDxe/GoogleTest/PxeBcDhcp6GoogleTest.cpp @@ -7,6 +7,8 @@ #include #include #include +#inclu= de +#include extern "C" { #include @@ -165,7 +167,7 @@ p= rotected: // Note: // Testing PxeBcHandleDhcp6Offer() is difficult because it depend= s on a // properly setup Private structure. Attempting to properly test thi= s function-// without a signficant refactor is a fools errand. Instead, we = will test+// without a significant refactor is a fools errand. Instead, we = will test // that we can prevent an overflow in the function. TEST_F (PxeBc= HandleDhcp6OfferTest, BasicUsageTest) { PXEBC_DHCP6_PACKET_CACHE *Cache6= =3D NULL;@@ -238,6 +240,7 @@ TEST_F (PxeBcCacheDnsServerAddressesTest, Bas= icUsageTest) { FreePool (Option); } }+ // Test Description // Test that we can prev= ent an overflow in the function TEST_F (PxeBcCacheDnsServerAddressesTest, A= ttemptOverflowTest) {@@ -470,10 +473,15 @@ TEST_F (PxeBcRequestBootServiceT= est, AttemptRequestOverFlowExpectFailure) { class PxeBcDhcp6DiscoverTest : public ::testing::Test { public: PXEBC_PR= IVATE_DATA Private =3D { 0 };+ // create a mock md5 hash+ UINT8 Md5Hash[1= 6] =3D { 0 };+ EFI_UDP6_PROTOCOL Udp6Read; protected: MockUefiRuntimeS= ervicesTableLib RtServicesMock;+ MockUefiBootServicesTableLib BsMock;+ Mo= ckRng RngMock; // Add any setup code if needed virtual void@@ -527,8 += 535,21 @@ TEST_F (PxeBcDhcp6DiscoverTest, BasicOverflowTest) { Private.Dhcp6Request->Length =3D (UINT16)(Cursor - (UINT8 *)Private.Dhc= p6Request); - EXPECT_CALL (RtServicesMock, gRT_GetTime)- .WillOnce (::t= esting::Return (0));+ EXPECT_CALL (BsMock, gBS_LocateProtocol)+ .WillOn= ce (+ ::testing::DoAll (+ ::testing::SetArgPointee= <2> (::testing::ByRef (gRngProtocol)),+ ::testing::Retur= n (EFI_SUCCESS)+ )+ );++ EXPECT_CALL (RngMock, Ge= tRng)+ .WillOnce (+ ::testing::DoAll (+ ::testi= ng::SetArgPointee<3> (::testing::ByRef (Md5Hash[0])),+ := :testing::Return (EFI_SUCCESS)+ )+ ); ASSERT_EQ= ( PxeBcDhcp6Discover (@@ -558,8 +579,21 @@ TEST_F (PxeBcDhcp6DiscoverT= est, BasicUsageTest) { Private.Dhcp6Request->Length =3D (UINT16)(Cursor - (UINT8 *)Private.Dhc= p6Request); - EXPECT_CALL (RtServicesMock, gRT_GetTime)- .WillOnce (::t= esting::Return (0));+ EXPECT_CALL (BsMock, gBS_LocateProtocol)+ .WillOn= ce (+ ::testing::DoAll (+ ::testing::SetArgPointee= <2> (::testing::ByRef (gRngProtocol)),+ ::testing::Retur= n (EFI_SUCCESS)+ )+ );++ EXPECT_CALL (RngMock, Ge= tRng)+ .WillOnce (+ ::testing::DoAll (+ ::testi= ng::SetArgPointee<3> (::testing::ByRef (Md5Hash[0])),+ := :testing::Return (EFI_SUCCESS)+ )+ ); ASSERT_EQ= ( PxeBcDhcp6Discover (@@ -572,3 +606,61 @@ TEST_F (PxeBcDhcp6DiscoverT= est, BasicUsageTest) { EFI_SUCCESS ); }++TEST_F (PxeBcDhcp6DiscoverTest, MultipleRequests= AttemptOverflow) {+ EFI_IPv6_ADDRESS DestIp =3D { 0 };+ EFI_D= HCP6_PACKET_OPTION RequestOpt =3D { 0 }; // the data section doesn't reall= y matter++ RequestOpt.OpCode =3D HTONS (0x1337);+ RequestOpt.OpLen =3D H= TONS (REQUEST_OPTION_LENGTH); // this length would overflow without a check= + UINT8 RequestOptBuffer[REQUEST_OPTION_LENGTH] =3D { 0 };++ // make sur= e we have enough space for 10 of these options+ ASSERT_TRUE (REQUEST_OPTIO= N_LENGTH * 10 <=3D PACKET_SIZE);++ UINT8 Index =3D 0;+ EFI_= DHCP6_PACKET *Packet =3D (EFI_DHCP6_PACKET *)&Private.Dhcp6Request[Index];= + UINT8 *Cursor =3D (UINT8 *)(Packet->Dhcp6.Option);++ // let= 's add 10 of these options - this should overflow+ for (UINT8 i =3D 0; i <= 10; i++) {+ CopyMem (Cursor, &RequestOpt, sizeof (RequestOpt));+ Cur= sor +=3D sizeof (RequestOpt) - 1;+ CopyMem (Cursor, RequestOptBuffer, RE= QUEST_OPTION_LENGTH);+ Cursor +=3D REQUEST_OPTION_LENGTH;+ }++ // Upda= te the packet length+ Packet->Length =3D (UINT16)(Cursor - (UINT8 *)Packet= );+ Packet->Size =3D PACKET_SIZE;++ // Make sure we're larger than the = buffer we're trying to write into+ ASSERT_TRUE (Packet->Length > sizeof (E= FI_PXE_BASE_CODE_DHCPV6_PACKET));++ EXPECT_CALL (BsMock, gBS_LocateProtoco= l)+ .WillOnce (+ ::testing::DoAll (+ ::testing:= :SetArgPointee<2> (::testing::ByRef (gRngProtocol)),+ ::= testing::Return (EFI_SUCCESS)+ )+ );++ EXPECT_CAL= L (RngMock, GetRng)+ .WillOnce (+ ::testing::DoAll (+ = ::testing::SetArgPointee<3> (::testing::ByRef (Md5Hash[0])),+ = ::testing::Return (EFI_SUCCESS)+ )+ )= ;++ ASSERT_EQ (+ PxeBcDhcp6Discover (+ &(PxeBcDhcp6DiscoverTest::P= rivate),+ 0,+ NULL,+ FALSE,+ (EFI_IP_ADDRESS *)&DestIp+= ),+ EFI_OUT_OF_RESOURCES+ );+}--=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 (#119200): https://edk2.groups.io/g/devel/message/119200 Mute This Topic: https://groups.io/mt/105996592/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-