From nobody Fri May 17 07:47:29 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+106484+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+106484+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1687984445; cv=none; d=zohomail.com; s=zohoarc; b=IkORT6Khs6cZWKakHsR63U3HnqMVadLvW6XMHgvXZBkDCq24I7vmGGCmFPQdc7O16jD6zIFgTToyn2Lt8ospUrHFlxJMSaEglfx2L+1LGApRMGNGhOEGlXuwf5a7XrTTIo+6VTN0fokMvLA2jIYPIRut8b47/jIKSchQqtju/0w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1687984445; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=aVAIf3v7/o+5zf6LCfqe8WiwuRynbJyPu8Grd5z6YbM=; b=F0FaRi5/fRjgLr4qlSnjbVXgt1ljLpp4+DJVdInfi+taDckmdAVzZzVaP+Gpy7+vnZEP4cPl1WqQkhpYWur5z2tvghnIMBQKXpmlZAK7vY2QVLWdzm7BWmnOaByyqeGPEIXWXgs05inWRLqBNt6A8e4n0+CsyI5VwyCY6rsjRJk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+106484+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 168798444510548.80872636487277; Wed, 28 Jun 2023 13:34:05 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id tdxPYY1788612xNlzDcE7s2J; Wed, 28 Jun 2023 13:34:04 -0700 X-Received: from mail-pf1-f179.google.com (mail-pf1-f179.google.com [209.85.210.179]) by mx.groups.io with SMTP id smtpd.web10.1107.1687984443732621835 for ; Wed, 28 Jun 2023 13:34:03 -0700 X-Received: by mail-pf1-f179.google.com with SMTP id d2e1a72fcca58-67ef5af0ce8so165429b3a.2 for ; Wed, 28 Jun 2023 13:34:03 -0700 (PDT) X-Gm-Message-State: gMlcwwlE5PnCf7CnaYi1Eec2x1787277AA= X-Google-Smtp-Source: ACHHUZ48+UTBj90SLqXLY0FfvU415/E6dRxHt9OgCaAmTebrujtj70nvp0bKXVSHTc2J4ULFTi+VsQ== X-Received: by 2002:a05:6a20:3d24:b0:12b:3075:ef4c with SMTP id y36-20020a056a203d2400b0012b3075ef4cmr7168358pzi.27.1687984442890; Wed, 28 Jun 2023 13:34:02 -0700 (PDT) X-Received: from MININT-0U7P5GU.redmond.corp.microsoft.com ([2001:4898:80e8:36:c4fd:c6b3:a2ad:4140]) by smtp.gmail.com with ESMTPSA id x19-20020aa793b3000000b0064d681c753csm6064157pff.40.2023.06.28.13.34.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Jun 2023 13:34:02 -0700 (PDT) From: "Kun Qin" To: devel@edk2.groups.io Cc: Jiewen Yao , Jian J Wang , Sami Mujawar , Pierre Gondois Subject: [edk2-devel] [PATCH v1 1/2] SecurityPkg: RngDxe: Unify handling of zero guid Date: Wed, 28 Jun 2023 13:33:55 -0700 Message-ID: <20230628203357.2001-2-kuqin12@gmail.com> In-Reply-To: <20230628203357.2001-1-kuqin12@gmail.com> References: <20230628203357.2001-1-kuqin12@gmail.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,kuqin12@gmail.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1687984444; bh=U1wUGG1DSyMbJSDAw1LPLpplRFT0LHc4KPQrlhzGTu0=; h=Cc:Date:From:Reply-To:Subject:To; b=AvHEatJO0FDUORbm3zG8CRcoWaqXZOKZBNsfwpkv91LXtaRKphWNhaOsNltNYzetYDX VCJ2nQvL8CS7hLZj6ZyWv2dB2IVbfpxv4kBTcTXHFEjPXOGEJKu9HkHqWLH57yq6FvBOe vQQ8NURcUFy0+G89ai5hDYkSHrc8tbPEhZU= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1687984446158100006 Content-Type: text/plain; charset="utf-8" From: Kun Qin REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4491 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 Cc: Jian J Wang Cc: Sami Mujawar Cc: Pierre Gondois Signed-off-by: Kun Qin reviewed-by tag, Sami): --- 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++; =20 - 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 (); } =20 // Raw algorithm (Trng) --=20 2.41.0.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- 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/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Fri May 17 07:47:29 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+106485+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+106485+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1687984445; cv=none; d=zohomail.com; s=zohoarc; b=KjFQQIGt1v2zdHydjxgnLET9VgoByoJZER4rwAKmEf2o3jxYPrLw8dwzE9KttuIvfYHyDsuMZ7Gsjb/B35wli1Pb7YbFZkH2OFoJ7jXWx6LsIEFpfnQfavbzPnAvLUAqb6xPXAPzmX+4RUWggECjyXvmcVKbpVNZ1jxSTofEho8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1687984445; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=m7xPJI/JNSFGppSqr5Fcdc3JIUgwMykce8WVyGzBD8A=; b=E4PY2MEhnOJNADZLck6+q01aSGRkFlCaecDWJIIvu/lOl3o0fzTGPa5nvuEvWkubjtrRAmTeEJf+5KlAyVqtwpTLlnOlcuFJQMYXIpajB92cZ+vnW72R3DUZs5uSfvlqqsNQintx1ksoT6fECa2ZKnbmHxZllJ6CHX8nHGy1cNI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+106485+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1687984445485670.5872712205448; Wed, 28 Jun 2023 13:34:05 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id x9T9YY1788612x82oB6VadQY; Wed, 28 Jun 2023 13:34:05 -0700 X-Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.169]) by mx.groups.io with SMTP id smtpd.web11.1101.1687984444454786484 for ; Wed, 28 Jun 2023 13:34:04 -0700 X-Received: by mail-pf1-f169.google.com with SMTP id d2e1a72fcca58-666ecb21f86so162290b3a.3 for ; Wed, 28 Jun 2023 13:34:04 -0700 (PDT) X-Gm-Message-State: 5SLqGQUQsJIgEFsvGi38UF6Fx1787277AA= X-Google-Smtp-Source: ACHHUZ7muy5aRMaLiAt71zODe1xAP2WJDNRcNJRVfaddGPIEVF8UTeL98h2o9ZK8gkJeNQlbpMyWqQ== X-Received: by 2002:a05:6a21:339a:b0:122:450b:48aa with SMTP id yy26-20020a056a21339a00b00122450b48aamr27688145pzb.21.1687984443760; Wed, 28 Jun 2023 13:34:03 -0700 (PDT) X-Received: from MININT-0U7P5GU.redmond.corp.microsoft.com ([2001:4898:80e8:36:c4fd:c6b3:a2ad:4140]) by smtp.gmail.com with ESMTPSA id x19-20020aa793b3000000b0064d681c753csm6064157pff.40.2023.06.28.13.34.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Jun 2023 13:34:03 -0700 (PDT) From: "Kun Qin" To: devel@edk2.groups.io Cc: Jiewen Yao , Jian J Wang , Sami Mujawar , Pierre Gondois Subject: [edk2-devel] [PATCH v1 2/2] SecurityPkg: RngDxe: Fixing mAvailableAlgoArray allocator Date: Wed, 28 Jun 2023 13:33:56 -0700 Message-ID: <20230628203357.2001-3-kuqin12@gmail.com> In-Reply-To: <20230628203357.2001-1-kuqin12@gmail.com> References: <20230628203357.2001-1-kuqin12@gmail.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,kuqin12@gmail.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1687984445; bh=G3GlUqHMM/2oKUF5/dZDx1rIOPO1A8+pBjRXStNFnmA=; h=Cc:Date:From:Reply-To:Subject:To; b=l14XMbNgpZzua+h+URghXPk5BzGF9UUTTFNZKdssra/oopvR3o5W4ePLJYA/7+AWHO9 GUtLRQ4tCjeaMYXofr7HcptOS8tIz+2H38XF7VDS7zouYFCOMU7CbBrgQPHRirLa4NKbK NvlvNVszyyJgNQLrg5HxUlAE5KzrEyBVlSg= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1687984446148100005 Content-Type: text/plain; charset="utf-8" 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 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 de279cdadeea..1d412ecff61d 100644 --- a/SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/AArch64Algo.c +++ b/SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/AArch64Algo.c @@ -33,7 +33,7 @@ GetAvailableAlgorithms ( UINT16 MinorRevision; =20 // Rng algorithms 2 times, one for the allocation, one to populate. - mAvailableAlgoArray =3D AllocateZeroPool (RNG_AVAILABLE_ALGO_MAX); + mAvailableAlgoArray =3D AllocateZeroPool (RNG_AVAILABLE_ALGO_MAX * sizeo= f (EFI_RNG_ALGORITHM)); if (mAvailableAlgoArray =3D=3D NULL) { return EFI_OUT_OF_RESOURCES; } 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; =20 // Rng algorithms 2 times, one for the allocation, one to populate. - mAvailableAlgoArray =3D AllocateZeroPool (RNG_AVAILABLE_ALGO_MAX); + mAvailableAlgoArray =3D AllocateZeroPool (RNG_AVAILABLE_ALGO_MAX * sizeo= f (EFI_RNG_ALGORITHM)); if (mAvailableAlgoArray =3D=3D NULL) { return EFI_OUT_OF_RESOURCES; } --=20 2.41.0.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#106485): https://edk2.groups.io/g/devel/message/106485 Mute This Topic: https://groups.io/mt/99839049/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-