From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-lf1-f51.google.com (mail-lf1-f51.google.com [209.85.167.51]) by mx.groups.io with SMTP id smtpd.web11.98570.1674811791892615145 for ; Fri, 27 Jan 2023 01:29:52 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20210112 header.b=XWGlmr/S; spf=pass (domain: gmail.com, ip: 209.85.167.51, mailfrom: savvamtr@gmail.com) Received: by mail-lf1-f51.google.com with SMTP id o20so7236246lfk.5 for ; Fri, 27 Jan 2023 01:29:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=nrGojc1bfKVdqVrcZsDLaJExix9YhiMeJ22RHqdxYAA=; b=XWGlmr/SiLp3IBZOw1TVgRXoz5a27dBqlrINBs1hQ+w3q5Siqg+NKnoUbIR38gZZ5k wDKthIKqQDPZOh4lncKPSjszcB3EfXK+0vhdTCkaQbIJo+k/G2Idh0NKFn6ud7SlXvSD 359NepaKKuTXfsNtwx7gKSALICOOPEnTogmYWwKNzwSlbcmTub6fdAXYJOET0ckZYM9V XCQziBld3dSXJbRscnCV8BFO85UTK5MZxsxRWiK9JF4nP305UiWBaS5zz4ou+fDVRstX XlrENKGYcBD57Na4d6VJFxexF1DUSc8zq0JcFHB/MFYsJaNw0Aoa9ssNuX7EBs5a5fnk q7xw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nrGojc1bfKVdqVrcZsDLaJExix9YhiMeJ22RHqdxYAA=; b=5ktoXwC1Ej2C1PkxqKhEtrpQjmltc8NlrQCccE0WCMZGt8fSy7JiR2NWFbvV9u69fi 7nB5ZoC0/Ji4aOfXU4XF0Rn7CkCFVfIZ5ze2vvEZu3uAiboG1EcIOx3X0YlgUiQgqFKZ pc4SK645b/6RmfVKVXv/UIkKm1RvqX595eHUDL4nLqNAIYp3jUX6IRzfwYs8QUEGlvX2 nHw31m2N9gbOfSkJlgiBsOOetBhsGuIWleML3WqDBX87YHKUQNSMK9l+2fvXnVQJWSTl gbMT6L9dtdDBeJgHJBydwi0jWicIx5qMhNowImhm0B23fpVm0kQPmuC/HuAYSC9Yiil+ 44zg== X-Gm-Message-State: AFqh2kokWRPAIoSHIxGFPoT+jai9w8POL2WLLQtJMkKzSoESRwTzkVZZ o1DFqYURH6ZHXzBWfE/iVkGtBAFhAncsyFtg X-Google-Smtp-Source: AMrXdXsfizZ44ZhWyly8mV/kWtna1DxvV01uG4WxLpjMdLHrznlTL2a75H/lqZVp5YRW7lKKyFK+Vw== X-Received: by 2002:a05:6512:114e:b0:4d0:8469:b196 with SMTP id m14-20020a056512114e00b004d08469b196mr12391671lfg.3.1674811790107; Fri, 27 Jan 2023 01:29:50 -0800 (PST) Return-Path: Received: from localhost.localdomain ([176.62.67.29]) by smtp.gmail.com with ESMTPSA id t11-20020a056512068b00b004cc8196a308sm229071lfe.98.2023.01.27.01.29.49 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 27 Jan 2023 01:29:49 -0800 (PST) From: "Savva Mitrofanov" To: devel@edk2.groups.io Cc: =?UTF-8?q?Marvin=20H=C3=A4user?= , Pedro Falcato , Vitaly Cheptsov Subject: [edk2-platforms][PATCH v3 03/11] Ext4Pkg: Fix division by zero by adding check for s_inodes_per_group Date: Fri, 27 Jan 2023 15:29:37 +0600 Message-Id: <20230127092945.94389-4-savvamtr@gmail.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230127092945.94389-1-savvamtr@gmail.com> References: <20230127092945.94389-1-savvamtr@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Superblock s_inodes_per_group field can't be zero, it leads to division by zero in BlockGroup routine Ext4ReadInode Cc: Marvin H=C3=A4user Cc: Pedro Falcato Cc: Vitaly Cheptsov Fixes: d9ceedca6c8f ("Ext4Pkg: Add Ext4Dxe driver.") Signed-off-by: Savva Mitrofanov --- Features/Ext4Pkg/Ext4Dxe/Superblock.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Features/Ext4Pkg/Ext4Dxe/Superblock.c b/Features/Ext4Pkg/Ext4D= xe/Superblock.c index 35dcf3c007c8..be3527e4d618 100644 --- a/Features/Ext4Pkg/Ext4Dxe/Superblock.c +++ b/Features/Ext4Pkg/Ext4Dxe/Superblock.c @@ -243,6 +243,11 @@ Ext4OpenSuperblock ( =0D DEBUG ((DEBUG_FS, "Read only =3D %u\n", Partition->ReadOnly));=0D =0D + if (Sb->s_inodes_per_group =3D=3D 0) {=0D + DEBUG ((DEBUG_ERROR, "[ext4] Inodes per group can not be zero\n"));=0D + return EFI_VOLUME_CORRUPTED;=0D + }=0D +=0D Partition->BlockSize =3D (UINT32)LShiftU64 (1024, Sb->s_log_block_size);= =0D =0D // The size of a block group can also be calculated as 8 * Partition->Bl= ockSize=0D --=20 2.39.0