From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (EUR05-AM6-obe.outbound.protection.outlook.com [40.107.22.70]) by mx.groups.io with SMTP id smtpd.web09.8739.1637062420217431990 for ; Tue, 16 Nov 2021 03:33:40 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=MSywHBuY; spf=pass (domain: arm.com, ip: 40.107.22.70, 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=mvP8MHYfH6H/tBRGvDjVFxYu65a8Pf1CzOmqd15FsRA=; b=MSywHBuYeQiDReXItttb9d5rXa5oFDL0qCKVR0LtPDksdvmOnjCLYrwC29jQJvDXYDDM9kaCIyL97h3ia7QwNcQxSz0Kws7vjAAIY8Z1gbSDmwEkL6hyGwnIdSNv//eZG56O3djrwbjJdheg91N2S0CsnVnB5tPW4TioXSjy+mI= Received: from AM6P195CA0060.EURP195.PROD.OUTLOOK.COM (2603:10a6:209:87::37) by DBBPR08MB4476.eurprd08.prod.outlook.com (2603:10a6:10:d0::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.26; Tue, 16 Nov 2021 11:33:24 +0000 Received: from AM5EUR03FT011.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:87:cafe::2c) by AM6P195CA0060.outlook.office365.com (2603:10a6:209:87::37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.15 via Frontend Transport; Tue, 16 Nov 2021 11:33:24 +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; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM5EUR03FT011.mail.protection.outlook.com (10.152.16.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.20 via Frontend Transport; Tue, 16 Nov 2021 11:33:23 +0000 Received: ("Tessian outbound dbb52aec1fa6:v110"); Tue, 16 Nov 2021 11:33:23 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 67b9317c91f8021f X-CR-MTA-TID: 64aa7808 Received: from ffff9a5acdf2.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id EFAF0FB6-72A7-4E0A-B2E1-A8773F069024.1; Tue, 16 Nov 2021 11:33:15 +0000 Received: from EUR02-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id ffff9a5acdf2.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 16 Nov 2021 11:33:15 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TQskKhAwoTcwvQNyfIzGl45CPhG2U4GlzFHVHNvNk7a0U0BBA1aEvS070YuZ0RFmGgoFwkyqdpJYKlnzjRI3HiUXZevsdXTXEOu2jBGcDZvDebHRSFkWKrhziKeLrInVhWsQpKPO1BDXGBotOECwKYEOWZoCPym5MJcbKNHaXbijWievCTNkLSxo2UZ3vqtjXeQNCdhjLZYUtegWKPABFWDsoDPLNClGIrr1O4hWlOHRqegpKZCNo7N6W2sVe2OCTC1bxrnVB9x1Vut1fUFgzPqUjMRNZJDg0PnQwyJ6DVWKoyEN+xVrXL6ikjvuY8BlPglCr97LJ3z5MUDveqTVsg== 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=mvP8MHYfH6H/tBRGvDjVFxYu65a8Pf1CzOmqd15FsRA=; b=AYGq7OZ3ZqdEyDgfvGU8uB3rfHLcx8E/laRZ3QHKKWGoKjuuahke0ss5ZyYdkTRFS1ZmtLea33ZN6B1d9RlSCdAdn5++hFU+35+C2Aalqfb20ehRaPLthA+5uvn4B/ybNq6GMGBAceaJn1CS+zeW6kLplB2rvwd2tFV6QIqivPgH1LP/nPy168hT/aiuIhnqqTE1nqXuw3Nvc25Wjznq2ahjHjGqSQ0x6+iK6VstFwZ+Yc5iT3W1a3uU6SO/dhC2afUXi92LHjqNV7L9pVF9KDt9RTwR9+e0OCIDw7LtWzxCbyINvlJ7BKWSP3ZcY1OJroVd/O6IaL/W5/67ZnmxKA== 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=mvP8MHYfH6H/tBRGvDjVFxYu65a8Pf1CzOmqd15FsRA=; b=MSywHBuYeQiDReXItttb9d5rXa5oFDL0qCKVR0LtPDksdvmOnjCLYrwC29jQJvDXYDDM9kaCIyL97h3ia7QwNcQxSz0Kws7vjAAIY8Z1gbSDmwEkL6hyGwnIdSNv//eZG56O3djrwbjJdheg91N2S0CsnVnB5tPW4TioXSjy+mI= Received: from AS9PR05CA0038.eurprd05.prod.outlook.com (2603:10a6:20b:489::25) by VI1PR08MB3424.eurprd08.prod.outlook.com (2603:10a6:803:88::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.26; Tue, 16 Nov 2021 11:33:09 +0000 Received: from VE1EUR03FT029.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:489:cafe::54) by AS9PR05CA0038.outlook.office365.com (2603:10a6:20b:489::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4713.19 via Frontend Transport; Tue, 16 Nov 2021 11:33:09 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; dkim=none (message not signed) header.d=none;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 VE1EUR03FT029.mail.protection.outlook.com (10.152.18.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4690.20 via Frontend Transport; Tue, 16 Nov 2021 11:33:09 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) by AZ-NEU-EX03.Arm.com (10.251.24.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20; Tue, 16 Nov 2021 11:32:56 +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.20 via Frontend Transport; Tue, 16 Nov 2021 11:32:55 +0000 From: "Sami Mujawar" To: CC: Sami Mujawar , , , , , , , , , , , , , Subject: [PATCH v2 6/8] SecurityPkg: Restructure checks in RngGetInfo Date: Tue, 16 Nov 2021 11:32:58 +0000 Message-ID: <20211116113301.31088-7-sami.mujawar@arm.com> X-Mailer: git-send-email 2.16.2.windows.1 In-Reply-To: <20211116113301.31088-1-sami.mujawar@arm.com> References: <20211116113301.31088-1-sami.mujawar@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c4019b80-dc5d-4e5a-98ce-08d9a8f4e640 X-MS-TrafficTypeDiagnostic: VI1PR08MB3424:|DBBPR08MB4476: 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: Xy8SFjJ5oHVgs9pBUKUvv6t0jLibdTCjh63zOnAc/Czda1ppBRniM1nQx/eQ2jHhip0Twg9+GCfMvkGdIDSD4ZkjsVU7PPNqNpi/QwJFR2Ru1pxnKztUgE/zjSzrKcSI7W4wsYZ3Pccq4Vv2jH5iBOFbGcnq3/0JqPp5vKxs/jD9ciac9GvgFpoSaSyZ19RplrD2czsapPMIRNAn6IlHhgu1EKQU00ZMf3mfe9y6Eh+H/YkN4jcvWvWaDNZt/+0JeNLOH4JWSQ/sBk9tvcMlZI57zsur6/rfRP6IeYwJ1+20KJeRsKVEHjtaiHKHCvah3fe95dQCSoKNp+zS+uenvkjMrNhZvcqvtvi1PAUc7T1qvNYYZui9ku0AjObz1r+fWcYG4a7C+7O+/l3cG9ctsusPlD9navIrKQvVhxnxglgjQt6+ZsZqpO5JTLFvx6D6hjFLj6PwgNj+deJ6RDWFo7sEaj8o5vu7TNjAT4UttXxB5F/6Nz0M0DMjjOlgnDiBl4z3ieOIShXjrIiKdvsePs0qgxaHR1YibNx8GLhOMIm4LfPsF6RK28VY1sFaoevXx1yyrxuTDjiMm9S1324faIRoPOoIyOSVa/+Y1Y+Z0F9Gj5q32mX5XyDunmz5rhCdVk/utTOlzyxWZvlpQHBSMSdyrMdSUZZveW1yUBYQN7hIYMZxNNxYMrM2zCZ5RVT7Cmx28jFBmEumcsuwdJFTh0QgtNbzRh+b+m4nfM+ER5EUxzC14cFhqr++EY3AeUvewgYq7DiBsZXxKMbTBHO2msrpWd45qc45VV6ToRHC4S3JS51lFPil/cIxd5RClZX/ 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)(46966006)(36840700001)(36860700001)(7696005)(336012)(44832011)(81166007)(36756003)(86362001)(4326008)(426003)(8676002)(5660300002)(2906002)(15650500001)(2616005)(6916009)(26005)(47076005)(7416002)(316002)(82310400003)(1076003)(70206006)(54906003)(356005)(70586007)(8936002)(508600001)(83380400001)(186003)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB3424 Return-Path: Sami.Mujawar@arm.com X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT011.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 4d0ceda0-8bd6-487f-cca6-08d9a8f4dd9f X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: CUOpNddlTn+or7fP8b+bDivM3+mypt2ZlrjCbfCNz2k31/Kc2lgQJUpujt6rYv3bz0ByWhAZDLHEfSnJlBp1shFvtQVohcaOsTuOEOvBaV63VfsCttqOPk1yCC6PbI0cET3exmrqoLD2KUGIrzSwB9cPqGsA2klpPm9V2KGfB1zhGKPXBomfXdFaP6AhuwlXBGaL+1zLqipUeA508nRx9jCB7QQ5sQZm8ocCWL16jS0CIZ+La53iW2YfmE+ZtA+Sul1AQh4hxe+/qZwT+kqY22p1xVkdJ0ooMEedkgZY0uRKP2+xGb6wsnSXJmkFoAiGmfCGhwfsNCRAPPN93ryy1i7zAkBz0FiNYMgahgTKdSH/XgRJNXF/baxBcmu3npP3jtDenB1SZBqLxmv8rFzbYuZbNM2ZsRV87BXKgFd+ovCsFUVy9xXH7QF90KOfsrgxdj8JX3fNhiE2QlX1rosCfuzvCG6SWxReGlfWuQGPUvU6rv47ndxI2BC9FrWgjr4Uq2E9H0bZHiF/TULjNpAH1Po2M/rUMvwy9eITw/BFmlKJ25vCbvPfyfrjLM4QJ6P/ncrI9t9+GX/vVQ1e+wYhJxKxqYVxemxR7F/oxOdbAr/DNrYqOgk+P5XIc/wpS+ssgs3ymhxvvq4UsAcp1gAIzfzlvaUn9oD2rqqw0LA8+Ce+wGHF1SyT2NkwBYKNmSDlIjcUo7Jhx6MliitzYVM0FjwFNaSEaDvKs6bd4qBL2aAvwt+5Xcn3c68g/50KS2NwuzsvTUiITu/1PPc1iq7nH6gKmQRUaQKNgrOqShuDx5M= 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)(46966006)(36840700001)(8676002)(8936002)(426003)(2616005)(81166007)(5660300002)(336012)(36860700001)(15650500001)(82310400003)(1076003)(2906002)(70586007)(70206006)(6916009)(47076005)(83380400001)(36756003)(54906003)(26005)(86362001)(508600001)(7696005)(44832011)(186003)(4326008)(316002);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Nov 2021 11:33:23.7505 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c4019b80-dc5d-4e5a-98ce-08d9a8f4e640 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: AM5EUR03FT011.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR08MB4476 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 --- Notes: v2: - No code change since v1. Re-sending with V2 series. [SAMI] 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)'