From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) by mx.groups.io with SMTP id smtpd.web10.43182.1688414959441578968 for ; Mon, 03 Jul 2023 13:09:19 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20221208 header.b=PvxBifJI; spf=pass (domain: gmail.com, ip: 209.85.214.175, mailfrom: kuqin12@gmail.com) Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-1b89600a37fso7483305ad.2 for ; Mon, 03 Jul 2023 13:09:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1688414959; x=1691006959; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=wqJllJQayiGZwZwMO/VAH3wuM0cEBYEMpfe1u1mUPNM=; b=PvxBifJI4to2zXD1xxCnBEAsVLvLMVhies2w17Iw5CSTLlYMTRFfrnxn6rrYvVXeSv uUwnB2KhJRgFdFSJbOMm4KQa2qRvYZhHIRdy/OHhbWQb5TB0oVQSfvtW5t6MZJYHfeQf hIvr+NLyqiJseEhrYiB1EViKR6QauVQbs0QE5oSGVU4hOi0iPUf0X1t9MEk4+/GCcPqD ebwfzHrPQTdJcgkWlRiNX7iaYM/8vAJoVww7QOhsng+cdTVd/xJ6mDJThIF+PJU676zv 7hp545dwzNb7ZubajONuopolZTfHoWwz9H3HfUId4rFoTToCw2ofYsFnHQP4Bkz5PbD1 qx8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688414959; x=1691006959; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=wqJllJQayiGZwZwMO/VAH3wuM0cEBYEMpfe1u1mUPNM=; b=JLnqQFEJQyYBatzTB5kF6GCzFgCgwy+KPKOQgW0En3w5vctL8to2ygeYHS5oWloESg nQuw4FRlgXkAFGG8QVtdQS5LY3dwn6RsgzBC+0wIDlAWRB27GIILDCSiHU09IIpo/QUG sophU9bE73mqzn8pRopf/kw5UzrfRbi43JogWNU0I8GhnYzWv9+y+uJ+WbPpz/k7qMIt eGBQLbGhC0a+774LKcJYRVadG9keUSdk/SkJ90QlnFK0HaiXVHEMKBvxx3u/rR8nkR4j oM5WTohn9w3NjeXhsU6fC/nAdsHheKxCrilBCQfMqlsaX+zXEnF3jZToJ8o4z5iU+HDU l6rQ== X-Gm-Message-State: ABy/qLZD8PhJmysWrn7g0tSlS4V6CwN2z5HA0jeDEaQs1Jfyf1IwCGMt wvxOKKlCkKANdJ8J0vQ1tOtBt6R9F68= X-Google-Smtp-Source: APBJJlHzR7sl7fckwuA3soj8u0+4SK0B4508HqaNsGcTjO+b7swhH4SjpuSnB9U2iRrzxuMVcqK++A== X-Received: by 2002:a17:902:e743:b0:1b5:1654:96d4 with SMTP id p3-20020a170902e74300b001b5165496d4mr10890033plf.4.1688414958666; Mon, 03 Jul 2023 13:09:18 -0700 (PDT) Return-Path: Received: from ?IPV6:2001:4898:d8:33:ec10:1d7e:be2:5742? ([2001:4898:80e8:3:6c30:1d7e:be2:5742]) by smtp.gmail.com with ESMTPSA id x18-20020a170902821200b001b83dc7feabsm9245888pln.304.2023.07.03.13.09.17 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 03 Jul 2023 13:09:18 -0700 (PDT) Message-ID: <208c571d-a05e-e3c7-b94d-9e9b25f27f0c@gmail.com> Date: Mon, 3 Jul 2023 13:09:17 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 Subject: Re: [edk2-devel] [PATCH v2 1/1] SecurityPkg: RngDxe: Fixing mAvailableAlgoArray allocator To: devel@edk2.groups.io, Sami Mujawar Cc: Jiewen Yao , Jian J Wang , Pierre Gondois References: <20230629235919.2077-1-kuqin12@gmail.com> <176D46B1D9752C4A.23465@groups.io> From: "Kun Qin" In-Reply-To: <176D46B1D9752C4A.23465@groups.io> Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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 > > 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 > 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; > > > > // 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; > > } >