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 5B9CC7803D2 for ; Mon, 30 Oct 2023 20:25:03 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=/LMhklPMZayykzoUXoP8rKmWh+94FswdyEOktBiONpo=; c=relaxed/simple; d=groups.io; h=ARC-Seal:ARC-Message-Signature:ARC-Authentication-Results:Received-SPF:From:To:CC:Subject:Date:Message-ID:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding:Content-Type; s=20140610; t=1698697502; v=1; b=CVjkhRopOoXbg9UA4XhmDJxp0IMDGGoWb+cKQhRD71PC4tZ5ilQV5YdIKlvMpS0HqsqXox3K QDIPypDk2P+Vd75I4/fxed6bY8uyfaA7T51u9EbxivdkW2PXzwxB+SgxRfYt/lptsuumAHgP1KV if83mzYJQqeK3Kxr9E8V96OA= X-Received: by 127.0.0.2 with SMTP id qpVPYY7687511x1iNgTU1RM4; Mon, 30 Oct 2023 13:25:02 -0700 X-Received: from NAM10-MW2-obe.outbound.protection.outlook.com (NAM10-MW2-obe.outbound.protection.outlook.com [40.107.94.43]) by mx.groups.io with SMTP id smtpd.web10.169087.1698697501169670606 for ; Mon, 30 Oct 2023 13:25:01 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EOjUv5q3PL2TXmrbJB8vdpE84mpFtDLYMlXbR97SGP5aaasT9cmx6jN+baBOppwNzS2ncso7kWlz9oOH3cAfXd8OEJyvlS7IsIX7t9uEDk56TnJXkeIgjG6f1tBNeiG40J6BZImwLVjhea6BjHZnZt4n7ZNH17hjL1jP3RCjAgPBvP7iShf9MEDa/6rCrJYQJdpytssj6W+tplcXTr2gCL+OMXp9zfAW+uI1f8NYIWYPB9bOiAfYas8wpVafVRR+Ijyi1kHf86Ik4PAfq7kp0qhrfL8y+PI86qNqAaHUkSTS3DXE9gze3AY3ONJlh/rli5ZXoor87roUeUIS5L34Og== 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=tmtEPL1888FwDCLULN7TFPDA86xVpVIwcaf+KM0KR+0=; b=SaSoED5NLv0e0nAhi8urm17vB0g44jETfUh0HZGc3Lv5saFdcWAH30+DLei+jwZSBZ0ufUxzRO0qU/HzHPFcyV9KAXSNQRM85V6XQuZwIDIytKuVZQ5n26DF2nV+nOB7TN4w5+6UCjceeGx+/Jcn8oC7jroSx+kmn7KDVHyBrUGI7mr0eu3K9RFWbmqUs1hzNmYcl29xpyctAA+L1ggMYeSrg9L+LQPGQ21XxN7Fy/+Hqdj8RorO3mf12rWTm3F8FgEvX4P7478oZQjuBbZVQ9L+pcwUJ9K8V1mSMpNawkxlMqiwj93VqgeCuBLlompLZ5+l9ZZqom4QJTLXvCPsPg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.232) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) X-Received: from MN2PR18CA0030.namprd18.prod.outlook.com (2603:10b6:208:23c::35) by IA0PR12MB8694.namprd12.prod.outlook.com (2603:10b6:208:488::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6933.28; Mon, 30 Oct 2023 20:24:57 +0000 X-Received: from BL6PEPF0001AB73.namprd02.prod.outlook.com (2603:10b6:208:23c:cafe::11) by MN2PR18CA0030.outlook.office365.com (2603:10b6:208:23c::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6933.28 via Frontend Transport; Mon, 30 Oct 2023 20:24:57 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.232) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.232 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.232; helo=mail.nvidia.com; pr=C X-Received: from mail.nvidia.com (216.228.118.232) by BL6PEPF0001AB73.mail.protection.outlook.com (10.167.242.166) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6933.22 via Frontend Transport; Mon, 30 Oct 2023 20:24:57 +0000 X-Received: from drhqmail202.nvidia.com (10.126.190.181) by mail.nvidia.com (10.127.129.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Mon, 30 Oct 2023 13:24:48 -0700 X-Received: from drhqmail201.nvidia.com (10.126.190.180) by drhqmail202.nvidia.com (10.126.190.181) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Mon, 30 Oct 2023 13:24:47 -0700 X-Received: from ashishsingha-lnx.nvidia.com (10.127.8.13) by mail.nvidia.com (10.126.190.180) with Microsoft SMTP Server id 15.2.986.41 via Frontend Transport; Mon, 30 Oct 2023 13:24:47 -0700 From: "Ashish Singhal via groups.io" To: , , , , , CC: Ashish Singhal Subject: [edk2-devel] [PATCH 1/2] EmbeddedPkg: Fix Android Boot Command Line Length Bug Date: Mon, 30 Oct 2023 14:24:43 -0600 Message-ID: <999da9572bc2ff0bbb8d7a69740256afd6ad5cde.1698697168.git.ashishsingha@nvidia.com> MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF0001AB73:EE_|IA0PR12MB8694:EE_ X-MS-Office365-Filtering-Correlation-Id: 32b8205e-f0c7-48aa-ae37-08dbd9864916 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: bwjmfScX7yrJg+D/eu/qo25wI/p9z7BPH6C5ZCajHXCPcIq1T6lP/SgGZaC8nHjOPNDH39euYjT6KLH1jW9jxr2Ig+TX9u9RUbeO1p8bLx1vC106APJwh3GUb7eOmK6h0p3sWXZu9hrVLtl7URWA2TrA+gfSaFGAdxIrqbnGsbU5yB/jPu0/Q22yA2qowk9dB6RKfAhrKiHeD853NryolNmMSXxuRH0CEVlzaaFEKcDoSVWWikEeR/aZmG4bILXqlwO9ClORUfiIvQzl5ah6QPggM5CxC9b4+SJe83tHPvOzFp6ulggE20t/usFxqVCzQyIUbDMnk+syvDQUFQBnmRDgaRQtd5qWlc3zfKVBPx8NsQTcv3E9HPdSyUYpBAeuMrFfV/CU2Kl0zF4nVXHWf2A5fFnVS+KUxyZw15qqZrpmlXa4h+Q9HkzBhRWB7tKltEyNMreN832EbGix70kl/4VnIq183FNJN/MJde9QQwJ4mdhGFmm2hWgU/yDi6UluoeKnr/4Y4utQ7725brlByotGRR8RnORrxumUt1eHo/vvhcsMhRDoOuHKL6Fk2hDShgNeDBzUwi5jw7TJU8IjM1YDsxXpVbpNRivQl72iKRsdHIpWaXEfDZtig643KTxO5LHSSQigqpzfanb2a76INJxCZevPqWZ8DvtUCdwi+gmGSNpkmJTWcNXxbERuGJJ1OBAIMhBUcxqmLATaY4n07Y5VY5PSP8JFlCZiQa4cGC8LGrPzwBS1aD4sGjjfE6gyCqQP1QQxH83cieiTe1OqMQ== X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2023 20:24:57.6250 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 32b8205e-f0c7-48aa-ae37-08dbd9864916 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.118.232];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF0001AB73.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB8694 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: SPV8xuDZLsB5TDpXLzD6XrvOx7686176AA= Content-Transfer-Encoding: quoted-printable Content-Type: text/plain X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=CVjkhRop; arc=reject ("signature check failed: fail, {[1] = sig:microsoft.com:reject}"); 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 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 ( =20 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 ); } =20 @@ -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; =20 + if ((Buffer =3D=3D NULL) || (BufferSize =3D=3D 0)) { + return EFI_INVALID_PARAMETER; + } + NewKernelArg =3D NULL; ImageHandle =3D NULL; =20 @@ -637,14 +643,15 @@ AndroidBootImgBoot ( goto Exit; } =20 - 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; } =20 - Status =3D AndroidBootImgUpdateArgs (Buffer, NewKernelArg); + Status =3D AndroidBootImgUpdateArgs (Buffer, NewKernelArg, NewKernelArgS= ize); if (EFI_ERROR (Status)) { goto Exit; } --=20 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 (#110337): https://edk2.groups.io/g/devel/message/110337 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-