From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (EUR04-VI1-obe.outbound.protection.outlook.com [40.107.8.42]) by mx.groups.io with SMTP id smtpd.web11.14464.1633016490443292661 for ; Thu, 30 Sep 2021 08:41:30 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=Yu0IhEr1; spf=pass (domain: arm.com, ip: 40.107.8.42, 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=pdE7feaM8wDfF8sTPPuJCl9IkaYoGsRfhn7UPZeqyw0=; b=Yu0IhEr1L76vt54X4QUUbLDkYxCEtSZ6u5H3KaX2RCzS7MhSZ6BdN+OW8LWKxte3TmxE73tyF6SjlEjJGFbeQk3ox5zFQVcnRH+Vsnbb0tyM8vc7uWdya6FWs1JwDosne6D91udWLffn4p9sr/PoB25Cw5nEIC3lPt+h5Cl1enk= Received: from AS8PR04CA0104.eurprd04.prod.outlook.com (2603:10a6:20b:31e::19) by AM6PR08MB4785.eurprd08.prod.outlook.com (2603:10a6:20b:d2::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.15; Thu, 30 Sep 2021 15:41:26 +0000 Received: from VE1EUR03FT014.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:31e:cafe::b8) by AS8PR04CA0104.outlook.office365.com (2603:10a6:20b:31e::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.14 via Frontend Transport; Thu, 30 Sep 2021 15:41:26 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; edk2.groups.io; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;edk2.groups.io; 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; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by VE1EUR03FT014.mail.protection.outlook.com (10.152.19.38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.14 via Frontend Transport; Thu, 30 Sep 2021 15:41:26 +0000 Received: ("Tessian outbound 71ebfb754289:v103"); Thu, 30 Sep 2021 15:41:26 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: d822c66c013f0b3c X-CR-MTA-TID: 64aa7808 Received: from 2dd6ed84b9df.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id ED8383ED-5866-45A5-88C8-3B846BB31C5B.1; Thu, 30 Sep 2021 15:41:17 +0000 Received: from EUR05-DB8-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 2dd6ed84b9df.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 30 Sep 2021 15:41:17 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=edWVQNhbxASgDKwDpy1YBB3+E8E/OWD4dbxnLdKxBEivCbCEfyO/YsKnhOMpLB4JsaXkXw3Cp5x9H9uSOOqAW93m6ORLRfbKKxBdTp6+k901ZYkYf8JHZHJwLGGzRLudmqQRLUFeUj1prf6D9TPJ2dQ71FZMO99YVwJiQOYVBgMUkB3kqti//jxd23BBWE9vBOpLf3dZMNf0/VQwunwErTtDbQFlBZhVGn74Iloy9YAb6l1VETOf2rw1HPW/an6cEnFV+hhccRRcc2uepVopvjeyDpmWjzndA+qPAX4Wdsn7YzzCOG4xfofLMjFSlM07WStOj+Gl69+h+rU9c6+Asg== 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; bh=pdE7feaM8wDfF8sTPPuJCl9IkaYoGsRfhn7UPZeqyw0=; b=bIa1IAtqq1+x94Dh2STKOWZS0DgAUUbMLu0oXKJY9Hv7jjFn6kI92lXhl5XIaUkvi+cYsyrdb0VBQfn3b2gHqbTlL1Bz0Ilg4vjZMvMuW42jcrYt5RMYl6mwW4n1Ac2BkGu3JjE6Z8q5/M2N94+jZRqHXwdRA56TOTiA7eDQ9Hdlq4Lqlm6B2xnyfDCequ122jl+OUaf5CC/NTkUhakbwEgq9ktSND4GnG9QOq/yCWLKq9I8CVUk49sa5wjMqVZfT5VPvtFLDuDi7HHx/gChr93Dm82cZapU1lbIMc98Yofup8yWoSCiNB/4t+1vbM17JMTTE7UFOR8z1iMqLDXNTQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); 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=pdE7feaM8wDfF8sTPPuJCl9IkaYoGsRfhn7UPZeqyw0=; b=Yu0IhEr1L76vt54X4QUUbLDkYxCEtSZ6u5H3KaX2RCzS7MhSZ6BdN+OW8LWKxte3TmxE73tyF6SjlEjJGFbeQk3ox5zFQVcnRH+Vsnbb0tyM8vc7uWdya6FWs1JwDosne6D91udWLffn4p9sr/PoB25Cw5nEIC3lPt+h5Cl1enk= Received: from AM6P192CA0039.EURP192.PROD.OUTLOOK.COM (2603:10a6:209:82::16) by DB6PR0802MB2437.eurprd08.prod.outlook.com (2603:10a6:4:9f::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.20; Thu, 30 Sep 2021 15:41:15 +0000 Received: from VE1EUR03FT018.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:82:cafe::d7) by AM6P192CA0039.outlook.office365.com (2603:10a6:209:82::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.14 via Frontend Transport; Thu, 30 Sep 2021 15:41:15 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 40.67.248.234 as permitted sender) receiver=protection.outlook.com; client-ip=40.67.248.234; helo=nebula.arm.com; Received: from nebula.arm.com (40.67.248.234) by VE1EUR03FT018.mail.protection.outlook.com (10.152.18.135) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4566.14 via Frontend Transport; Thu, 30 Sep 2021 15:41:15 +0000 Received: from AZ-NEU-EX01.Emea.Arm.com (10.251.26.4) by AZ-NEU-EX03.Arm.com (10.251.24.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2308.14; Thu, 30 Sep 2021 15:40:51 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) by AZ-NEU-EX01.Emea.Arm.com (10.251.26.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.14; Thu, 30 Sep 2021 15:40:47 +0000 Received: from E114225.Arm.com (10.1.196.43) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2308.14 via Frontend Transport; Thu, 30 Sep 2021 15:40:50 +0000 From: "Sami Mujawar" To: CC: Sami Mujawar , , , , , , , , , , , , , Subject: [PATCH v1 7/9] SecurityPkg: Restructure checks in RngGetInfo Date: Thu, 30 Sep 2021 16:40:42 +0100 Message-ID: <20210930154044.37336-8-sami.mujawar@arm.com> X-Mailer: git-send-email 2.16.2.windows.1 In-Reply-To: <20210930154044.37336-1-sami.mujawar@arm.com> References: <20210930154044.37336-1-sami.mujawar@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 494f9091-826a-49ba-99dd-08d98428c3ac X-MS-TrafficTypeDiagnostic: DB6PR0802MB2437:|AM6PR08MB4785: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:3276;OLM:3276; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: ZkbDVswK00Qs9c7Gc8WyLrIOa8YvAqcf5jX/8wwaHtzctofDPuWlMP/QrCP5wyovH3sb6YI1i1pNfb/9amec0TQrQl/Z7hhQQ6YTZSEmxI5cMqvjaZyTfzg/MpHhJFBNk0X/3C26fuIexzkCbEUhtUZpSO7FR/ktVZ5EKJ0zDAuYEsFAVaNuE3FrtaplLzEwplZWOnfwrWQ6tmtmEwai56iawZ7Dj2rlIuVtDQYKV21JNIsjuqXzjrCiWbjivWxtSsVd+QxHDO+jbNrZWUSvT8xwoovhaAVKJsfn3m7zj4HVEXZEiiWFzriafIhehYMjoudZe5iSD5RoQPuUkBqOSRzTLQsn1UCOSgK+Wngg7zho6ZgOwVD2geoD4f1vfxFaZeK3/YmM/NpPapCNiU1G9iOE0Bo/IXwnCLCQw5lvtiv9N1k9xVEFWOz2WyZbUP5uHzF6MzrFx12UiIPPBZPrpFdJuTrwgbO8LRxwwXLg9IOodtHiKpb8TMA/h0FHwn0G1bGqmSZkwbZcYQRCMX0fm/cUaNbyRylPYp7txwLMiTrgSkh4vOWOj/TedVzqKdQe2Yt9kQ1L3tDFxvb1vS0YIkAOt2RKUcDqFSvAxEgbXNOEvpi/lQYjBp+5Ih6pzKkYsn8k3Uq7FYWzlszv7rY73oTZLZGmpIz5+rIFa7NraYTIVhG6YBWRIHMXjK0rOPGZQOZHEBC6dah/6gtBkgZJ5lR6nNI0NVirJTlA7aIzLVi/OWpYSTAtqFq9yeNuovHR/n2Ohr7MTNq37YrfiuRqegrWI4JEoZYmBGoXdT12ft+PXAyjvmKlbxFwpEOUxXqc X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:nebula.arm.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(4636009)(36840700001)(46966006)(81166007)(2906002)(36756003)(86362001)(186003)(4326008)(8676002)(1076003)(356005)(5660300002)(26005)(6666004)(70586007)(6916009)(70206006)(316002)(44832011)(336012)(8936002)(36860700001)(83380400001)(2616005)(426003)(54906003)(508600001)(15650500001)(7416002)(47076005)(82310400003)(7696005)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0802MB2437 Return-Path: Sami.Mujawar@arm.com X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT014.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 8b7e7c70-ac5a-421e-3e3e-08d98428bce1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: RYoY16hev7P7oIF2FyXKAx5T061hUPNRyMFYeFeOsamo7aZX2VhlDGGvUKNbYHOrhFbFFKTW2/PjLaT5gjodAY+Pq6adBegfq3Gi8wcIIKz4wjeGX2xt63yZruD5/ORuRrs6P693GgmvgerEA2c2MAQ1zYbObv1zf8oOqXMvOm+Npke97KTr/36XtMDEGpWLOVq5SF32VoBwB6qx+fMgCGbx7GKFej6n11Qbcuc1Svnn6WjpJlmb8GkRjJ1wiWczIrfsFivmEdzPa6+Grprs3gJ49/RdOWGGnZ0UrcOYAsWOZfEy54+uQ9uS/rGcg6r7jjvHD2NOMtnJqy7lyXYUinFevpikZkcB9VgpF62rNoXFYpdjRS1+ZNhmC1nIBuivogtDBKG3wUAD7qKiUr2xzsrvwZVzQSV9/56Qk4aPxgfs3ycq97PiTiXVJR3t0Xe4PW2jGTYj5ZCdBtte9FijV7O8BxYZnn5+7qPz5CmKLFmOWqIi2F7j6DHpFdh0aRQD4kKqTk1SgfEKo8h828Q6FEpWXv8fur9WMf0T5Sm5eUvKukbRHRVrsavJ1CvtyIZoHoVxj1bcwHfQnTEnbj8MjKLnFQIHLerbpRGKp1GrIIf7pqe7RB8DFQV2Bi3+mqkqxvmAe2ZutjTr/F/M/mOAY4zaZyAzhPS2yyksLMQ+RYD4u3kWptu9P6L2GjKgkXXayvJg2jmchocjwbYqesEa4cesVZ0ifWa8ZusoraTDrfZflmrPZGjYrJpCoJxojrVermpyXdjcpsQXVPFNSnvzcscvMtjmahQliI47xjntbd0= 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:(4636009)(36840700001)(46966006)(426003)(81166007)(336012)(82310400003)(4326008)(36860700001)(6916009)(7696005)(47076005)(5660300002)(6666004)(86362001)(8936002)(1076003)(2616005)(54906003)(26005)(186003)(508600001)(70206006)(83380400001)(8676002)(70586007)(15650500001)(36756003)(2906002)(44832011)(316002);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Sep 2021 15:41:26.5013 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 494f9091-826a-49ba-99dd-08d98428c3ac 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: VE1EUR03FT014.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4785 Content-Type: text/plain Bugzilla: 3668 (https://bugzilla.tianocore.org/show_bug.cgi?id=3668) Move the check to see if the RNGAlgorithmList pointer is NULL to ArchGetSupportedRngAlgorithms(). This allows the caller to obtain the buffer size required to store the Algorithm List by passing RNGAlgorithmListSize as zero and RNGAlgorithmList as NULL. Signed-off-by: Sami Mujawar --- SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c | 6 ++++++ SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.c | 11 ++--------- SecurityPkg/RandomNumberGenerator/RngDxe/RngDxeInternals.h | 2 +- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c b/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c index 2009f95b4cadb07fc9073c3c0660cf549965422a..f1122a48102595506cc423c3ab501d9a72f50543 100644 --- a/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c +++ b/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c @@ -16,6 +16,7 @@ Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.
(C) Copyright 2015 Hewlett Packard Enterprise Development LP
+ Copyright (c) 2021, Arm Limited. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -116,6 +117,7 @@ RngGetRNG ( @retval EFI_SUCCESS The RNG algorithm list was returned successfully. @retval EFI_BUFFER_TOO_SMALL The buffer RNGAlgorithmList is too small to hold the result. + @retval EFI_INVALID_PARAMETER The pointer to the buffer RNGAlgorithmList is invalid. **/ UINTN @@ -135,6 +137,10 @@ ArchGetSupportedRngAlgorithms ( return EFI_BUFFER_TOO_SMALL; } + if (RNGAlgorithmList == NULL) { + return EFI_INVALID_PARAMETER; + } + CpuRngSupportedAlgorithm = PcdGetPtr (PcdCpuRngSupportedAlgorithm); CopyMem(&RNGAlgorithmList[0], CpuRngSupportedAlgorithm, sizeof (EFI_RNG_ALGORITHM)); diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.c b/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.c index b959c70536ea3b9049905bbfd3d973fc9b2f6dcf..2e3b714bc691e4e517866369c034b721fbccfa24 100644 --- a/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.c +++ b/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.c @@ -14,6 +14,7 @@ Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.
(C) Copyright 2015 Hewlett Packard Enterprise Development LP
+ Copyright (c) 2021, Arm Limited. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent @@ -59,8 +60,6 @@ RngGetInfo ( OUT EFI_RNG_ALGORITHM *RNGAlgorithmList ) { - EFI_STATUS Status; - if ((This == NULL) || (RNGAlgorithmListSize == NULL)) { return EFI_INVALID_PARAMETER; } @@ -68,13 +67,7 @@ RngGetInfo ( // // Return algorithm list supported by driver. // - if (RNGAlgorithmList != NULL) { - Status = ArchGetSupportedRngAlgorithms (RNGAlgorithmListSize, RNGAlgorithmList); - } else { - Status = EFI_INVALID_PARAMETER; - } - - return Status; + return ArchGetSupportedRngAlgorithms (RNGAlgorithmListSize, RNGAlgorithmList); } // diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxeInternals.h b/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxeInternals.h index 34886adcf549efdedc1a7b8f16b81a5148531de2..37c27c4094e5302dfe2e7d9bbeef33a24b0c73ea 100644 --- a/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxeInternals.h +++ b/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxeInternals.h @@ -90,7 +90,7 @@ RngGetRNG ( @retval EFI_SUCCESS The RNG algorithm list was returned successfully. @retval EFI_BUFFER_TOO_SMALL The buffer RNGAlgorithmList is too small to hold the result. - + @retval EFI_INVALID_PARAMETER The pointer to the buffer RNGAlgorithmList is invalid. **/ UINTN EFIAPI -- 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'