public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Ashish Singhal via groups.io" <ashishsingha=nvidia.com@groups.io>
To: "Chang, Abner" <Abner.Chang@amd.com>,
	"devel@edk2.groups.io" <devel@edk2.groups.io>,
	"quic_llindhol@quicinc.com" <quic_llindhol@quicinc.com>,
	"ardb+tianocore@kernel.org" <ardb+tianocore@kernel.org>,
	"git@danielschaefer.me" <git@danielschaefer.me>,
	Jeff Brasen <jbrasen@nvidia.com>
Subject: Re: [edk2-devel] [PATCH 1/2] EmbeddedPkg: Fix Android Boot Command Line Length Bug
Date: Wed, 15 Nov 2023 03:13:19 +0000	[thread overview]
Message-ID: <BY5PR12MB5544A102AE4728391133A5D0BAB1A@BY5PR12MB5544.namprd12.prod.outlook.com> (raw)
In-Reply-To: <MN2PR12MB3966822C72AE3C5129993E4CEAAEA@MN2PR12MB3966.namprd12.prod.outlook.com>

[-- Attachment #1: Type: text/plain, Size: 5724 bytes --]

Hello Abner,

Thanks for the feedback. I have pushed v2 of the patch set.

Thanks
Ashish
________________________________
From: Chang, Abner <Abner.Chang@amd.com>
Sent: Thursday, November 9, 2023 7:06 PM
To: Ashish Singhal <ashishsingha@nvidia.com>; devel@edk2.groups.io <devel@edk2.groups.io>; quic_llindhol@quicinc.com <quic_llindhol@quicinc.com>; ardb+tianocore@kernel.org <ardb+tianocore@kernel.org>; git@danielschaefer.me <git@danielschaefer.me>; Jeff Brasen <jbrasen@nvidia.com>
Subject: RE: [PATCH 1/2] EmbeddedPkg: Fix Android Boot Command Line Length Bug

External email: Use caution opening links or attachments


[AMD Official Use Only - General]






From: Ashish Singhal <ashishsingha@nvidia.com>
Sent: Tuesday, November 7, 2023 1:55 AM
To: devel@edk2.groups.io; quic_llindhol@quicinc.com; ardb+tianocore@kernel.org; Chang, Abner <Abner.Chang@amd.com>; git@danielschaefer.me; Jeff Brasen <jbrasen@nvidia.com>
Subject: Re: [PATCH 1/2] EmbeddedPkg: Fix Android Boot Command Line Length Bug



Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.



Hello,



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



Thanks

Ashish

________________________________

From: Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>
Sent: Monday, October 30, 2023 2:24 PM
To: devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>>; quic_llindhol@quicinc.com<mailto:quic_llindhol@quicinc.com> <quic_llindhol@quicinc.com<mailto:quic_llindhol@quicinc.com>>; ardb+tianocore@kernel.org<mailto:ardb+tianocore@kernel.org> <ardb+tianocore@kernel.org<mailto:ardb+tianocore@kernel.org>>; abner.chang@amd.com<mailto:abner.chang@amd.com> <abner.chang@amd.com<mailto:abner.chang@amd.com>>; git@danielschaefer.me<mailto:git@danielschaefer.me> <git@danielschaefer.me<mailto:git@danielschaefer.me>>; Jeff Brasen <jbrasen@nvidia.com<mailto:jbrasen@nvidia.com>>
Cc: Ashish Singhal <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>
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 <ashishsingha@nvidia.com<mailto:ashishsingha@nvidia.com>>
---
 .../AndroidBootImgLib/AndroidBootImgLib.c     | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/EmbeddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.c b/EmbeddedPkg/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 = 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 == NULL) || (BufferSize == 0)) {
+    return EFI_INVALID_PARAMETER;
+  }
+
   NewKernelArg = NULL;
   ImageHandle  = NULL;

@@ -637,14 +643,15 @@ AndroidBootImgBoot (
     goto Exit;
   }

-  NewKernelArg = AllocateZeroPool (ANDROID_BOOTIMG_KERNEL_ARGS_SIZE);
+  NewKernelArgSize = ANDROID_BOOTIMG_KERNEL_ARGS_SIZE;
+  NewKernelArg     = AllocateZeroPool (sizeof (CHAR16) * NewKernelArgSize);

I think you can just move the memory allocation code to inside AndroidBootImgUpdateArgs then you don’t need the additional arg for AndroidBootImgUpdateArgs.

Also Change AndroidBootImgUpdateArgs (Buffer, NewKernelArg); to AndroidBootImgUpdateArgs (Buffer, &NewKernelArg);

With this the code looks simple.

thanks

Abner

   if (NewKernelArg == NULL) {
     DEBUG ((DEBUG_ERROR, "Fail to allocate memory\n"));
     Status = EFI_OUT_OF_RESOURCES;
     goto Exit;
   }

-  Status = AndroidBootImgUpdateArgs (Buffer, NewKernelArg);
+  Status = AndroidBootImgUpdateArgs (Buffer, NewKernelArg, NewKernelArgSize);
   if (EFI_ERROR (Status)) {
     goto Exit;
   }
--
2.17.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#111230): https://edk2.groups.io/g/devel/message/111230
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]
-=-=-=-=-=-=-=-=-=-=-=-



[-- Attachment #2: Type: text/html, Size: 13665 bytes --]

      reply	other threads:[~2023-11-15  3:13 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-30 20:24 [edk2-devel] [PATCH 1/2] EmbeddedPkg: Fix Android Boot Command Line Length Bug Ashish Singhal via groups.io
2023-10-30 20:24 ` [edk2-devel] [PATCH 2/2] EmbeddedPkg: Allow longer android kernel command line Ashish Singhal via groups.io
2023-11-06 17:55 ` [edk2-devel] [PATCH 1/2] EmbeddedPkg: Fix Android Boot Command Line Length Bug Ashish Singhal via groups.io
2023-11-10  2:06   ` Chang, Abner via groups.io
2023-11-15  3:13     ` Ashish Singhal via groups.io [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=BY5PR12MB5544A102AE4728391133A5D0BAB1A@BY5PR12MB5544.namprd12.prod.outlook.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox