Hi Kun,

This patch and Pierre's series at https://edk2.groups.io/g/devel/message/106711 are both required to fix the RNG implementation for Arm.

I will wait for the MdePkg and SecurityPkg maintainers for any feedback by end of next week. If there are no futher comments, I will merge both this patch and the series at https://edk2.groups.io/g/devel/message/106711.

Regards,

Sami Mujawar

On 03/07/2023 09:09 pm, Kun Qin wrote:
Hi Sami,

Would you prefer to have input from Jiewen or Jian to review this patch as well?

Otherwise, would you mind helping me to merge the change?

Thanks in advance!

Regards,
Kun

On 6/29/2023 4:59 PM, Kun Qin via groups.io wrote:
From: Kun Qin <ku...@microsoft.com>

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 <jiewen....@intel.com>
Cc: Jian J Wang <jian.j.w...@intel.com>
Cc: Sami Mujawar <sami.muja...@arm.com>
Cc: Pierre Gondois <pierre.gond...@arm.com>

Signed-off-by: Kun Qin <ku...@microsoft.com>
Reviewed-by: Sami Mujawar <sami.muja...@arm.com>
---

Notes:
     v2:
     - Added reviewed-by tag [Sami]

  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 e8be217f8a8c..e7107a0b7039 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;

    }



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#106720): https://edk2.groups.io/g/devel/message/106720
Mute This Topic: https://groups.io/mt/99934328/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-


Reply via email to