[edk2-devel] [edk2-platforms][PATCH v3 08/11] Ext4Pkg: Check VolumeName allocation correctness in Ext4GetVolumeName

Pedro Falcato pedro.falcato at gmail.com
Fri Jan 27 14:27:31 UTC 2023


On Fri, Jan 27, 2023 at 9:29 AM Savva Mitrofanov <savvamtr at gmail.com> 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äuser <mhaeuser at posteo.de>
> Cc: Pedro Falcato <pedro.falcato at gmail.com>
> Cc: Vitaly Cheptsov <vit9696 at protonmail.com>
> Fixes: cfbbae595eec ("Ext4Pkg: Add handling of EFI_FILE_SYSTEM_VOLUME_LABEL GetInfo().")
> Signed-off-by: Savva Mitrofanov <savvamtr at gmail.com>
> ---
>  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/File.c
> index 9dde4a5d1a2d..677caf88fbdc 100644
> --- a/Features/Ext4Pkg/Ext4Dxe/File.c
> +++ b/Features/Ext4Pkg/Ext4Dxe/File.c
> @@ -719,7 +719,11 @@ Ext4GetVolumeName (
>
>
>      VolNameLength = StrLen (VolumeName);
>
>    } else {
>
> -    VolumeName    = AllocateZeroPool (sizeof (CHAR16));
>
> +    VolumeName = AllocateZeroPool (sizeof (CHAR16));
>
> +    if (VolumeName == NULL) {
>
> +      return EFI_OUT_OF_RESOURCES;
>
> +    }
>
> +
>
>      VolNameLength = 0;
>
>    }
>
>
>
> @@ -786,7 +790,9 @@ Ext4GetFilesystemInfo (
>    Info->VolumeSize = MultU64x32 (TotalBlocks, Part->BlockSize);
>
>    Info->FreeSpace  = MultU64x32 (FreeBlocks, Part->BlockSize);
>
>
>
> -  StrCpyS (Info->VolumeLabel, VolNameLength + 1, VolumeName);
>
> +  Status = 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 = AllocateZeroPool (InodeSize);
>
>
>
> -  if (!Inode) {
>
> +  if (Inode == NULL) {
>
>      return NULL;
>
>    }
>
>
>
> --
> 2.39.0
>

Embarrassing...
Reviewed-by: Pedro Falcato <pedro.falcato at gmail.com>

-- 
Pedro


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#99170): https://edk2.groups.io/g/devel/message/99170
Mute This Topic: https://groups.io/mt/96562698/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-




More information about the edk2-devel-archive mailing list