From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id A1354941DA0 for ; Mon, 6 Nov 2023 17:55:12 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=1lcmxZzAlP8z7wWaNeEmbVxy1dAZYqcsO+pLgWAVufc=; c=relaxed/simple; d=groups.io; h=ARC-Seal:ARC-Message-Signature:ARC-Authentication-Results:From:To:Subject:Thread-Topic:Thread-Index:Date:Message-ID:References:In-Reply-To:Accept-Language:msip_labels:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type; s=20140610; t=1699293311; v=1; b=irvNgVLTLBhLa8OpT1MbkSuEzyRBA0sRoCCgqb56SeuBj4nmCNPHoCMP7WkXKJkbxXbJCqPE GMkYbM+TjgIrPgV4ehPMlwoEjspcorkSnWUnJuMbeSDArewfN9pkfjUdrLV4JPQwzdIiclA0BR7 ZZme4GZZmACw1LE1xypAnQ3Y= X-Received: by 127.0.0.2 with SMTP id Gw4EYY7687511xu2vX2TsEpT; Mon, 06 Nov 2023 09:55:11 -0800 X-Received: from NAM11-DM6-obe.outbound.protection.outlook.com (NAM11-DM6-obe.outbound.protection.outlook.com [40.107.223.68]) by mx.groups.io with SMTP id smtpd.web11.61135.1699293310637857224 for ; Mon, 06 Nov 2023 09:55:10 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MojGYk9HGkhi6FjET1E2mbxO+IFJ90coLHKSmIGdhYTRdptPf39Ari6UtWC9RTh2kyxo+qEtuPAa704fMBh0eVesVTb/2UiVnmxpzvkhZ2TcbDTZMfClTL60Kv/06VyY3ur7KgK3g2d3wbDeqB8iv0ADQhKJpjRW6AXux+jZHKi/Fvi8QkoHtIAXewITqgLNeza6Xyz/ZGETaSefwh+gaSbNylfbB/kua5ZhzVYjI+nHrbaI9sxWHaE0cN6Ub2nSz8W/zUH+meB2GnKVTZsm/+xScSrDg6IzT6Wc2oiGyXL8outl7rjlFrCKbnDVbFjiVY8UDfD2b9fEBNzfi5B3dg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=BR5z7ZrFAfKeC4efe/kYUgJMar1HiEuIF44RXxQltA0=; b=AsyzT75YvaOhfMjnM/2+Khe3hc0kyxhUSw2/FfsFzf3vaOSF7+Z/4hYmws1qdtv9xE+D1zToLDV1NiqNcRbhlmoVBxAt2GRyYFURrU64qgzGsNAblkcKyf+L2Po6pqesemSNKfekzv6cthmWFSmYiBUCd8U6+MNJ1MmJLMX4t5u88Ero7qgQocB0pDyPTk/ym1LZo/voFxTon1vIQQURuzjTUY09FRw2Y/9VVMeVWFac0WwCGZD1PfmiBgYIh6lBa+QmJxIFcf9PhGeZm85l2E3jdEylWdmlUjgjELFFn1SBTTUbKR632Rg/z/UwYV8w7+2pkyP3E84F6KjffYBvtA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none X-Received: from BY5PR12MB5544.namprd12.prod.outlook.com (2603:10b6:a03:1d9::22) by IA0PR12MB7578.namprd12.prod.outlook.com (2603:10b6:208:43d::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.28; Mon, 6 Nov 2023 17:55:05 +0000 X-Received: from BY5PR12MB5544.namprd12.prod.outlook.com ([fe80::dfe9:3fbf:8f9a:13a6]) by BY5PR12MB5544.namprd12.prod.outlook.com ([fe80::dfe9:3fbf:8f9a:13a6%3]) with mapi id 15.20.6954.028; Mon, 6 Nov 2023 17:55:05 +0000 From: "Ashish Singhal via groups.io" To: "devel@edk2.groups.io" , "quic_llindhol@quicinc.com" , "ardb+tianocore@kernel.org" , "abner.chang@amd.com" , "git@danielschaefer.me" , Jeff Brasen Subject: Re: [edk2-devel] [PATCH 1/2] EmbeddedPkg: Fix Android Boot Command Line Length Bug Thread-Topic: [PATCH 1/2] EmbeddedPkg: Fix Android Boot Command Line Length Bug Thread-Index: AQHaC28o45KxKTqhVEK1ddFT1LUAIrBtncIY Date: Mon, 6 Nov 2023 17:55:05 +0000 Message-ID: References: <999da9572bc2ff0bbb8d7a69740256afd6ad5cde.1698697168.git.ashishsingha@nvidia.com> In-Reply-To: <999da9572bc2ff0bbb8d7a69740256afd6ad5cde.1698697168.git.ashishsingha@nvidia.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: BY5PR12MB5544:EE_|IA0PR12MB7578:EE_ x-ms-office365-filtering-correlation-id: 172bc5d6-9a6c-4ca7-1742-08dbdef181f6 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam-message-info: xO5ZOXLfK6ZTQ3sWQonz/y/8GaczEw7tq34jLH+veXO1FAd1c4gi5bbsd5CFRRp18PEbV3QmpNy0fKWJ/AcTV8GojLP5u7ctbW1l3AoDcOFnnrYMzFFFlh34jyt5mKd+mMUxeqH56d4L9wHfA5sq7VZumV9O6keK6YBO6YTwFSIgEpWlSWRYxiOS5zVgCpUL/Pqc+7B8CmqhP4tkq+uMJHvpZyT8l70Icy4cHSvcOpRZ39o4gYM9PO+pxj6zg1gmbz7NGMY2flWzcoafS1oyEo61kNTQ0LYzalz3rzHL4Gb1yth289ID4gTNOnONhTf6jzjn73XFC4+uaTRgA46NXCNpXyvRsmr3ajCwBbFNaDJjbFd/BnS3gC9C8m1HcQGfdqpUFwUfRjEXR+djCFooasaDlpxwLvf+WJ22saU1I+D8yNi83Lqj7Z48u+LBzEtKlv5UbUkFQCPrNfWJeWvBhCZCut/LPVFsguDvqLIxZNBxmONBPp4djbncP4qmlZPl/AkLdVDYRmoprTzJFPDaiXzNMClD50EqM5maFOKIiNPETSaoC5s4xu4e8Z0dtE4XmEHCUYiAlyEqA0JiaLARyWyRiiYpytmVmXuIVfT9goS95SM3CSrgiaeiBsgrcOU2 x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?kwVRU2f1OMoSIqW3iUQ3rTBwX4U0EZ5masADPhnxKeOvf2eiQE4/LKTw6WST?= =?us-ascii?Q?Gbjamr/kFrECcUthMIWo2/K+YyHr+TivXBYRcx29S8Q7LG2XO41Rgjk5n81G?= =?us-ascii?Q?bbmu6554CdQFHuRq8v0bAfy3OAvNzf3lWg2Hc4bbybpK5NHlrhIk9OsMGKej?= =?us-ascii?Q?KUt4vQze22rr39z45uSWxSsm7UiTGzXpxU5hPJkGkWx3RZCLOC2nlxgyk22c?= =?us-ascii?Q?qlnn1E/N+nbY+e2DibCmsQqRk9fLoDZrAqqwytyzZU/TWUAJJakBLhpnwjZT?= =?us-ascii?Q?V4oKfrPIAfci+arOfBwTrWOHSn8IFitXjtWQ8jAiSQnnsQsH2vupYqaFE0xW?= =?us-ascii?Q?Biaq6pg07CfxePNvWBKphNggHJrhswYWkF9OhFbKXd7yxV3rSIpwRMIeto3+?= =?us-ascii?Q?5WIegMk1PSBykaZTaK3vgVIrNZiuFpX+r1t/RNT6ls3yh/JbLPDiaIHUT3wg?= =?us-ascii?Q?d9rmLXIBFRnmAqykchfniN8IB/HX4yaCiHRVAg++Tmd2yWCCmwgr3pJe5y4M?= =?us-ascii?Q?X3JWNVpCXtFvL55yHCnpWFk91vJs4f1/Stsa4jN/R9yxwtxVA0hPKPuz9hYO?= =?us-ascii?Q?6b1QR2fyDAHPV/OZfhlG00weFFg0M3RUf3damOGLfgvyhp4vwQq6g1+G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/M4Dp+zhMjAT0hCgNdH?= =?us-ascii?Q?id0uIEjVOHvADDCYF4ycUYl6ypCyrXbJFTMYwW43?= MIME-Version: 1.0 X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: BY5PR12MB5544.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 172bc5d6-9a6c-4ca7-1742-08dbdef181f6 X-MS-Exchange-CrossTenant-originalarrivaltime: 06 Nov 2023 17:55:05.1382 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: t4mUbauRBsXE7wfCgbIhdIhjBPyfkxBRnViGQqYv7AwIKSN8VxmsW2wdYIj2pY55L+SqxR88tWYmM62UI5JuqA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB7578 Precedence: Bulk 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,ashishsingha@nvidia.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: JF2tti5zJLxdg7Ors955hwTfx7686176AA= Content-Language: en-US Content-Type: multipart/alternative; boundary="_000_BY5PR12MB5544A2E063E5B0B72BCF7E74BAAAABY5PR12MB5544namp_" X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=irvNgVLT; dmarc=none; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io --_000_BY5PR12MB5544A2E063E5B0B72BCF7E74BAAAABY5PR12MB5544namp_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hello, Hoping to get some feedback on these 2 patches this week. Thanks Ashish ________________________________ From: Ashish Singhal Sent: Monday, October 30, 2023 2:24 PM To: devel@edk2.groups.io ; quic_llindhol@quicinc.com = ; ardb+tianocore@kernel.org ; abner.chang@amd.com ; git@danielschaefer.me <= git@danielschaefer.me>; Jeff Brasen Cc: Ashish Singhal Subject: [PATCH 1/2] EmbeddedPkg: Fix Android Boot Command Line Length Bug Curently, AndroidBootImgLib expects input kernel command line to never exceed 256 unicode characters where the image header allows for 512 ascii characters. If image header allows 512 ascii characters, similar number of unicode characters should be allowed at the minimum. Signed-off-by: Ashish Singhal --- .../AndroidBootImgLib/AndroidBootImgLib.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/EmbeddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.c b/Em= beddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.c index 1359a66db2..02769cd0df 100644 --- a/EmbeddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.c +++ b/EmbeddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.c @@ -321,8 +321,9 @@ AndroidBootImgGetFdt ( EFI_STATUS AndroidBootImgUpdateArgs ( - IN VOID *BootImg, - OUT VOID *KernelArgs + IN VOID *BootImg, + OUT VOID *KernelArgs, + IN UINT32 KernelArgsSize ) { CHAR8 ImageKernelArgs[ANDROID_BOOTIMG_KERNEL_ARGS_SIZE]; @@ -337,13 +338,13 @@ AndroidBootImgUpdateArgs ( AsciiStrToUnicodeStrS ( ImageKernelArgs, KernelArgs, - ANDROID_BOOTIMG_KERNEL_ARGS_SIZE >> 1 + KernelArgsSize ); // Append platform kernel arguments if (mAndroidBootImg->AppendArgs) { Status =3D mAndroidBootImg->AppendArgs ( KernelArgs, - ANDROID_BOOTIMG_KERNEL_ARGS_SIZE + KernelArgsSize ); } @@ -611,11 +612,16 @@ AndroidBootImgBoot ( MEMORY_DEVICE_PATH KernelDevicePath; EFI_HANDLE ImageHandle; VOID *NewKernelArg; + UINT32 NewKernelArgSize; EFI_LOADED_IMAGE_PROTOCOL *ImageInfo; VOID *RamdiskData; UINTN RamdiskSize; IN VOID *FdtBase; + if ((Buffer =3D=3D NULL) || (BufferSize =3D=3D 0)) { + return EFI_INVALID_PARAMETER; + } + NewKernelArg =3D NULL; ImageHandle =3D NULL; @@ -637,14 +643,15 @@ AndroidBootImgBoot ( goto Exit; } - NewKernelArg =3D AllocateZeroPool (ANDROID_BOOTIMG_KERNEL_ARGS_SIZE); + NewKernelArgSize =3D ANDROID_BOOTIMG_KERNEL_ARGS_SIZE; + NewKernelArg =3D AllocateZeroPool (sizeof (CHAR16) * NewKernelArgSiz= e); if (NewKernelArg =3D=3D NULL) { DEBUG ((DEBUG_ERROR, "Fail to allocate memory\n")); Status =3D EFI_OUT_OF_RESOURCES; goto Exit; } - Status =3D AndroidBootImgUpdateArgs (Buffer, NewKernelArg); + Status =3D AndroidBootImgUpdateArgs (Buffer, NewKernelArg, NewKernelArgS= ize); if (EFI_ERROR (Status)) { goto Exit; } -- 2.17.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 (#110752): https://edk2.groups.io/g/devel/message/110752 Mute This Topic: https://groups.io/mt/102284239/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- --_000_BY5PR12MB5544A2E063E5B0B72BCF7E74BAAAABY5PR12MB5544namp_ Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable
Hello,

Hoping to get some feedback on these 2 patches this week.

Thanks
Ashish

From: Ashish Singhal <as= hishsingha@nvidia.com>
Sent: Monday, October 30, 2023 2:24 PM
To: devel@edk2.groups.io <devel@edk2.groups.io>; quic_llindhol= @quicinc.com <quic_llindhol@quicinc.com>; ardb+tianocore@kernel.org &= lt;ardb+tianocore@kernel.org>; abner.chang@amd.com <abner.chang@amd.c= om>; git@danielschaefer.me <git@danielschaefer.me>; Jeff Brasen <jbrasen@nvidia.com>
Cc: Ashish Singhal <ashishsingha@nvidia.com>
Subject: [PATCH 1/2] EmbeddedPkg: Fix Android Boot Command Line Leng= th Bug
 
Curently, AndroidBootImgLib expects input kernel c= ommand line
to never exceed 256 unicode characters where the image header
allows for 512 ascii characters. If image header allows 512
ascii characters, similar number of unicode characters should be
allowed at the minimum.

Signed-off-by: Ashish Singhal <ashishsingha@nvidia.com>
---
 .../AndroidBootImgLib/AndroidBootImgLib.c     | 1= 9 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/EmbeddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.c b/Em= beddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.c
index 1359a66db2..02769cd0df 100644
--- a/EmbeddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.c
+++ b/EmbeddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.c
@@ -321,8 +321,9 @@ AndroidBootImgGetFdt (
 
 EFI_STATUS
 AndroidBootImgUpdateArgs (
-  IN  VOID  *BootImg,
-  OUT VOID  *KernelArgs
+  IN  VOID    *BootImg,
+  OUT VOID    *KernelArgs,
+  IN  UINT32  KernelArgsSize
   )
 {
   CHAR8       ImageKernelArgs[ANDR= OID_BOOTIMG_KERNEL_ARGS_SIZE];
@@ -337,13 +338,13 @@ AndroidBootImgUpdateArgs (
   AsciiStrToUnicodeStrS (
     ImageKernelArgs,
     KernelArgs,
-    ANDROID_BOOTIMG_KERNEL_ARGS_SIZE >> 1
+    KernelArgsSize
     );
   // Append platform kernel arguments
   if (mAndroidBootImg->AppendArgs) {
     Status =3D mAndroidBootImg->AppendArgs (
            &nb= sp;            =         KernelArgs,
-            &n= bsp;            = ;       ANDROID_BOOTIMG_KERNEL_ARGS_SIZE
+            &n= bsp;            = ;       KernelArgsSize
            &nb= sp;            =         );
   }
 
@@ -611,11 +612,16 @@ AndroidBootImgBoot (
   MEMORY_DEVICE_PATH       &n= bsp; KernelDevicePath;
   EFI_HANDLE        &nbs= p;        ImageHandle;
   VOID         &nbs= p;             = *NewKernelArg;
+  UINT32          &= nbsp;          NewKernelArgSiz= e;
   EFI_LOADED_IMAGE_PROTOCOL  *ImageInfo;
   VOID         &nbs= p;             = *RamdiskData;
   UINTN         &nb= sp;            Ramdi= skSize;
   IN  VOID        &= nbsp;          *FdtBase;
 
+  if ((Buffer =3D=3D NULL) || (BufferSize =3D=3D 0)) {
+    return EFI_INVALID_PARAMETER;
+  }
+
   NewKernelArg =3D NULL;
   ImageHandle  =3D NULL;
 
@@ -637,14 +643,15 @@ AndroidBootImgBoot (
     goto Exit;
   }
 
-  NewKernelArg =3D AllocateZeroPool (ANDROID_BOOTIMG_KERNEL_ARGS_SIZE= );
+  NewKernelArgSize =3D ANDROID_BOOTIMG_KERNEL_ARGS_SIZE;
+  NewKernelArg     =3D AllocateZeroPool (sizeof (= CHAR16) * NewKernelArgSize);
   if (NewKernelArg =3D=3D NULL) {
     DEBUG ((DEBUG_ERROR, "Fail to allocate memory= \n"));
     Status =3D EFI_OUT_OF_RESOURCES;
     goto Exit;
   }
 
-  Status =3D AndroidBootImgUpdateArgs (Buffer, NewKernelArg);
+  Status =3D AndroidBootImgUpdateArgs (Buffer, NewKernelArg, NewKerne= lArgSize);
   if (EFI_ERROR (Status)) {
     goto Exit;
   }
--
2.17.1

_._,_._,_

Groups.io Links:

=20 You receive all messages sent to this group. =20 =20

View/Reply Online (#110752) | =20 | Mute= This Topic | New Topic
Your Subscriptio= n | Contact Group Owner | Unsubscribe [rebecca@openfw.io]

_._,_._,_
--_000_BY5PR12MB5544A2E063E5B0B72BCF7E74BAAAABY5PR12MB5544namp_--