From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (EUR05-VI1-obe.outbound.protection.outlook.com [40.107.21.56]) by mx.groups.io with SMTP id smtpd.web11.8011.1688717806016851113 for ; Fri, 07 Jul 2023 01:16:46 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=LzroukAm; spf=pass (domain: arm.com, ip: 40.107.21.56, mailfrom: sami.mujawar@arm.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=sPSASfELqEvjRYkaGAL/foLRhWMo/R/UhEfMLGvL+Rc=; b=LzroukAmfGf5WOiJ0opS5YOrkrjNOjYUYAB7NJpr3bj0o9MrJGjMixUYvaKiy0jle8HqqWhbUCsVL65pxZH8R4bIHVC6H315RI9+a9viiGUuEPkyBH9zjllqQdfg9LQ/E3xmkX/cmYd0b9NrSTWCAyVZ05rxawm5TgL5FT7KR7Q= Received: from AS9PR06CA0004.eurprd06.prod.outlook.com (2603:10a6:20b:462::20) by AS8PR08MB9290.eurprd08.prod.outlook.com (2603:10a6:20b:5a5::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.17; Fri, 7 Jul 2023 08:16:42 +0000 Received: from AM7EUR03FT056.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:462:cafe::4d) by AS9PR06CA0004.outlook.office365.com (2603:10a6:20b:462::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.25 via Frontend Transport; Fri, 7 Jul 2023 08:16:42 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; pr=C Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM7EUR03FT056.mail.protection.outlook.com (100.127.140.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.25 via Frontend Transport; Fri, 7 Jul 2023 08:16:42 +0000 Received: ("Tessian outbound 997ae1cc9f47:v145"); Fri, 07 Jul 2023 08:16:41 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: e7c63165954e89bd X-CR-MTA-TID: 64aa7808 Received: from a8f9d8793e2d.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id D79D43E1-ADA4-442C-BE0A-28244240B178.1; Fri, 07 Jul 2023 08:16:30 +0000 Received: from EUR04-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id a8f9d8793e2d.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 07 Jul 2023 08:16:30 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=acMZbGV5bZWEFRswNImAclb4r1Y6gu9XuGppSLvJEFqHBNi9GQ205F9eDHy2P7nVcOLiyzM8QK4Zoez9SylQDUtRfQWMc+K1kB1EH78J/0eyIeCuxKnekq/LGJ/hDFGAQ1a74IdJUgZE9qbSx90jp4IOJR/IKY5Bw7pDd3g5qxv4S8E3/naF164ahS6LXb2763DZa6GlDj1zX8WMmogQs5aa411AG+KDwP3peaBwJMUYvx1ZMfj9vuyFBv33k3DXrTCbCdF1ewtZBqk0toLUueMDR0vzjy2fRSnYAdbXzdHQhb6mxyM/zf7S0cHbikfrMEbBT3g5zFjBtRrBVeAXdw== 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=sPSASfELqEvjRYkaGAL/foLRhWMo/R/UhEfMLGvL+Rc=; b=Q4c3xbgGwEGgD+pyzNiRHHIX3zCjD1ALmDyJaYF1jMrrfSVj+noxcR0dFMgBd196L3nt1yTSNT5vqfpznbi1bO3t+daAQgjspp31YfdOP9meVNZ5Z15LbljIMskHjyUJ6ovtI51Riy8lA/QRbphcDwIb81FTtSaGDqTbPDVselJOzd/rgDMo1wUpa7P3C7FUfFn59FecBqj/V3970TNShoRtYzLcEBzvKL7+tPBta8dY1borp8ctyw29i1EKIMPY5murOuYddAc+FZTmGXqYkmEv3XNBN2bRaC+Xu2HsUF6qgk/qN7zUWnZUVr+q6OBCuvzewxUJLIPJGNXQtepABg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=sPSASfELqEvjRYkaGAL/foLRhWMo/R/UhEfMLGvL+Rc=; b=LzroukAmfGf5WOiJ0opS5YOrkrjNOjYUYAB7NJpr3bj0o9MrJGjMixUYvaKiy0jle8HqqWhbUCsVL65pxZH8R4bIHVC6H315RI9+a9viiGUuEPkyBH9zjllqQdfg9LQ/E3xmkX/cmYd0b9NrSTWCAyVZ05rxawm5TgL5FT7KR7Q= Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Received: from AS8PR08MB6806.eurprd08.prod.outlook.com (2603:10a6:20b:39b::12) by DBAPR08MB5656.eurprd08.prod.outlook.com (2603:10a6:10:1a2::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.25; Fri, 7 Jul 2023 08:16:27 +0000 Received: from AS8PR08MB6806.eurprd08.prod.outlook.com ([fe80::8ef4:aa57:6248:7850]) by AS8PR08MB6806.eurprd08.prod.outlook.com ([fe80::8ef4:aa57:6248:7850%4]) with mapi id 15.20.6565.016; Fri, 7 Jul 2023 08:16:27 +0000 Message-ID: Date: Fri, 7 Jul 2023 09:16:25 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 Subject: Re: [edk2-devel] [PATCH v2 1/1] SecurityPkg: RngDxe: Fixing mAvailableAlgoArray allocator To: Kun Qin , devel@edk2.groups.io, Ard Biesheuvel , Jiewen Yao , Jian J Wang , michael.d.kinney@intel.com, gaoliming@byosoft.com.cn, zhiguang.liu@intel.com CC: Pierre Gondois , "nd@arm.com" References: <20230629235919.2077-1-kuqin12@gmail.com> <176D46B1D9752C4A.23465@groups.io> <208c571d-a05e-e3c7-b94d-9e9b25f27f0c@gmail.com> From: "Sami Mujawar" In-Reply-To: <208c571d-a05e-e3c7-b94d-9e9b25f27f0c@gmail.com> X-ClientProxiedBy: LO4P123CA0563.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:33b::11) To AS8PR08MB6806.eurprd08.prod.outlook.com (2603:10a6:20b:39b::12) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: AS8PR08MB6806:EE_|DBAPR08MB5656:EE_|AM7EUR03FT056:EE_|AS8PR08MB9290:EE_ X-MS-Office365-Filtering-Correlation-Id: 05755eb5-d157-42ef-3c30-08db7ec27eea x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: dB/c9sh7AzPTYakOev4dD9XvqpLKaSde+s2lEwj6v3yrDuL0NVjnWsV1e0CRHdmYDnr9ywNVgw9PGgIfVVQrc0dB73KuSVS6xv8GmU2d7Jz9JqpQ9pFwJterU2cFGGLLcVzfXmZnE7aX07LWqwnDc7bz5SHi0aHu5kYcF70RLsOdtPd71YWlrkdXw8forXq+yCmi7w8u8Z2Me5OSvbkJ31Ucgvm7Jp22PMeBKOGDT1IeDZP30npcK+mu8rfAnxtfIW8bpW+YDZZOAI5yoimXX4800rDsLfZdmnm5quuH+huHitIGI+Iv9UFrWWwbTEkIP3/d78ogyyBIlF94BgMwM86gw80/iG56irLqqF/btwPOW8n9wmKNiLkWCA3xu8zgexXqq6k1o0h+ECFF+ynXE9qJot6p40loHAd8u9H8hL30UeMl5+0D2RRDqOAJ7G5jBf7yqNKgrC9zDO6ItjDWKnGlPsrA5+nLpG+90ftacNeIm98mSIbhQcq5fmDm9kCaPskBrjjwCMNw4ISBzWgQZDT2497PchDWOo+RwfE6XDirr3y3rdKXU5LYx/F9R2cbT0TcCD15jTynENCwrTU7Ino0eoMyaD/mEbJeXDWD1GoVwtlXWQGKxV7V8S42u5oqLFspohTlkrmqNfj+UGj095WHI0qZbrRUzWtO3JjN6vXHubeAtxlAl7a1FMCol7RUt6S1P8UjETK+4PbqZX232A== X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AS8PR08MB6806.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(366004)(346002)(376002)(396003)(39860400002)(136003)(451199021)(66946007)(66556008)(66476007)(4326008)(2616005)(38100700002)(86362001)(186003)(31696002)(26005)(53546011)(6506007)(83380400001)(45080400002)(36756003)(478600001)(6512007)(966005)(6486002)(54906003)(110136005)(44832011)(41300700001)(31686004)(5660300002)(15650500001)(8936002)(8676002)(2906002)(316002)(145543001)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR08MB5656 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Return-Path: Sami.Mujawar@arm.com X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT056.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: c83ed0ba-f5fa-438b-86cd-08db7ec27607 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: r7Yw5AYz4cJcEkt6BIlJZQpP7sc99QYAF/vrGBmLuLtSt//1oCzE0+mpLI3/6odFK7MML3b5IlyjGMtBYQXZpHxZ1Uc0yYnQdWDV9KN4ofqtAt4yH8JMxeX+zBDNc6MKOR429Kv5lysSySYz/H0qtnkxJcixNXLxLnLPzvvgATOo0nopcs41wuKHsxVcOCmP13mOATI17L8Ge7awhDer6+gckJq0Yev+UQS4b2ReKk1+Rh29VzDxgW7MowWrXWFQbu0MKh1sBao+9+IUjn18EnJlxIISOQTpPBufNkVQIM08JazWvIiUu9wQhqUj7FRezBeX4HtUV4L0iKiVXee7A6a8qPAMuOg6gjQRNwU6zarPCgEZlC6pQGXz7KqeDD5Q8s0KjSYNYb560T0KbAVg6t0TGRCWi9afB63jZU3BYOPDYkEp+xxBDmoEeTQAji8E1JcZbEK2hwxc8/OFzmAuz3IeBoubUg6R8zOgi3NAc2l8afX+N1RlV+Ua4LPTTSoJyX0tDaKCiYnRN8X4+MXbWwWg9WrYLJoSIuctMxxTj8jxtmvQdAwvPmk8Aw5N5kXqGIYpkRElgNFpBn/ccGuZi3mOs0Z8wbIF9zWp53Ka7hhglSw9JqpzE0zBWX90SHUQcLisUoB0CTwKTn9cWmhaBvT1pB3GStOEWRpxNAT5HR3/HQotniyrn4INYzCou+rDp5o36ReSGWoeuWZI1NZ1F0kaQz2QLulcEkXbULUQkd0QHGC4NZnRVK6dibbtye5u2ln3ZrbVVSQlZvC/dHYbmROclmKjgVsg0q+LmaSTY72cb6uCEDlFGLdPslQ7Ab6muvFcXCl8K46Lm12GQa5LLQ== X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(13230028)(4636009)(396003)(376002)(136003)(346002)(39860400002)(451199021)(36840700001)(40470700004)(46966006)(31686004)(82310400005)(15650500001)(2906002)(8676002)(478600001)(86362001)(31696002)(36860700001)(40480700001)(2616005)(5660300002)(8936002)(6506007)(44832011)(53546011)(26005)(110136005)(186003)(6486002)(6512007)(336012)(966005)(45080400002)(54906003)(40460700003)(83380400001)(356005)(47076005)(4326008)(36756003)(316002)(70206006)(81166007)(70586007)(82740400003)(41300700001)(145543001)(43740500002);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jul 2023 08:16:42.0467 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 05755eb5-d157-42ef-3c30-08db7ec27eea X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: AM7EUR03FT056.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB9290 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable Hi Kun, This patch and Pierre's series at=20 https://edk2.groups.io/g/devel/message/106711 are both required to fix=20 the RNG implementation for Arm. I will wait for the MdePkg and SecurityPkg maintainers for any feedback=20 by end of next week. If there are no futher comments, I will merge both=20 this patch and the series at https://edk2.groups.io/g/devel/message/106711. Regards, Sami Mujawar On 03/07/2023 09:09 pm, Kun Qin wrote: > Hi Sami, > > Would you prefer to have input from Jiewen or Jian to review this=20 > patch as well? > > Otherwise, would you mind helping me to merge the change? > > Thanks in advance! > > Regards, > Kun > > On 6/29/2023 4:59 PM, Kun Qin via groups.io wrote: >> From: Kun Qin >> >> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4491 >> >> mAvailableAlgoArray is currently allocated for "RNG_AVAILABLE_ALGO_MAX" >> number of bytes, whereas it was dereferenced as "EFI_RNG_ALGORITHM". >> >> This change fixed the buffer allocation logic by allocating a proper=20 >> size >> of buffer before referencing. >> >> Cc: Jiewen Yao >> Cc: Jian J Wang >> Cc: Sami Mujawar >> Cc: Pierre Gondois >> >> Signed-off-by: Kun Qin >> Reviewed-by: Sami Mujawar >> --- >> >> Notes: >> =C2=A0=C2=A0=C2=A0=C2=A0 v2: >> =C2=A0=C2=A0=C2=A0=C2=A0 - Added reviewed-by tag [Sami] >> >> =C2=A0 SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/AArch64Algo.c | = 2 +- >> =C2=A0 SecurityPkg/RandomNumberGenerator/RngDxe/Arm/ArmAlgo.c | 2 +- >> =C2=A0 2 files changed, 2 insertions(+), 2 deletions(-) >> >> diff --git=20 >> a/SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/AArch64Algo.c=20 >> b/SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/AArch64Algo.c >> index e8be217f8a8c..e7107a0b7039 100644 >> --- a/SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/AArch64Algo.c >> +++ b/SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/AArch64Algo.c >> @@ -33,7 +33,7 @@ GetAvailableAlgorithms ( >> =C2=A0=C2=A0=C2=A0 UINT16=C2=A0 MinorRevision; >> >> >> =C2=A0=C2=A0=C2=A0 // Rng algorithms 2 times, one for the allocation, on= e to populate. >> >> -=C2=A0 mAvailableAlgoArray =3D AllocateZeroPool (RNG_AVAILABLE_ALGO_MAX= ); >> >> +=C2=A0 mAvailableAlgoArray =3D AllocateZeroPool (RNG_AVAILABLE_ALGO_MAX= *=20 >> sizeof (EFI_RNG_ALGORITHM)); >> >> =C2=A0=C2=A0=C2=A0 if (mAvailableAlgoArray =3D=3D NULL) { >> >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return EFI_OUT_OF_RESOURCES; >> >> =C2=A0=C2=A0=C2=A0 } >> >> diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/Arm/ArmAlgo.c=20 >> b/SecurityPkg/RandomNumberGenerator/RngDxe/Arm/ArmAlgo.c >> index 4b24f5c4a69b..5e621df601fb 100644 >> --- a/SecurityPkg/RandomNumberGenerator/RngDxe/Arm/ArmAlgo.c >> +++ b/SecurityPkg/RandomNumberGenerator/RngDxe/Arm/ArmAlgo.c >> @@ -32,7 +32,7 @@ GetAvailableAlgorithms ( >> =C2=A0=C2=A0=C2=A0 UINT16=C2=A0 MinorRevision; >> >> >> =C2=A0=C2=A0=C2=A0 // Rng algorithms 2 times, one for the allocation, on= e to populate. >> >> -=C2=A0 mAvailableAlgoArray =3D AllocateZeroPool (RNG_AVAILABLE_ALGO_MAX= ); >> >> +=C2=A0 mAvailableAlgoArray =3D AllocateZeroPool (RNG_AVAILABLE_ALGO_MAX= *=20 >> sizeof (EFI_RNG_ALGORITHM)); >> >> =C2=A0=C2=A0=C2=A0 if (mAvailableAlgoArray =3D=3D NULL) { >> >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return EFI_OUT_OF_RESOURCES; >> >> =C2=A0=C2=A0=C2=A0 } >>