From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) by mx.groups.io with SMTP id smtpd.web10.1365.1688083164862426355 for ; Thu, 29 Jun 2023 16:59:24 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20221208 header.b=WH3qZM5u; spf=pass (domain: gmail.com, ip: 209.85.214.177, mailfrom: kuqin12@gmail.com) Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-1b80b343178so8916825ad.0 for ; Thu, 29 Jun 2023 16:59:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1688083164; x=1690675164; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=m/sbx5hGLrR7NLw4PuYVrMwBz6SP7zFy7DV1jCkmEio=; b=WH3qZM5ubOuRQurwEc9Pmzxo+dNsT9p/dHoo6+ffCODaC2JxNLJEUZ4OxwRakRws05 X2FFRfwP2wc3vlLercZoyPjj4u8faz/9rfctz4ptPVtG3dmOMdSUbDFs/NJvpsbdwTbl USaD1/qr3QmCTwRfqlBMJXFJmQW75Dv56Yzi/msvwm1AZRKxcSZupCY6cJTjLGuNG1Ui rAgpC5rnLnrtDS7w64eWH91WsmnCD0Ic7xFfHbP5P5tQgYubyKLE6BXVOH6a6uJ6r+6Z Q1sxvlwbCIxCwx/NH/vQCxJe8oPknQblTlBe8VKw7SjkQuSYAy2GJSCYmtigh5uN/ONX +Xrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688083164; x=1690675164; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=m/sbx5hGLrR7NLw4PuYVrMwBz6SP7zFy7DV1jCkmEio=; b=kRWXHHJdnzSj/ezTCa+jcmjSA3LZ//+vv4y7v+94mKdJeYDYQ7g1kvCy7KfMhaDod2 tYAGkG/jridY24zCSEwd6/lqmVvTF5kgxDrZI7X1GTvnzxvE8VdQjWoFDt0BnVPqtICN J4dlKlD3KwdusOthE/10LjUCrz6oXiHsOeg91iao1Mc2dUJwmIMdF0epg8U1OqTWo18Q DEdpOM1iwTVojEhi6iI5+tUJF5S1oLA6caJzc9Ys6Ye9cbt6JkKjcDiqwDRylbLCuTc1 eHAK9t4dqDOdNuqz5pvAJ0v+/OSh/9Z4eGjmgoiCs4q3TNNVXH6C9ZMQLk8WEHZLzx6g oNLg== X-Gm-Message-State: ABy/qLY/+CU5SC4TVvJfLojtv5MgHHff2e2WPA2uKYjzd5uEVRXTvg0O 1c8Rol1l6GuQem658Pkzujq2AQWALhc= X-Google-Smtp-Source: APBJJlHLhJRrJlFyHuMk5cYDI7+hsgB5M9gEzuMw5devG0UyoNJosmOTZ0xHcn8RkNYhXf5ZUNFdMQ== X-Received: by 2002:a17:902:da92:b0:1b7:e646:4cc4 with SMTP id j18-20020a170902da9200b001b7e6464cc4mr635315plx.28.1688083164037; Thu, 29 Jun 2023 16:59:24 -0700 (PDT) Return-Path: Received: from MININT-0U7P5GU.redmond.corp.microsoft.com ([2001:4898:80e8:7:8971:7e07:c1c3:d47a]) by smtp.gmail.com with ESMTPSA id y8-20020a1709029b8800b001b23eb0b4bbsm9617476plp.147.2023.06.29.16.59.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Jun 2023 16:59:23 -0700 (PDT) From: "Kun Qin" To: devel@edk2.groups.io Cc: Jiewen Yao , Jian J Wang , Sami Mujawar , Pierre Gondois , Sami Mujawar Subject: [PATCH v2 1/1] SecurityPkg: RngDxe: Fixing mAvailableAlgoArray allocator Date: Thu, 29 Jun 2023 16:59:18 -0700 Message-ID: <20230629235919.2077-2-kuqin12@gmail.com> X-Mailer: git-send-email 2.41.0.windows.1 In-Reply-To: <20230629235919.2077-1-kuqin12@gmail.com> References: <20230629235919.2077-1-kuqin12@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Kun Qin REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4491 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 Cc: Jian J Wang Cc: Sami Mujawar Cc: Pierre Gondois Signed-off-by: Kun Qin Reviewed-by: Sami Mujawar --- 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;=0D =0D // Rng algorithms 2 times, one for the allocation, one to populate.=0D - mAvailableAlgoArray =3D AllocateZeroPool (RNG_AVAILABLE_ALGO_MAX);=0D + mAvailableAlgoArray =3D AllocateZeroPool (RNG_AVAILABLE_ALGO_MAX * sizeo= f (EFI_RNG_ALGORITHM));=0D if (mAvailableAlgoArray =3D=3D NULL) {=0D return EFI_OUT_OF_RESOURCES;=0D }=0D diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/Arm/ArmAlgo.c b/Secur= ityPkg/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;=0D =0D // Rng algorithms 2 times, one for the allocation, one to populate.=0D - mAvailableAlgoArray =3D AllocateZeroPool (RNG_AVAILABLE_ALGO_MAX);=0D + mAvailableAlgoArray =3D AllocateZeroPool (RNG_AVAILABLE_ALGO_MAX * sizeo= f (EFI_RNG_ALGORITHM));=0D if (mAvailableAlgoArray =3D=3D NULL) {=0D return EFI_OUT_OF_RESOURCES;=0D }=0D --=20 2.41.0.windows.1