public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH 1/1] Ext4Pkg: Sanity check the inode size
@ 2022-08-06 23:39 Pedro Falcato
  2022-08-07  6:27 ` Marvin Häuser
  0 siblings, 1 reply; 3+ messages in thread
From: Pedro Falcato @ 2022-08-06 23:39 UTC (permalink / raw)
  To: devel; +Cc: Marvin Häuser

Check its alignment and value for possible bad values.

Cc: Marvin Häuser <mhaeuser@posteo.de>
Signed-off-by: Pedro Falcato <pedro.falcato@gmail.com>
---
 Features/Ext4Pkg/Ext4Dxe/Superblock.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/Features/Ext4Pkg/Ext4Dxe/Superblock.c b/Features/Ext4Pkg/Ext4Dxe/Superblock.c
index c22155ba11b4..edee051c41e8 100644
--- a/Features/Ext4Pkg/Ext4Dxe/Superblock.c
+++ b/Features/Ext4Pkg/Ext4Dxe/Superblock.c
@@ -189,6 +189,12 @@ Ext4OpenSuperblock (
     Partition->FeaturesIncompat = Sb->s_feature_incompat;
     Partition->FeaturesRoCompat = Sb->s_feature_ro_compat;
     Partition->InodeSize        = Sb->s_inode_size;
+
+    // Check for proper alignment of InodeSize and that InodeSize is indeed larger than
+    // the minimum size, 128 bytes.
+    if (((Partition->InodeSize % 4) != 0) || (Partition->InodeSize < EXT4_GOOD_OLD_INODE_SIZE)) {
+      return EFI_VOLUME_CORRUPTED;
+    }
   } else {
     // GOOD_OLD_REV
     Partition->FeaturesCompat = Partition->FeaturesIncompat = Partition->FeaturesRoCompat = 0;
-- 
2.37.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/1] Ext4Pkg: Sanity check the inode size
  2022-08-06 23:39 [PATCH 1/1] Ext4Pkg: Sanity check the inode size Pedro Falcato
@ 2022-08-07  6:27 ` Marvin Häuser
  2022-08-07 14:29   ` Pedro Falcato
  0 siblings, 1 reply; 3+ messages in thread
From: Marvin Häuser @ 2022-08-07  6:27 UTC (permalink / raw)
  To: Pedro Falcato; +Cc: devel

Reviewed-by: Marvin Häuser <mhaeuser@posteo.de>

> On 7. Aug 2022, at 01:39, Pedro Falcato <pedro.falcato@gmail.com> wrote:
> 
> Check its alignment and value for possible bad values.
> 
> Cc: Marvin Häuser <mhaeuser@posteo.de>
> Signed-off-by: Pedro Falcato <pedro.falcato@gmail.com>
> ---
> Features/Ext4Pkg/Ext4Dxe/Superblock.c | 6 ++++++
> 1 file changed, 6 insertions(+)
> 
> diff --git a/Features/Ext4Pkg/Ext4Dxe/Superblock.c b/Features/Ext4Pkg/Ext4Dxe/Superblock.c
> index c22155ba11b4..edee051c41e8 100644
> --- a/Features/Ext4Pkg/Ext4Dxe/Superblock.c
> +++ b/Features/Ext4Pkg/Ext4Dxe/Superblock.c
> @@ -189,6 +189,12 @@ Ext4OpenSuperblock (
>     Partition->FeaturesIncompat = Sb->s_feature_incompat;
>     Partition->FeaturesRoCompat = Sb->s_feature_ro_compat;
>     Partition->InodeSize        = Sb->s_inode_size;
> +
> +    // Check for proper alignment of InodeSize and that InodeSize is indeed larger than
> +    // the minimum size, 128 bytes.
> +    if (((Partition->InodeSize % 4) != 0) || (Partition->InodeSize < EXT4_GOOD_OLD_INODE_SIZE)) {
> +      return EFI_VOLUME_CORRUPTED;
> +    }
>   } else {
>     // GOOD_OLD_REV
>     Partition->FeaturesCompat = Partition->FeaturesIncompat = Partition->FeaturesRoCompat = 0;
> -- 
> 2.37.1
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/1] Ext4Pkg: Sanity check the inode size
  2022-08-07  6:27 ` Marvin Häuser
@ 2022-08-07 14:29   ` Pedro Falcato
  0 siblings, 0 replies; 3+ messages in thread
From: Pedro Falcato @ 2022-08-07 14:29 UTC (permalink / raw)
  To: Marvin Häuser; +Cc: edk2-devel-groups-io

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

Pushed as 436a861
<https://github.com/tianocore/edk2-platforms/commit/436a8612ae96eecbb91ec13eaf3a281366c95af1>

On Sun, Aug 7, 2022 at 7:27 AM Marvin Häuser <mhaeuser@posteo.de> wrote:

> Reviewed-by: Marvin Häuser <mhaeuser@posteo.de>
>
> > On 7. Aug 2022, at 01:39, Pedro Falcato <pedro.falcato@gmail.com> wrote:
> >
> > Check its alignment and value for possible bad values.
> >
> > Cc: Marvin Häuser <mhaeuser@posteo.de>
> > Signed-off-by: Pedro Falcato <pedro.falcato@gmail.com>
> > ---
> > Features/Ext4Pkg/Ext4Dxe/Superblock.c | 6 ++++++
> > 1 file changed, 6 insertions(+)
> >
> > diff --git a/Features/Ext4Pkg/Ext4Dxe/Superblock.c
> b/Features/Ext4Pkg/Ext4Dxe/Superblock.c
> > index c22155ba11b4..edee051c41e8 100644
> > --- a/Features/Ext4Pkg/Ext4Dxe/Superblock.c
> > +++ b/Features/Ext4Pkg/Ext4Dxe/Superblock.c
> > @@ -189,6 +189,12 @@ Ext4OpenSuperblock (
> >     Partition->FeaturesIncompat = Sb->s_feature_incompat;
> >     Partition->FeaturesRoCompat = Sb->s_feature_ro_compat;
> >     Partition->InodeSize        = Sb->s_inode_size;
> > +
> > +    // Check for proper alignment of InodeSize and that InodeSize is
> indeed larger than
> > +    // the minimum size, 128 bytes.
> > +    if (((Partition->InodeSize % 4) != 0) || (Partition->InodeSize <
> EXT4_GOOD_OLD_INODE_SIZE)) {
> > +      return EFI_VOLUME_CORRUPTED;
> > +    }
> >   } else {
> >     // GOOD_OLD_REV
> >     Partition->FeaturesCompat = Partition->FeaturesIncompat =
> Partition->FeaturesRoCompat = 0;
> > --
> > 2.37.1
> >
>
>

-- 
Pedro Falcato

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-08-07 14:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-06 23:39 [PATCH 1/1] Ext4Pkg: Sanity check the inode size Pedro Falcato
2022-08-07  6:27 ` Marvin Häuser
2022-08-07 14:29   ` Pedro Falcato

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox