From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from EUR03-AM7-obe.outbound.protection.outlook.com (EUR03-AM7-obe.outbound.protection.outlook.com [40.107.105.65]) by mx.groups.io with SMTP id smtpd.web10.5232.1688034853099409611 for ; Thu, 29 Jun 2023 03:34:13 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=RmMSEBay; spf=pass (domain: arm.com, ip: 40.107.105.65, 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=xsEC/ewjvWjt6LlqgX6sW75SXf11sZvOXKTNIzcKSWM=; b=RmMSEBay6v1nxF3tGtEB/ul2IIPOXI4G+zfHuKnSpzDSlRWAw5WlJbKrdi2BkJp3JF7k+sv7E09HXL8pgkPOuzQ4CMetmArd/EJqrj4TdD4P5WvoOrlhi917wtmHukXZ+Om7ZQENs2QoKulHVnLb6A9ypLtArcp5LBFe3ru+q9k= Received: from DUZPR01CA0047.eurprd01.prod.exchangelabs.com (2603:10a6:10:469::16) by PAWPR08MB9735.eurprd08.prod.outlook.com (2603:10a6:102:2ee::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6544.19; Thu, 29 Jun 2023 10:34:09 +0000 Received: from DBAEUR03FT059.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:469:cafe::28) by DUZPR01CA0047.outlook.office365.com (2603:10a6:10:469::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6544.22 via Frontend Transport; Thu, 29 Jun 2023 10:34:09 +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 DBAEUR03FT059.mail.protection.outlook.com (100.127.142.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6544.20 via Frontend Transport; Thu, 29 Jun 2023 10:34:09 +0000 Received: ("Tessian outbound e2424c13b707:v142"); Thu, 29 Jun 2023 10:34:09 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 738db19251123913 X-CR-MTA-TID: 64aa7808 Received: from c4a113665fb3.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 6CC86914-C47E-45D9-B28C-24DF6D63F273.1; Thu, 29 Jun 2023 10:34:03 +0000 Received: from EUR02-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id c4a113665fb3.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 29 Jun 2023 10:34:03 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=m17+K9l/q5D5URSSsMALQlX6lYKnp08qyc8TaWWKXC0US1m2nzrgPUVA0cWi3hQoYQZYxu6vQghcgGknHsJAhy0Xe4jRFX1H09XAOg6CKIRJdJndwfomkKUxKnaIShxSHIEB/5CeeQ8SLGXL98wUl8rNwzuLcpFokFK9to+IRNqOSOcLPQ95lEXwELTWymeDTFlEoe3QuuJ4KVMFmNUquTNi01yDgjiXOdKhbyYsj7x5Of3dkyDwZEfoRAF+3pmYRBpUGP3jvCCocWt+4LKQ6EZpfPnQk13hVnah6BaG0O66PgdJcA7qPUxeGchlx+DfpDUp8Qt5/BEom7VrYWdKfA== 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=xsEC/ewjvWjt6LlqgX6sW75SXf11sZvOXKTNIzcKSWM=; b=ENNpk99Ujbieug6YXFuvUs/kL/1jp0ZugTel/X4A/U7cfmnfF8DqtBWoBkDL1/rJvXOenNsPjqXDmqrTPFENISj6LQ0IZcwBT9QvY1pSvjuN4g+b3KJot1Qj8qrRJlKmOQQMgzo3d19StCiq+ez73UW7AbfkLNvva5GssxA70xZ/N2a3Gb+U+Wr9h1JfHXVhrODlfnHTpaPGq51y8XaSB/bwE7j9THb9AssDs7v1LoKu3N8tqdU8bveNpqidxzzkgdGjfty+vBvdDUtDD6wjRNrUlyDH5TotcD/Tqs9WlYfh0Y/k9C+Zg5KawOSCNGoe0w84z6sLgEsDFhmg9BGYFw== 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=xsEC/ewjvWjt6LlqgX6sW75SXf11sZvOXKTNIzcKSWM=; b=RmMSEBay6v1nxF3tGtEB/ul2IIPOXI4G+zfHuKnSpzDSlRWAw5WlJbKrdi2BkJp3JF7k+sv7E09HXL8pgkPOuzQ4CMetmArd/EJqrj4TdD4P5WvoOrlhi917wtmHukXZ+Om7ZQENs2QoKulHVnLb6A9ypLtArcp5LBFe3ru+q9k= 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 PA4PR08MB6240.eurprd08.prod.outlook.com (2603:10a6:102:ec::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.26; Thu, 29 Jun 2023 10:34:00 +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.6544.019; Thu, 29 Jun 2023 10:34:00 +0000 Message-ID: <756d8c57-a645-f949-16a7-2afd55e092cb@arm.com> Date: Thu, 29 Jun 2023 11:33:58 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 Subject: Re: [PATCH v1 2/2] SecurityPkg: RngDxe: Fixing mAvailableAlgoArray allocator To: Kun Qin , devel@edk2.groups.io Cc: Jiewen Yao , Jian J Wang , Pierre Gondois , "nd@arm.com" References: <20230628203357.2001-1-kuqin12@gmail.com> <20230628203357.2001-3-kuqin12@gmail.com> From: "Sami Mujawar" In-Reply-To: <20230628203357.2001-3-kuqin12@gmail.com> X-ClientProxiedBy: LO4P123CA0560.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:33b::18) To AS8PR08MB6806.eurprd08.prod.outlook.com (2603:10a6:20b:39b::12) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: AS8PR08MB6806:EE_|PA4PR08MB6240:EE_|DBAEUR03FT059:EE_|PAWPR08MB9735:EE_ X-MS-Office365-Filtering-Correlation-Id: 051554db-8f27-4218-788d-08db788c5f44 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: GbiVHU4ss0z9DGWCe0xt0dge1HHSF0ex26dSHGLbYx9257lpj9eUbve2wOgjGmfwVwFTx2PdnNH3y0Yn9ltmKt69N0TQXvGMZrAFv+9ctMpI8fZX5KxLEpzBiBsAfwWQGTXYAFhCivO5iWR64yKRoOlHSH9g20nUnotMzZNTbGLoQOhBYgGbJZYc6yJ5MjR3vWs6Rpfb3XOpCGj8yrEloMDaa441j6ZslkM0U6sRANdl1e5b2UtrpY3uLwP9TopDncnBLQnjA+t5Jn+psgffuGn9pu6Yiel7coFUz6Ie+WChh8jnnYADyGMZrFi/X+QF6KaOkPCyFb8MkKmrdZFZ1goQrOBdSkpHaivwzhzHymSIasdYLdkTdyMyCrlRGRhj8V1BR6rnyZq6Uk0EgrXqFxgUSYxbnScEbHHFPC2teilACn1C1+YGVVmnHSiCuiAbWF3P9+vo8kRIK3Ci4zjWAS0rGhGyjfNdQll+PTEi/Sdn1hpOY3cT7escPDhNaw3NJelPcHUg7y5P5Lj176J0d1z6KsBFUyvtyXenIydY4RQav5QmLS1nFCFyMgge/UxomiuWzxNNMv7lmo7YKCmFAHQCGIDIKwUVH5ibbw8LiRmtQ9Iqq1voJvodZv3bM3BRvpZvShFQbqkdsOSbakIhK0Tn1pjOPKYWYov8PdAj6fA= 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)(376002)(39860400002)(396003)(366004)(346002)(136003)(451199021)(5660300002)(66476007)(26005)(2906002)(186003)(38100700002)(2616005)(6506007)(6512007)(8936002)(83380400001)(53546011)(41300700001)(44832011)(66946007)(66556008)(36756003)(31696002)(6486002)(478600001)(966005)(86362001)(45080400002)(54906003)(8676002)(4326008)(316002)(15650500001)(31686004)(145543001)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR08MB6240 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: DBAEUR03FT059.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 6d4ccfae-f7f5-4d86-33b9-08db788c5a01 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0RyJJ9xHSCTX5gnohJMbuC57iaOa5Ae5KwW/UO4F7+T2N8B6JNjIECAjg9MRlCG9imBzg5fnNwSdWej5/A38qYfIjTTfArLYAkYQgYb8jRKzvkbcTYYdtpzmN+Z3pLirzL7aagueYFg6UlCTM2yYemKKY67pKz9dRFUmEu3p3cnr0so3Akecc4xagFSY8FoZuZLPTGddzps4DPHednuNaNoFpNi1fOwsxSzuNKum9LqF6ysc1obWODoR4pf4fHxLH9K+o4IpAFpuR0qN/iAZyqoaW0oqXqmiBwCCynf92qjY/OSxAXHYxzca3783I/X8qr7O+XBzFnjP0sp4G2P0EzTyMpqCKkxzBImbl0UpODRrMtzTfCbz0y2tJNISzqHplqWNK3NFSfhKnYrEltlfuuX2VgDXGe1XaIzda9S5PFVPU2Y3aFOqVSA71ylvuL3GUIrSDcW58sDTVl6iLgFSjH/ibii9gshZdmwkIEBFFgxTsUwQKKNmT8uz7AarM77czmnAlu2uFAadtK6bnwLUD2XgQrC1TgDSDgtB9tuiE8Rt+E9FOefKWsLjmn4hjf/lksJuFiIG3akUlOJYQagq+/Qr9w2Du6JjtyNKlCY6kd0RpeaWqV1N61NE0ubPAFQcf3lBm2PSg4b84nXM5xjWJqpeiYolMMhDiYmBd7NvFHQ+Hbqq26Tt0Q54+204Clk0mpX6oD7AdujrSbocPORU5JlyCyLj7Ak3m3FaGdZfe8vEwiJspAdtLZEYfC132/8VE7bCvzR/cccKR0FaGeAI6hisWLG9Dqg4PoxzofEF7Es= 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)(136003)(396003)(39860400002)(376002)(346002)(451199021)(46966006)(40470700004)(36840700001)(31686004)(82310400005)(186003)(26005)(2906002)(15650500001)(86362001)(31696002)(82740400003)(6486002)(966005)(316002)(4326008)(36756003)(8676002)(8936002)(54906003)(478600001)(45080400002)(81166007)(2616005)(47076005)(336012)(6506007)(6512007)(356005)(5660300002)(53546011)(83380400001)(44832011)(70586007)(41300700001)(70206006)(40460700003)(40480700001)(36860700001)(145543001)(43740500002);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jun 2023 10:34:09.2134 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 051554db-8f27-4218-788d-08db788c5f44 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: DBAEUR03FT059.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAWPR08MB9735 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Hi Kun, Thank you for this fix. Reviewed-by: Sami Mujawar Regards, Sami Mujawar On 28/06/2023 09:33 pm, Kun Qin wrote: > From: Kun Qin > > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4491 > > 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 size > of buffer before referencing. > > Cc: Jiewen Yao > Cc: Jian J Wang > Cc: Sami Mujawar > Cc: Pierre Gondois > > Signed-off-by: Kun Qin > --- > SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/AArch64Algo.c | 2 +- > SecurityPkg/RandomNumberGenerator/RngDxe/Arm/ArmAlgo.c | 2 +- > 2 files changed, 2 insertions(+), 2 deletions(-) > > diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/AArch64Algo.c b/SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/AArch64Algo.c > index de279cdadeea..1d412ecff61d 100644 > --- a/SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/AArch64Algo.c > +++ b/SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/AArch64Algo.c > @@ -33,7 +33,7 @@ GetAvailableAlgorithms ( > UINT16 MinorRevision; > > > > // Rng algorithms 2 times, one for the allocation, one to populate. > > - mAvailableAlgoArray = AllocateZeroPool (RNG_AVAILABLE_ALGO_MAX); > > + mAvailableAlgoArray = AllocateZeroPool (RNG_AVAILABLE_ALGO_MAX * sizeof (EFI_RNG_ALGORITHM)); > > if (mAvailableAlgoArray == NULL) { > > return EFI_OUT_OF_RESOURCES; > > } > > diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/Arm/ArmAlgo.c 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 ( > UINT16 MinorRevision; > > > > // Rng algorithms 2 times, one for the allocation, one to populate. > > - mAvailableAlgoArray = AllocateZeroPool (RNG_AVAILABLE_ALGO_MAX); > > + mAvailableAlgoArray = AllocateZeroPool (RNG_AVAILABLE_ALGO_MAX * sizeof (EFI_RNG_ALGORITHM)); > > if (mAvailableAlgoArray == NULL) { > > return EFI_OUT_OF_RESOURCES; > > } >