[edk2-devel] [edk2-platforms][PATCH v3 03/11] Ext4Pkg: Fix division by zero by adding check for s_inodes_per_group

Savva Mitrofanov savvamtr at gmail.com
Fri Jan 27 09:29:37 UTC 2023


Superblock s_inodes_per_group field can't be zero, it leads to division
by zero in BlockGroup routine Ext4ReadInode

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

diff --git a/Features/Ext4Pkg/Ext4Dxe/Superblock.c b/Features/Ext4Pkg/Ext4Dxe/Superblock.c
index 35dcf3c007c8..be3527e4d618 100644
--- a/Features/Ext4Pkg/Ext4Dxe/Superblock.c
+++ b/Features/Ext4Pkg/Ext4Dxe/Superblock.c
@@ -243,6 +243,11 @@ Ext4OpenSuperblock (
 

   DEBUG ((DEBUG_FS, "Read only = %u\n", Partition->ReadOnly));

 

+  if (Sb->s_inodes_per_group == 0) {

+    DEBUG ((DEBUG_ERROR, "[ext4] Inodes per group can not be zero\n"));

+    return EFI_VOLUME_CORRUPTED;

+  }

+

   Partition->BlockSize = (UINT32)LShiftU64 (1024, Sb->s_log_block_size);

 

   // The size of a block group can also be calculated as 8 * Partition->BlockSize

-- 
2.39.0



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#99139): https://edk2.groups.io/g/devel/message/99139
Mute This Topic: https://groups.io/mt/96562692/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