From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) by mx.groups.io with SMTP id smtpd.web10.103138.1674829663184014075 for ; Fri, 27 Jan 2023 06:27:43 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20210112 header.b=oiNykMe3; spf=pass (domain: gmail.com, ip: 209.85.214.176, mailfrom: pedro.falcato@gmail.com) Received: by mail-pl1-f176.google.com with SMTP id d3so5063386plr.10 for ; Fri, 27 Jan 2023 06:27:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=Wjakj7c6qmPLOQVWYYeDEqz4n5UEHj59tYd+D/YtguE=; b=oiNykMe3/0WtmP1TpLJTU9k/2JoEGK+qlVVPNBv5JAAB1sYC3oacl5TM7jWLQnzrj+ 5l6gpEmZiKeog07jEzpwEMn/IJ8CdzCr24W36AzkN/5F8XAtj04oIeRF7j+vx4f7UHjr fCzJFItzT7YWslBcFBz2ej+BUd9T9aKl68oi3a5d+k7IjxOHBULjHrptTI532voNYDhK gRGK2zkm1hE3fE6wHhwFKo1HaSgAWqa/wqDBlAsxv9yT42H9oUDtXbynxTCx5KVaEQyR g6DrRoUtWVIPxNwVtvoOJUsnM1W0FI8r/u4vMvrVbl+WFQvPRW216BHSq4K879lo32QE gNKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Wjakj7c6qmPLOQVWYYeDEqz4n5UEHj59tYd+D/YtguE=; b=bSCt2/wVIGH7VljuGGxc50YiRLCFT+PuzosWiYxmpQYzd8KhDpzL8CWmb1DOTGPorU Fa13E9fCBUwuWzyLZ7xZ4PD7Cn/KYbWwi68eFpNfYXtii7uezJmmyPsXRlegmp0eGMob DSF9Y0t5Wzc0mP5YRXh1VTybvlSmTPiwznX22u58vYLJBoa21Pwsjf/K7QC5OB5Fbnkh v2v+KlQnk3Yw0PzVNykRXvGKHdMy+Cx7/gE966pJjFWoM3p7XTbLsXHp6PGESiLKDUia FtFSfMr0QJ2JsEL+ZB51wnauL2VIuvdR3EPYqLgJKE6OO23Ydj1LTNf7Tx9I/BhF6/Rj CAGg== X-Gm-Message-State: AFqh2kp0v1CG4icpG6fAz73fVTfFvzMat0PsQT0/OzevWZ+z+0ZE7CVL ep38sOxrwguxM2egzRY+YG+HD8NiKsphPxKTyv3PiuswG7x2Fw== X-Google-Smtp-Source: AMrXdXtS/RGrptyILjV1qREUzNzpwsp7dQO9A52x7xyuS5+E5WXtlW5Yu6ychIAklYg1EYmHU1v5BAOiDWDQ0MRiJss= X-Received: by 2002:a17:90a:1a03:b0:228:7eed:e756 with SMTP id 3-20020a17090a1a0300b002287eede756mr6460238pjk.166.1674829662524; Fri, 27 Jan 2023 06:27:42 -0800 (PST) MIME-Version: 1.0 References: <20230127092945.94389-1-savvamtr@gmail.com> <20230127092945.94389-9-savvamtr@gmail.com> In-Reply-To: <20230127092945.94389-9-savvamtr@gmail.com> From: "Pedro Falcato" Date: Fri, 27 Jan 2023 14:27:31 +0000 Message-ID: Subject: Re: [edk2-devel] [edk2-platforms][PATCH v3 08/11] Ext4Pkg: Check VolumeName allocation correctness in Ext4GetVolumeName To: devel@edk2.groups.io, savvamtr@gmail.com Cc: =?UTF-8?Q?Marvin_H=C3=A4user?= , Vitaly Cheptsov Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Jan 27, 2023 at 9:29 AM Savva Mitrofanov wrote= : > > Missing check in some cases leads to failed StrCpyS call in > Ext4GetVolumeLabelInfo. Also correct condition that checks Inode pointer > for being NULL in Ext4AllocateInode > > Cc: Marvin H=C3=A4user > Cc: Pedro Falcato > Cc: Vitaly Cheptsov > Fixes: cfbbae595eec ("Ext4Pkg: Add handling of EFI_FILE_SYSTEM_VOLUME_LAB= EL GetInfo().") > Signed-off-by: Savva Mitrofanov > --- > Features/Ext4Pkg/Ext4Dxe/File.c | 10 ++++++++-- > Features/Ext4Pkg/Ext4Dxe/Inode.c | 2 +- > 2 files changed, 9 insertions(+), 3 deletions(-) > > diff --git a/Features/Ext4Pkg/Ext4Dxe/File.c b/Features/Ext4Pkg/Ext4Dxe/F= ile.c > index 9dde4a5d1a2d..677caf88fbdc 100644 > --- a/Features/Ext4Pkg/Ext4Dxe/File.c > +++ b/Features/Ext4Pkg/Ext4Dxe/File.c > @@ -719,7 +719,11 @@ Ext4GetVolumeName ( > > > VolNameLength =3D StrLen (VolumeName); > > } else { > > - VolumeName =3D AllocateZeroPool (sizeof (CHAR16)); > > + VolumeName =3D AllocateZeroPool (sizeof (CHAR16)); > > + if (VolumeName =3D=3D NULL) { > > + return EFI_OUT_OF_RESOURCES; > > + } > > + > > VolNameLength =3D 0; > > } > > > > @@ -786,7 +790,9 @@ Ext4GetFilesystemInfo ( > Info->VolumeSize =3D MultU64x32 (TotalBlocks, Part->BlockSize); > > Info->FreeSpace =3D MultU64x32 (FreeBlocks, Part->BlockSize); > > > > - StrCpyS (Info->VolumeLabel, VolNameLength + 1, VolumeName); > > + Status =3D StrCpyS (Info->VolumeLabel, VolNameLength + 1, VolumeName); > > + > > + ASSERT_EFI_ERROR (Status); > > > > FreePool (VolumeName); > > > > diff --git a/Features/Ext4Pkg/Ext4Dxe/Inode.c b/Features/Ext4Pkg/Ext4Dxe/= Inode.c > index e44b5638599f..90e3eb88f523 100644 > --- a/Features/Ext4Pkg/Ext4Dxe/Inode.c > +++ b/Features/Ext4Pkg/Ext4Dxe/Inode.c > @@ -230,7 +230,7 @@ Ext4AllocateInode ( > > > Inode =3D AllocateZeroPool (InodeSize); > > > > - if (!Inode) { > > + if (Inode =3D=3D NULL) { > > return NULL; > > } > > > > -- > 2.39.0 > Embarrassing... Reviewed-by: Pedro Falcato --=20 Pedro