[edk2-devel] [edk2-platforms][PATCH v3 02/11] Ext4Pkg: Fix incorrect checksum metadata feature check

Savva Mitrofanov posted 11 patches 3 years ago
There is a newer version of this series
[edk2-devel] [edk2-platforms][PATCH v3 02/11] Ext4Pkg: Fix incorrect checksum metadata feature check
Posted by Savva Mitrofanov 3 years ago
Missing comparison != 0 leads to broken logic condition. Also replaced
CSUM_SEED feature_incompat check with predefined macro EXT4_HAS_INCOMPAT

Cc: Marvin Häuser <mhaeuser@posteo.de>
Cc: Pedro Falcato <pedro.falcato@gmail.com>
Cc: Vitaly Cheptsov <vit9696@protonmail.com>
Fixes: d9ceedca6c8f ("Ext4Pkg: Add Ext4Dxe driver.")
Signed-off-by: Savva Mitrofanov <savvamtr@gmail.com>
---
 Features/Ext4Pkg/Ext4Dxe/Superblock.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/Features/Ext4Pkg/Ext4Dxe/Superblock.c b/Features/Ext4Pkg/Ext4Dxe/Superblock.c
index 5a3c7f478187..35dcf3c007c8 100644
--- a/Features/Ext4Pkg/Ext4Dxe/Superblock.c
+++ b/Features/Ext4Pkg/Ext4Dxe/Superblock.c
@@ -220,13 +220,11 @@ Ext4OpenSuperblock (
   }

 

   // At the time of writing, it's the only supported checksum.

-  if (Partition->FeaturesCompat & EXT4_FEATURE_RO_COMPAT_METADATA_CSUM &&

-      (Sb->s_checksum_type != EXT4_CHECKSUM_CRC32C))

-  {

+  if (EXT4_HAS_METADATA_CSUM (Partition) && (Sb->s_checksum_type != EXT4_CHECKSUM_CRC32C)) {

     return EFI_UNSUPPORTED;

   }

 

-  if ((Partition->FeaturesIncompat & EXT4_FEATURE_INCOMPAT_CSUM_SEED) != 0) {

+  if (EXT4_HAS_INCOMPAT (Partition, EXT4_FEATURE_INCOMPAT_CSUM_SEED)) {

     Partition->InitialSeed = Sb->s_checksum_seed;

   } else {

     Partition->InitialSeed = Ext4CalculateChecksum (Partition, Sb->s_uuid, 16, ~0U);

-- 
2.39.0



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#99138): https://edk2.groups.io/g/devel/message/99138
Mute This Topic: https://groups.io/mt/96562691/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-
Re: [edk2-devel] [edk2-platforms][PATCH v3 02/11] Ext4Pkg: Fix incorrect checksum metadata feature check
Posted by Marvin Häuser 3 years ago
On 27. Jan 2023, at 10:29, Savva Mitrofanov <savvamtr@gmail.com> wrote:
> 
> Missing comparison != 0 leads to broken logic condition.

The actual issue appears to be FeaturesCompat vs FeaturesRoCompat (latter is hidden by your usage of the macro). Checking for != 0 is redundant (albeit required by the code style guideline for non-functional reasons). Please confirm and update the commit message if you agree.

> Also replaced
> CSUM_SEED feature_incompat check with predefined macro EXT4_HAS_INCOMPAT
> 
> Cc: Marvin Häuser <mhaeuser@posteo.de>
> Cc: Pedro Falcato <pedro.falcato@gmail.com>
> Cc: Vitaly Cheptsov <vit9696@protonmail.com>
> Fixes: d9ceedca6c8f ("Ext4Pkg: Add Ext4Dxe driver.")
> Signed-off-by: Savva Mitrofanov <savvamtr@gmail.com>
> ---
> Features/Ext4Pkg/Ext4Dxe/Superblock.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/Features/Ext4Pkg/Ext4Dxe/Superblock.c b/Features/Ext4Pkg/Ext4Dxe/Superblock.c
> index 5a3c7f478187..35dcf3c007c8 100644
> --- a/Features/Ext4Pkg/Ext4Dxe/Superblock.c
> +++ b/Features/Ext4Pkg/Ext4Dxe/Superblock.c
> @@ -220,13 +220,11 @@ Ext4OpenSuperblock (
>   }
> 
>   // At the time of writing, it's the only supported checksum.
> -  if (Partition->FeaturesCompat & EXT4_FEATURE_RO_COMPAT_METADATA_CSUM &&
> -      (Sb->s_checksum_type != EXT4_CHECKSUM_CRC32C))
> -  {
> +  if (EXT4_HAS_METADATA_CSUM (Partition) && (Sb->s_checksum_type != EXT4_CHECKSUM_CRC32C)) {
>     return EFI_UNSUPPORTED;
>   }
> 
> -  if ((Partition->FeaturesIncompat & EXT4_FEATURE_INCOMPAT_CSUM_SEED) != 0) {
> +  if (EXT4_HAS_INCOMPAT (Partition, EXT4_FEATURE_INCOMPAT_CSUM_SEED)) {
>     Partition->InitialSeed = Sb->s_checksum_seed;
>   } else {
>     Partition->InitialSeed = Ext4CalculateChecksum (Partition, Sb->s_uuid, 16, ~0U);
> -- 
> 2.39.0
> 



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#99148): https://edk2.groups.io/g/devel/message/99148
Mute This Topic: https://groups.io/mt/96562691/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-
Re: [edk2-devel] [edk2-platforms][PATCH v3 02/11] Ext4Pkg: Fix incorrect checksum metadata feature check
Posted by Savva Mitrofanov 3 years ago
Thanks for pointing this, yes, this change actually replaces structure field from FeaturesCompat to FeaturesRoCompat. The commit message was already corrected in referenced repository fork.

> On 27 Jan 2023, at 16:02, Marvin Häuser <mhaeuser@posteo.de> wrote:
> 
> The actual issue appears to be FeaturesCompat vs FeaturesRoCompat (latter is hidden by your usage of the macro). Checking for != 0 is redundant (albeit required by the code style guideline for non-functional reasons). Please confirm and update the commit message if you agree.



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#99296): https://edk2.groups.io/g/devel/message/99296
Mute This Topic: https://groups.io/mt/96562691/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-


Re: [edk2-devel] [edk2-platforms][PATCH v3 02/11] Ext4Pkg: Fix incorrect checksum metadata feature check
Posted by Pedro Falcato 3 years ago
On Fri, Jan 27, 2023 at 10:02 AM Marvin Häuser <mhaeuser@posteo.de> wrote:
>
> On 27. Jan 2023, at 10:29, Savva Mitrofanov <savvamtr@gmail.com> wrote:
> >
> > Missing comparison != 0 leads to broken logic condition.
>
> The actual issue appears to be FeaturesCompat vs FeaturesRoCompat (latter is hidden by your usage of the macro). Checking for != 0 is redundant (albeit required by the code style guideline for non-functional reasons). Please confirm and update the commit message if you agree.

+1, the actual issue comes from using the wrong feature mask and not the != 0.
If we get a v4, please update, else I can rewrite it myself.

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

-- 
Pedro


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#99172): https://edk2.groups.io/g/devel/message/99172
Mute This Topic: https://groups.io/mt/96562691/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-
Re: [edk2-devel] [edk2-platforms][PATCH v3 02/11] Ext4Pkg: Fix incorrect checksum metadata feature check
Posted by Marvin Häuser 3 years ago
With the commit message changed,

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

> On 27. Jan 2023, at 15:29, Pedro Falcato <pedro.falcato@gmail.com> wrote:
> 
> On Fri, Jan 27, 2023 at 10:02 AM Marvin Häuser <mhaeuser@posteo.de> wrote:
>> 
>>> On 27. Jan 2023, at 10:29, Savva Mitrofanov <savvamtr@gmail.com> wrote:
>>> 
>>> Missing comparison != 0 leads to broken logic condition.
>> 
>> The actual issue appears to be FeaturesCompat vs FeaturesRoCompat (latter is hidden by your usage of the macro). Checking for != 0 is redundant (albeit required by the code style guideline for non-functional reasons). Please confirm and update the commit message if you agree.
> 
> +1, the actual issue comes from using the wrong feature mask and not the != 0.
> If we get a v4, please update, else I can rewrite it myself.
> 
> Reviewed-by: Pedro Falcato <pedro.falcato@gmail.com>
> 
> -- 
> Pedro



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#99295): https://edk2.groups.io/g/devel/message/99295
Mute This Topic: https://groups.io/mt/96562691/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-