From: "Chang, Abner via groups.io" <abner.chang=amd.com@groups.io>
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: [edk2-devel] [PATCH v2 1/2] EmbeddedPkg: Fix Android Boot Command Line Length Bug
Date: Tue, 21 Nov 2023 01:57:06 +0000 [thread overview]
Message-ID: <MN2PR12MB3966C30C7AE111063E9C80AEEABBA@MN2PR12MB3966.namprd12.prod.outlook.com> (raw)
In-Reply-To: <BY5PR12MB5544C3862D671BE2743F1E6CBAB4A@BY5PR12MB5544.namprd12.prod.outlook.com>
[AMD Official Use Only - General]
>I did not add this intentionally and even sent out an email asking the same on edk2-rfc if this should be done by maintainers unless you want me to do it as a ??separate patch set.
>Link to the message is https://edk2.groups.io/g/rfc/message/827
That's fine.
> String comes in from the https://github.com/tianocore/edk2/blob/master/EmbeddedPkg/Include/Library/AndroidBootImgLib.h#L43 header so it should ideally be self-contained. If you still think we should check for it, I can add a separate patch while keeping this one unaffected.
Reviewed-by: Abner Chang <abner.chang@amd.com>
Abner
From: Ashish Singhal <ashishsingha@nvidia.com>
Sent: Tuesday, November 21, 2023 3:34 AM
To: Chang, Abner <Abner.Chang@amd.com>; devel@edk2.groups.io; quic_llindhol@quicinc.com; ardb+tianocore@kernel.org; git@danielschaefer.me; Jeff Brasen <jbrasen@nvidia.com>
Subject: Re: [PATCH v2 1/2] EmbeddedPkg: Fix Android Boot Command Line Length Bug
[AMD Official Use Only - General]
Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
________________________________________
From: Chang, Abner <mailto:Abner.Chang@amd.com>
Sent: Monday, November 20, 2023 5:13 AM
To: Ashish Singhal <mailto:ashishsingha@nvidia.com>; mailto:devel@edk2.groups.io <mailto:devel@edk2.groups.io>; mailto:quic_llindhol@quicinc.com <mailto:quic_llindhol@quicinc.com>; mailto:ardb+tianocore@kernel.org <mailto:ardb+tianocore@kernel.org>; mailto:git@danielschaefer.me <mailto:git@danielschaefer.me>; Jeff Brasen <mailto:jbrasen@nvidia.com>
Subject: RE: [PATCH v2 1/2] EmbeddedPkg: Fix Android Boot Command Line Length Bug
External email: Use caution opening links or attachments
[AMD Official Use Only - General]
Thanks for this update and two more comments,
> -----Original Message-----
> From: Ashish Singhal <mailto:ashishsingha@nvidia.com>
> Sent: Wednesday, November 15, 2023 11:12 AM
> To: mailto:devel@edk2.groups.io; mailto:quic_llindhol@quicinc.com;
> mailto:ardb+tianocore@kernel.org; Chang, Abner <mailto:Abner.Chang@amd.com>;
> mailto:git@danielschaefer.me; mailto:jbrasen@nvidia.com
> Cc: Ashish Singhal <mailto:ashishsingha@nvidia.com>
> Subject: [PATCH v2 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.
>
>
> 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 <mailto:ashishsingha@nvidia.com>
> ---
> .../AndroidBootImgLib/AndroidBootImgLib.c | 31 +++++++++++--------
> 1 file changed, 18 insertions(+), 13 deletions(-)
>
> diff --git a/EmbeddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.c
> b/EmbeddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.c
> index 1359a66db2..f63648e60d 100644
> --- a/EmbeddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.c
> +++ b/EmbeddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.c
> @@ -322,11 +322,12 @@ AndroidBootImgGetFdt (
> EFI_STATUS
> AndroidBootImgUpdateArgs (
> IN VOID *BootImg,
> - OUT VOID *KernelArgs
> + OUT VOID **KernelArgs
> )
I know the original code doesn't have the function header. Would you mind to add it as we change the prototype of this function?
Or you probably would like to keep it as it for the consistence, as no function header for any of functions in this file.
I did not add this intentionally and even sent out an email asking the same on edk2-rfc if this should be done by maintainers unless you want me to do it as a separate patch set.
Link to the message is https://edk2.groups.io/g/rfc/message/827
> {
> CHAR8 ImageKernelArgs[ANDROID_BOOTIMG_KERNEL_ARGS_SIZE];
> EFI_STATUS Status;
> + UINT32 NewKernelArgSize;
>
> // Get kernel arguments from Android boot image
> Status = AndroidBootImgGetKernelArgs (BootImg, ImageKernelArgs);
> @@ -334,16 +335,23 @@ AndroidBootImgUpdateArgs (
> return Status;
> }
>
Do you think we have to check if the ASCII string size in ImageKernelArgs greater than ANDROID_BOOTIMG_KERNEL_ARGS_SIZE?
Thanks
Abner
String comes in from the https://github.com/tianocore/edk2/blob/master/EmbeddedPkg/Include/Library/AndroidBootImgLib.h#L43 header so it should ideally be self-contained. If you still think we should check for it, I can add a separate patch while keeping this one unaffected.
Thanks
Ashish
> + NewKernelArgSize = ANDROID_BOOTIMG_KERNEL_ARGS_SIZE;
> + *KernelArgs = AllocateZeroPool (sizeof (CHAR16) * NewKernelArgSize);
> + if (*KernelArgs == NULL) {
> + DEBUG ((DEBUG_ERROR, "Fail to allocate memory\n"));
> + return EFI_OUT_OF_RESOURCES;
> + }
> +
> AsciiStrToUnicodeStrS (
> ImageKernelArgs,
> - KernelArgs,
> - ANDROID_BOOTIMG_KERNEL_ARGS_SIZE >> 1
> + *KernelArgs,
> + NewKernelArgSize
> );
> // Append platform kernel arguments
> if (mAndroidBootImg->AppendArgs) {
> Status = mAndroidBootImg->AppendArgs (
> - KernelArgs,
> - ANDROID_BOOTIMG_KERNEL_ARGS_SIZE
> + *KernelArgs,
> + NewKernelArgSize
> );
> }
>
> @@ -616,6 +624,10 @@ AndroidBootImgBoot (
> UINTN RamdiskSize;
> IN VOID *FdtBase;
>
> + if ((Buffer == NULL) || (BufferSize == 0)) {
> + return EFI_INVALID_PARAMETER;
> + }
> +
> NewKernelArg = NULL;
> ImageHandle = NULL;
>
> @@ -637,14 +649,7 @@ AndroidBootImgBoot (
> goto Exit;
> }
>
> - NewKernelArg = AllocateZeroPool
> (ANDROID_BOOTIMG_KERNEL_ARGS_SIZE);
> - 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);
> if (EFI_ERROR (Status)) {
> goto Exit;
> }
> --
> 2.17.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#111496): https://edk2.groups.io/g/devel/message/111496
Mute This Topic: https://groups.io/mt/102598724/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
next prev parent reply other threads:[~2023-11-21 1:57 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-15 3:12 [edk2-devel] [PATCH v2 1/2] EmbeddedPkg: Fix Android Boot Command Line Length Bug Ashish Singhal via groups.io
2023-11-15 3:12 ` [edk2-devel] [PATCH v2 2/2] EmbeddedPkg: Allow longer android kernel command line Ashish Singhal via groups.io
2023-11-20 12:30 ` Chang, Abner via groups.io
2023-11-20 17:18 ` Ashish Singhal via groups.io
2023-11-21 1:52 ` Chang, Abner via groups.io
2023-11-20 12:13 ` [edk2-devel] [PATCH v2 1/2] EmbeddedPkg: Fix Android Boot Command Line Length Bug Chang, Abner via groups.io
2023-11-20 19:33 ` Ashish Singhal via groups.io
2023-11-21 1:57 ` Chang, Abner via groups.io [this message]
2023-11-29 16:37 ` Ashish Singhal via groups.io
2023-11-30 2:13 ` Chang, Abner via groups.io
2023-11-30 2:15 ` Ashish Singhal via groups.io
2023-11-30 2:20 ` Chang, Abner via groups.io
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=MN2PR12MB3966C30C7AE111063E9C80AEEABBA@MN2PR12MB3966.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