[edk2-devel] [PATCH v1 1/2] SecurityPkg: RngDxe: Unify handling of zero guid

Kun Qin kuqin12 at gmail.com
Wed Jun 28 20:33:55 UTC 2023


From: Kun Qin <kuqin at microsoft.com>

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4491

The existing logic of initializing `mAvailableAlgoArrayCount` will treat
the zero GUID in `PcdCpuRngSupportedAlgorithm` as a legit case and
increment `mAvailableAlgoArrayCount`, causing the RNG protocol be
published.

However, when the protocol is invoked, any zero GUID will be filtered
out, leaving a possible edge case where the protocol only has a zero GUID
based algorithm and being filtered out will always result in an ASSERT.

This change marked the zero GUID as an issue and will not increment the
counter and thus avoid publishing the protocol completely.

Cc: Jiewen Yao <jiewen.yao at intel.com>
Cc: Jian J Wang <jian.j.wang at intel.com>
Cc: Sami Mujawar <Sami.Mujawar at arm.com>
Cc: Pierre Gondois <pierre.gondois at arm.com>

Signed-off-by: Kun Qin <kuqin at microsoft.com>
---
 SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/AArch64Algo.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/AArch64Algo.c b/SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/AArch64Algo.c
index e8be217f8a8c..de279cdadeea 100644
--- a/SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/AArch64Algo.c
+++ b/SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/AArch64Algo.c
@@ -47,15 +47,16 @@ GetAvailableAlgorithms (
       );
     mAvailableAlgoArrayCount++;
 
-    DEBUG_CODE_BEGIN ();
     if (IsZeroGuid (PcdGetPtr (PcdCpuRngSupportedAlgorithm))) {
+      DEBUG_CODE_BEGIN ();
       DEBUG ((
         DEBUG_WARN,
         "PcdCpuRngSupportedAlgorithm should be a non-zero GUID\n"
         ));
+
+      DEBUG_CODE_END ();
+      mAvailableAlgoArrayCount--;
     }
-
-    DEBUG_CODE_END ();
   }
 
   // Raw algorithm (Trng)
-- 
2.41.0.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#106484): https://edk2.groups.io/g/devel/message/106484
Mute This Topic: https://groups.io/mt/99839047/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-




More information about the edk2-devel-archive mailing list