From: "PierreGondois" <pierre.gondois@arm.com>
To: devel@edk2.groups.io
Cc: ardb+tianocore@kernel.org, leif@nuviainc.com,
sami.mujawar@arm.com, Jiewen Yao <jiewen.yao@intel.com>,
Jian J Wang <jian.j.wang@intel.com>
Subject: [PATCH v4 2/2] SecurityPkg/RngDxe: Check for NULL PcdCpuRngSupportedAlgorithm
Date: Tue, 7 Mar 2023 18:15:50 +0100 [thread overview]
Message-ID: <20230307171550.555541-3-pierre.gondois@arm.com> (raw)
In-Reply-To: <20230307171550.555541-1-pierre.gondois@arm.com>
From: Pierre Gondois <pierre.gondois@arm.com>
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4151
The EFI_RNG_PROTOCOL can advertise multiple algorithms through
Guids. The PcdCpuRngSupportedAlgorithm contains a Guid that
can be configured. It represents the algorithm used in RngLib
and using CPU instructions.
When adding support for the Firmware Trng interface, it was made
available through in the RngDxe module. In RngDxe, the algorithm
associated with PcdCpuRngSupportedAlgorithm (implemented by the
RngLib) was always advertised by default.
It was assumed that support for RngLib and RNDR instructions
should be kept in ArmVirtPkg. However this support did not exist
as all ArmVirtPkg use the BaseRngLibTimerLib.inf implementation
of the RngLib.
Do not advertise the RngLib and PcdCpuRngSupportedAlgorithm
if PcdCpuRngSupportedAlgorithm is NULL.
Reported-by: Sami Mujawar <sami.mujawar@arm.com>
Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com>
---
.../RngDxe/AArch64/AArch64Algo.c | 14 +++-----------
1 file changed, 3 insertions(+), 11 deletions(-)
diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/AArch64Algo.c b/SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/AArch64Algo.c
index e8be217f8a8c..c98e09363e25 100644
--- a/SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/AArch64Algo.c
+++ b/SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/AArch64Algo.c
@@ -39,23 +39,15 @@ GetAvailableAlgorithms (
}
// Check RngGetBytes() before advertising PcdCpuRngSupportedAlgorithm.
- if (!EFI_ERROR (RngGetBytes (sizeof (DummyRand), (UINT8 *)&DummyRand))) {
+ if (!IsZeroGuid (PcdGetPtr (PcdCpuRngSupportedAlgorithm)) &&
+ !EFI_ERROR (RngGetBytes (sizeof (DummyRand), (UINT8 *)&DummyRand)))
+ {
CopyMem (
&mAvailableAlgoArray[mAvailableAlgoArrayCount],
PcdGetPtr (PcdCpuRngSupportedAlgorithm),
sizeof (EFI_RNG_ALGORITHM)
);
mAvailableAlgoArrayCount++;
-
- DEBUG_CODE_BEGIN ();
- if (IsZeroGuid (PcdGetPtr (PcdCpuRngSupportedAlgorithm))) {
- DEBUG ((
- DEBUG_WARN,
- "PcdCpuRngSupportedAlgorithm should be a non-zero GUID\n"
- ));
- }
-
- DEBUG_CODE_END ();
}
// Raw algorithm (Trng)
--
2.25.1
prev parent reply other threads:[~2023-03-07 17:16 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-07 17:15 [PATCH v4 0/2] SecurityPkg: Fixes for RngDxe PierreGondois
2023-03-07 17:15 ` [PATCH v4 1/2] SecurityPkg/RngDxe: Simplify Rng algorithm selection for Arm PierreGondois
2023-03-07 17:15 ` PierreGondois [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230307171550.555541-3-pierre.gondois@arm.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox