From nobody Thu May 2 21:01:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+97261+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+97261+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1670856422; cv=none; d=zohomail.com; s=zohoarc; b=lVP33eguzUDub6QX93a+vpu6VoYJz6X6BdF9oj+V7gzQhjfmC5qyI9rvZ5RUEQWqJC18BXw9mEa0sjMeF5Sbe1Sf1ZeXkpxzse/aKyfaxYY2/9mAP6395bYepiEQNyP5eLvxOcLdiStbG5e/Mpmi6hkTmTCJA16VqID904LA/k4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670856422; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=OPWrRdd4A9HLauWmB9TGEfsii2pghxCO8/+PV16DIkQ=; b=a5Jctiv4qndweIeH5s5YWK9B4m0pp7nLRTyg3CfFSU/FTu0dlNSur6b5P2zkvz9fhfbBUUyGhV+TF2NPLNBOP1RnPK0QHyVXoQXEP3L7caqU+ZLh+Yfw1+KyI694a23MI9HxmPv8PTuU4/f5s9haRAO9KDjMyg6g+NhyDMdR2k8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+97261+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 16708564226281002.4803870003522; Mon, 12 Dec 2022 06:47:02 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id urT1YY1788612x9OrVO1RB87; Mon, 12 Dec 2022 06:47:02 -0800 X-Received: from mail-lf1-f46.google.com (mail-lf1-f46.google.com [209.85.167.46]) by mx.groups.io with SMTP id smtpd.web11.44999.1670856421448535571 for ; Mon, 12 Dec 2022 06:47:01 -0800 X-Received: by mail-lf1-f46.google.com with SMTP id y25so18965157lfa.9 for ; Mon, 12 Dec 2022 06:47:01 -0800 (PST) X-Gm-Message-State: nGtIdKer1EQWiGrwHxYiUJJex1787277AA= X-Google-Smtp-Source: AA0mqf4U4GN6DLJory1fLLND67zvo1IOskTv2DKy8AMwlVxuIdRox0LcQdLOyBj4Bf9IcPmwjBpEQg== X-Received: by 2002:a05:6512:3115:b0:4b5:6950:bbb2 with SMTP id n21-20020a056512311500b004b56950bbb2mr3813647lfb.66.1670856419511; Mon, 12 Dec 2022 06:46:59 -0800 (PST) X-Received: from localhost.localdomain ([77.221.215.144]) by smtp.gmail.com with ESMTPSA id t4-20020a056512030400b0049c29292250sm1643313lfp.149.2022.12.12.06.46.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Dec 2022 06:46:59 -0800 (PST) From: "Savva Mitrofanov" To: devel@edk2.groups.io Cc: =?UTF-8?q?Marvin=20H=C3=A4user?= , Pedro Falcato , Vitaly Cheptsov Subject: [edk2-devel] [edk2-platforms][PATCH v2 01/11] Ext4Pkg: Fix memory leak in Ext4RetrieveDirent Date: Mon, 12 Dec 2022 20:46:44 +0600 Message-Id: <20221212144654.2650-2-savvamtr@gmail.com> In-Reply-To: <20221212144654.2650-1-savvamtr@gmail.com> References: <20221212144654.2650-1-savvamtr@gmail.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,savvamtr@gmail.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1670856422; bh=3dmnzuOaB919dEnezZbHy73DwoGhbSv2UtcBIK3ktwU=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=b0/HrE0oinGfB3ice5yHfzmzomIJoLF+cp16CNt63U+Qpap5fwh+etZfqWBDztxe83H KCzQuJaoKHi9v3PvUskj/uSqxjlqsDQ8zRh1eBGPyvNwWa0mxK+8zk47xSOGxNcVRNhTe C5PtlQHezdCVpz2jXfGyGPkj8T/oWNVLcvI= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1670856424191100005 Content-Type: text/plain; charset="utf-8" We need to free buffer on return if BlockRemainder !=3D 0. Also changed return logic from function to use use common exit to prevent code duplication. Cc: Marvin H=C3=A4user Cc: Pedro Falcato Cc: Vitaly Cheptsov Fixes: e55f0527dde48a5f139c1b8f35acc4e6b59dd794 Signed-off-by: Savva Mitrofanov --- Features/Ext4Pkg/Ext4Dxe/Directory.c | 30 +++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/Features/Ext4Pkg/Ext4Dxe/Directory.c b/Features/Ext4Pkg/Ext4Dx= e/Directory.c index 4441e6d192b6..8b8fce568e43 100644 --- a/Features/Ext4Pkg/Ext4Dxe/Directory.c +++ b/Features/Ext4Pkg/Ext4Dxe/Directory.c @@ -112,8 +112,7 @@ Ext4RetrieveDirent ( UINTN ToCopy; UINTN BlockOffset; =20 - Status =3D EFI_NOT_FOUND; - Buf =3D AllocatePool (Partition->BlockSize); + Buf =3D AllocatePool (Partition->BlockSize); =20 if (Buf =3D=3D NULL) { return EFI_OUT_OF_RESOURCES; @@ -127,7 +126,8 @@ Ext4RetrieveDirent ( DivU64x32Remainder (DirInoSize, Partition->BlockSize, &BlockRemainder); if (BlockRemainder !=3D 0) { // Directory inodes need to have block aligned sizes - return EFI_VOLUME_CORRUPTED; + Status =3D EFI_VOLUME_CORRUPTED; + goto Out; } =20 while (Off < DirInoSize) { @@ -136,8 +136,7 @@ Ext4RetrieveDirent ( Status =3D Ext4Read (Partition, Directory, Buf, Off, &Length); =20 if (Status !=3D EFI_SUCCESS) { - FreePool (Buf); - return Status; + goto Out; } =20 for (BlockOffset =3D 0; BlockOffset < Partition->BlockSize; ) { @@ -145,19 +144,19 @@ Ext4RetrieveDirent ( RemainingBlock =3D Partition->BlockSize - BlockOffset; // Check if the minimum directory entry fits inside [BlockOffset, En= dOfBlock] if (RemainingBlock < EXT4_MIN_DIR_ENTRY_LEN) { - FreePool (Buf); - return EFI_VOLUME_CORRUPTED; + Status =3D EFI_VOLUME_CORRUPTED; + goto Out; } =20 if (!Ext4ValidDirent (Entry)) { - FreePool (Buf); - return EFI_VOLUME_CORRUPTED; + Status =3D EFI_VOLUME_CORRUPTED; + goto Out; } =20 if ((Entry->name_len > RemainingBlock) || (Entry->rec_len > Remainin= gBlock)) { // Corrupted filesystem - FreePool (Buf); - return EFI_VOLUME_CORRUPTED; + Status =3D EFI_VOLUME_CORRUPTED; + goto Out; } =20 // Unused entry @@ -186,8 +185,8 @@ Ext4RetrieveDirent ( ToCopy =3D MIN (Entry->rec_len, sizeof (EXT4_DIR_ENTRY)); =20 CopyMem (Result, Entry, ToCopy); - FreePool (Buf); - return EFI_SUCCESS; + Status =3D EFI_SUCCESS; + goto Out; } =20 BlockOffset +=3D Entry->rec_len; @@ -196,8 +195,11 @@ Ext4RetrieveDirent ( Off +=3D Partition->BlockSize; } =20 + Status =3D EFI_NOT_FOUND; + +Out: FreePool (Buf); - return EFI_NOT_FOUND; + return Status; } =20 /** --=20 2.38.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#97261): https://edk2.groups.io/g/devel/message/97261 Mute This Topic: https://groups.io/mt/95622329/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Thu May 2 21:01:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+97262+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+97262+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1670856424; cv=none; d=zohomail.com; s=zohoarc; b=g4tA+tY+v/Wjr4oUh6+UebUfzU6n8o/DVx3xTxO3Qj9yH7tCrgoI5J3JhH80Wlw5a3Dh0wyl4c6paiRfmDnwM9RjNg9GGVjBa6wXhWka0L+l2reFPWM34PssgjFbIrxcLGnwANxzksKwXfCUa5m4LtZyA4o5xZ55USeRSBxrKeY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670856424; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=stqkvOpYlMAuLGL6q88updnqC+3K9hgCq6n26Ig/4y0=; b=QkvRhJ2bhutSoTx7hGyc6G1dZrwojAPXC1BTWz6NRUf7dWt5X49LLsqi7vv5pNw6m3JWni1Z6aU4fz2wx5ytBE3E55IhfUo5KNGeKPAzRSMmyCeRsCWTJdbX44EgEZa23pkEzEyUHeqKeeNtHRTIISjre8Pq/ORO9N2mTD1L/MI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+97262+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1670856424188793.1553933095091; Mon, 12 Dec 2022 06:47:04 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id Xed5YY1788612xgazXEUycra; Mon, 12 Dec 2022 06:47:03 -0800 X-Received: from mail-lf1-f52.google.com (mail-lf1-f52.google.com [209.85.167.52]) by mx.groups.io with SMTP id smtpd.web10.44803.1670856422400430394 for ; Mon, 12 Dec 2022 06:47:02 -0800 X-Received: by mail-lf1-f52.google.com with SMTP id x28so18970119lfn.6 for ; Mon, 12 Dec 2022 06:47:02 -0800 (PST) X-Gm-Message-State: r5lx97iDEWfMV2J4aZlu5xrlx1787277AA= X-Google-Smtp-Source: AA0mqf6vl0vQkQNG4sTgzIPzLW13lL0/CaO0pAS2kp/jMU3vBUuF4jGD1E6LZJjRPMTboijovSBWZA== X-Received: by 2002:a05:6512:7b:b0:4aa:7821:8021 with SMTP id i27-20020a056512007b00b004aa78218021mr5316216lfo.34.1670856420522; Mon, 12 Dec 2022 06:47:00 -0800 (PST) X-Received: from localhost.localdomain ([77.221.215.144]) by smtp.gmail.com with ESMTPSA id t4-20020a056512030400b0049c29292250sm1643313lfp.149.2022.12.12.06.46.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Dec 2022 06:47:00 -0800 (PST) From: "Savva Mitrofanov" To: devel@edk2.groups.io Cc: =?UTF-8?q?Marvin=20H=C3=A4user?= , Pedro Falcato , Vitaly Cheptsov Subject: [edk2-devel] [edk2-platforms][PATCH v2 02/11] Ext4Pkg: Move EXT4_NAME_MAX definition to Ext4Disk.h Date: Mon, 12 Dec 2022 20:46:45 +0600 Message-Id: <20221212144654.2650-3-savvamtr@gmail.com> In-Reply-To: <20221212144654.2650-1-savvamtr@gmail.com> References: <20221212144654.2650-1-savvamtr@gmail.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,savvamtr@gmail.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1670856423; bh=J8Aslw/BOyERQaZiV07rr86eRa5ARVhNtzOzSo9zCpA=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=OD/7AntrZZw/LOfXyUUu4c1jxDBPqbxzu7+4LUlnQEAHcpVVa3cjQOvfVBlCkO38h7K YRkB8io5Zo3KuacrJxBmxrH30b7HlZkRfRjBd4RCMDAcSxA8/2F1MH3YlCbPi9LYO8PxF jHyQFwiXRP5l2yblRjXUIF6LuL2Ln79/LoU= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1670856426256100012 Content-Type: text/plain; charset="utf-8" Constant EXT4_NAME_MAX is related to EXT4_DIR_ENTRY FS structure, so it should be placed into Ext4Disk.h header Cc: Marvin H=C3=A4user Cc: Pedro Falcato Cc: Vitaly Cheptsov Fixes: e55f0527dde48a5f139c1b8f35acc4e6b59dd794 Signed-off-by: Savva Mitrofanov --- Features/Ext4Pkg/Ext4Dxe/Ext4Disk.h | 4 +++- Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h | 3 +-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Features/Ext4Pkg/Ext4Dxe/Ext4Disk.h b/Features/Ext4Pkg/Ext4Dxe= /Ext4Disk.h index 4fd91a423324..1285644dcb25 100644 --- a/Features/Ext4Pkg/Ext4Dxe/Ext4Disk.h +++ b/Features/Ext4Pkg/Ext4Dxe/Ext4Disk.h @@ -397,12 +397,14 @@ typedef struct _Ext4Inode { UINT32 i_projid; } EXT4_INODE; =20 +#define EXT4_NAME_MAX 255 + typedef struct { UINT32 inode; UINT16 rec_len; UINT8 name_len; UINT8 file_type; - CHAR8 name[255]; + CHAR8 name[EXT4_NAME_MAX]; } EXT4_DIR_ENTRY; =20 #define EXT4_MIN_DIR_ENTRY_LEN 8 diff --git a/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h b/Features/Ext4Pkg/Ext4Dxe/= Ext4Dxe.h index adf3c13f6ea9..81ba568c5947 100644 --- a/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h +++ b/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h @@ -31,8 +31,7 @@ =20 #include "Ext4Disk.h" =20 -#define SYMLOOP_MAX 8 -#define EXT4_NAME_MAX 255 +#define SYMLOOP_MAX 8 // // We need to specify path length limit for security purposes, to prevent = possible // overflows and dead-loop conditions. Originally this limit is absent in = FS design, --=20 2.38.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#97262): https://edk2.groups.io/g/devel/message/97262 Mute This Topic: https://groups.io/mt/95622330/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Thu May 2 21:01:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+97263+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+97263+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1670856425; cv=none; d=zohomail.com; s=zohoarc; b=jZKeCBEZKXLPhmMY+pgKYjIMdRZa/9S7CPNmhkTMgf7UvljdvsCFaejC6ztgJVMc6iEkNTVyCBQoqJxpWD8E7aNRrB6kAdAFXWUwPReC328FIKuO2c/yCuQh84a4zCLD/MY2hspTcATSWJ8j7aYImRWRTupn835pmCXBWZrvOcQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670856425; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=19iMJT6FH5cY/8lrQtOf+Ooi/9RzTEvQOfitmkVomAo=; b=DeqXtSMofwERlNlTc70NMwduD/EDumWx3kyQj3aykj7y8jfw9FEEJZ0i/WWSXwJKQgf2gpT6dWC2ld15Wy2hV7YIsVfu/a09RN59tm0IFiu+dQv0zNOGNq/OP/yAsGTPIxekq7OTS7QUMbMiTS6gdI7pqxMVb5BZQ/GpS5Btq5U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+97263+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 16708564251191020.5261405733726; Mon, 12 Dec 2022 06:47:05 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id L2QqYY1788612xX4jclzPUb5; Mon, 12 Dec 2022 06:47:04 -0800 X-Received: from mail-lj1-f181.google.com (mail-lj1-f181.google.com [209.85.208.181]) by mx.groups.io with SMTP id smtpd.web10.44804.1670856423584482903 for ; Mon, 12 Dec 2022 06:47:03 -0800 X-Received: by mail-lj1-f181.google.com with SMTP id s10so9872ljg.1 for ; Mon, 12 Dec 2022 06:47:03 -0800 (PST) X-Gm-Message-State: qMKDkLw4a4sPa3Hso4jZ9MGIx1787277AA= X-Google-Smtp-Source: AA0mqf5PfHOWU87y7RLOA2wiGjOoDNi2hybsnn9IxCMjtOOZKScDkacPu8j94dxJUj1yYzCO2YHuvA== X-Received: by 2002:a2e:bc89:0:b0:27b:5596:1e4d with SMTP id h9-20020a2ebc89000000b0027b55961e4dmr609846ljf.34.1670856421515; Mon, 12 Dec 2022 06:47:01 -0800 (PST) X-Received: from localhost.localdomain ([77.221.215.144]) by smtp.gmail.com with ESMTPSA id t4-20020a056512030400b0049c29292250sm1643313lfp.149.2022.12.12.06.47.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Dec 2022 06:47:01 -0800 (PST) From: "Savva Mitrofanov" To: devel@edk2.groups.io Cc: =?UTF-8?q?Marvin=20H=C3=A4user?= , Pedro Falcato , Vitaly Cheptsov Subject: [edk2-devel] [edk2-platforms][PATCH v2 03/11] Ext4Pkg: Fix global buffer overflow in Ext4ReadDir Date: Mon, 12 Dec 2022 20:46:46 +0600 Message-Id: <20221212144654.2650-4-savvamtr@gmail.com> In-Reply-To: <20221212144654.2650-1-savvamtr@gmail.com> References: <20221212144654.2650-1-savvamtr@gmail.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,savvamtr@gmail.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1670856424; bh=0H7ZBx/J9HeTCRv4kjIzWG0aGIIVZg6/BmxT+RH5YCI=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=of8hbMLRGEkZvuhno089uzHJYPeAzMbnkpx27/lwKP6Ryg7BlcbCSKHxCZR7syOJMod piwUh501G4zqlwP5wQjash70MmYRT9RNd10eNJwYEaOA70bMV+31ZaLEA5OXTrlQdYCwZ aCOZv6+luYGhxuUPcmrHuv0vY2NhU8rIuAg= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1670856426274100014 Content-Type: text/plain; charset="utf-8" Directory entry structure can contain name_len bigger than size of "." or "..", that's why CompareMem in such cases leads to global buffer overflow. So there are two problems. The first is that statement doesn't check cases when name_len !=3D 0 but > 2 and the second is that we passing big Length to CompareMem routine. The correct way here is to check that name_len <=3D 2 and check for null-terminator presence Cc: Marvin H=C3=A4user Cc: Pedro Falcato Cc: Vitaly Cheptsov Fixes: e55f0527dde48a5f139c1b8f35acc4e6b59dd794 Signed-off-by: Savva Mitrofanov --- Features/Ext4Pkg/Ext4Dxe/Directory.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Features/Ext4Pkg/Ext4Dxe/Directory.c b/Features/Ext4Pkg/Ext4Dx= e/Directory.c index 8b8fce568e43..ffc0e8043076 100644 --- a/Features/Ext4Pkg/Ext4Dxe/Directory.c +++ b/Features/Ext4Pkg/Ext4Dxe/Directory.c @@ -491,11 +491,9 @@ Ext4ReadDir ( =20 // Entry.name_len may be 0 if it's a nameless entry, like an unused en= try // or a checksum at the end of the directory block. - // memcmp (and CompareMem) return 0 when the passed length is 0. - - IsDotOrDotDot =3D Entry.name_len !=3D 0 && - (CompareMem (Entry.name, ".", Entry.name_len) =3D=3D 0= || - CompareMem (Entry.name, "..", Entry.name_len) =3D=3D = 0); + IsDotOrDotDot =3D Entry.name_len <=3D 2 && + ((Entry.name[0] =3D=3D '.') && + (Entry.name[1] =3D=3D '.' || Entry.name[1] =3D=3D '\0= ')); =20 // When inode =3D 0, it's unused. ShouldSkip =3D Entry.inode =3D=3D 0 || IsDotOrDotDot; --=20 2.38.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#97263): https://edk2.groups.io/g/devel/message/97263 Mute This Topic: https://groups.io/mt/95622331/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Thu May 2 21:01:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+97264+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+97264+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1670856425; cv=none; d=zohomail.com; s=zohoarc; b=DBAGj8oxMvrnsdOggjOWjXfxp91S+RzPBMWw7om8AgMbZnO/LhftMCbOQ3b4YWHM0En0j0HoPZMZmVAyWkei1B8RJBp2qHr62sd4uCgnnfqkyDWX8SDnVNwlmfcHM8yw4m/gOZ49Kd0lT4Vuk/bz2AfqhQ6Sc5MBLNexswnrExU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670856425; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=r89GyRTA39b4+ZhxPZQq7WsCzBuBr7p4L8V1xI+4feg=; b=Tg4ArpA2ATeeEjWo2OCjkcwqlJvdRQwrievp2Qyqaubq7RsNSR+C9JN2y3YfqOIgTR1as+5TKkyJzm4Fe8mQHWyXbgUyW2CDWfENQD0TmeyeomuUk1RC+/wYuIhpoOgeqh9gDp6HpNqs0YvcGEhx37gy7/rtBEX164KxhpsJpEQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+97264+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1670856425446755.0547119217374; Mon, 12 Dec 2022 06:47:05 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id b2MAYY1788612xEDJNkk0jyD; Mon, 12 Dec 2022 06:47:05 -0800 X-Received: from mail-lf1-f53.google.com (mail-lf1-f53.google.com [209.85.167.53]) by mx.groups.io with SMTP id smtpd.web11.45003.1670856424392905373 for ; Mon, 12 Dec 2022 06:47:04 -0800 X-Received: by mail-lf1-f53.google.com with SMTP id p36so18957147lfa.12 for ; Mon, 12 Dec 2022 06:47:04 -0800 (PST) X-Gm-Message-State: KiDypUslmuSzaKSnapxPpxClx1787277AA= X-Google-Smtp-Source: AA0mqf686Hrf73c3jlN3JqhgPAtFMArUDGB82CpETGG1ns1zSH6DwAnn3KxmeWkVhMG7oypKqYzizA== X-Received: by 2002:a05:6512:c09:b0:4b6:e64c:aec6 with SMTP id z9-20020a0565120c0900b004b6e64caec6mr2368209lfu.63.1670856422590; Mon, 12 Dec 2022 06:47:02 -0800 (PST) X-Received: from localhost.localdomain ([77.221.215.144]) by smtp.gmail.com with ESMTPSA id t4-20020a056512030400b0049c29292250sm1643313lfp.149.2022.12.12.06.47.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Dec 2022 06:47:02 -0800 (PST) From: "Savva Mitrofanov" To: devel@edk2.groups.io Cc: =?UTF-8?q?Marvin=20H=C3=A4user?= , Pedro Falcato , Vitaly Cheptsov Subject: [edk2-devel] [edk2-platforms][PATCH v2 04/11] Ext4Pkg: Fix incorrect checksum metadata feature check Date: Mon, 12 Dec 2022 20:46:47 +0600 Message-Id: <20221212144654.2650-5-savvamtr@gmail.com> In-Reply-To: <20221212144654.2650-1-savvamtr@gmail.com> References: <20221212144654.2650-1-savvamtr@gmail.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,savvamtr@gmail.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1670856425; bh=7pcb73FF4mIihBgfdSpIDwUHoXXMDjiIRHpyBbd0r4U=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=anUxoupMw+HAVFoB2Pp7rCKSP7w13MXI/7sTbOU3xYVohPeIHfuWZacLeqMuxAhzOSR oirfkWGP3zc6dDIJBg+wq76mOEwM4rK7PBqI/bOYj9UgHSJPT5lm00zBJYjd8OyiULHRg PjxyrekxNJqDG7DgIFqnNA9bfqPLeOhkjWI= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1670856426264100013 Content-Type: text/plain; charset="utf-8" Missing comparison !=3D 0 leads to broken logic condition. Also replaced CSUM_SEED feature_incompat check with predefined macro EXT4_HAS_INCOMPAT Cc: Marvin H=C3=A4user Cc: Pedro Falcato Cc: Vitaly Cheptsov Fixes: e55f0527dde48a5f139c1b8f35acc4e6b59dd794 Signed-off-by: Savva Mitrofanov --- Features/Ext4Pkg/Ext4Dxe/Superblock.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Features/Ext4Pkg/Ext4Dxe/Superblock.c b/Features/Ext4Pkg/Ext4D= xe/Superblock.c index edee051c41e8..4c662bd1784f 100644 --- a/Features/Ext4Pkg/Ext4Dxe/Superblock.c +++ b/Features/Ext4Pkg/Ext4Dxe/Superblock.c @@ -220,13 +220,11 @@ Ext4OpenSuperblock ( } =20 // At the time of writing, it's the only supported checksum. - if (Partition->FeaturesCompat & EXT4_FEATURE_RO_COMPAT_METADATA_CSUM && - (Sb->s_checksum_type !=3D EXT4_CHECKSUM_CRC32C)) - { + if (EXT4_HAS_METADATA_CSUM (Partition) && (Sb->s_checksum_type !=3D EXT4= _CHECKSUM_CRC32C)) { return EFI_UNSUPPORTED; } =20 - if ((Partition->FeaturesIncompat & EXT4_FEATURE_INCOMPAT_CSUM_SEED) !=3D= 0) { + if (EXT4_HAS_INCOMPAT (Partition, EXT4_FEATURE_INCOMPAT_CSUM_SEED)) { Partition->InitialSeed =3D Sb->s_checksum_seed; } else { Partition->InitialSeed =3D Ext4CalculateChecksum (Partition, Sb->s_uui= d, 16, ~0U); --=20 2.38.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#97264): https://edk2.groups.io/g/devel/message/97264 Mute This Topic: https://groups.io/mt/95622332/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Thu May 2 21:01:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+97265+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+97265+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1670856426; cv=none; d=zohomail.com; s=zohoarc; b=cMU3uG7gKKMuRAdG+vKhv4ZANUutWZSeyI2a9gN7e7g9/mI/WKZm0khd71ELGa2jQniNhiWCcLwzaEN/1SJi8VM+sSl9AdUWIFA0TKFdHZI8DSC0pMcSFfKTFM0w7eKy2UcR2+PpbE6Wv7sJ1aJ5K7AeLDfWLH/TnYK+frkmoLk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670856426; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=kO3mMUUqv3nvpKiZv+aI+vl5Xy3scVvMLN2aqRn1Xs4=; b=cfdyPGUupIvsF7754XwS/ULgX481zxHOJsaREEeM/z9fuN+LoF5NNRp/woMKBCU7F1Py3ERuk4qT+zZwusN9slbM4/di6LLRGOyN2sglQs8XI/2rkRJVWefFJCHDu9X44VrcM6cRTSLItdSGe5xzcW0nZqzCHLCdsYhYPiV9xFE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+97265+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1670856426538826.7446082310274; Mon, 12 Dec 2022 06:47:06 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id 4sKbYY1788612xc0qCnRa2Ut; Mon, 12 Dec 2022 06:47:06 -0800 X-Received: from mail-lf1-f44.google.com (mail-lf1-f44.google.com [209.85.167.44]) by mx.groups.io with SMTP id smtpd.web10.44805.1670856425579707957 for ; Mon, 12 Dec 2022 06:47:05 -0800 X-Received: by mail-lf1-f44.google.com with SMTP id cf42so19016136lfb.1 for ; Mon, 12 Dec 2022 06:47:05 -0800 (PST) X-Gm-Message-State: 1mHoFbXMAAgGciGw45RlGEYBx1787277AA= X-Google-Smtp-Source: AA0mqf53qZM6Jd860mJYyb8NTFSiaW07/fiCZpdgPx2eJAuPqSZrNyb7lE+AwlQAqUxOnHG8kQjzlg== X-Received: by 2002:a19:ad05:0:b0:4b5:b8cd:d2c6 with SMTP id t5-20020a19ad05000000b004b5b8cdd2c6mr2246305lfc.14.1670856423667; Mon, 12 Dec 2022 06:47:03 -0800 (PST) X-Received: from localhost.localdomain ([77.221.215.144]) by smtp.gmail.com with ESMTPSA id t4-20020a056512030400b0049c29292250sm1643313lfp.149.2022.12.12.06.47.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Dec 2022 06:47:03 -0800 (PST) From: "Savva Mitrofanov" To: devel@edk2.groups.io Cc: =?UTF-8?q?Marvin=20H=C3=A4user?= , Pedro Falcato , Vitaly Cheptsov Subject: [edk2-devel] [edk2-platforms][PATCH v2 05/11] Ext4Pkg: Fix division by zero by adding check for s_inodes_per_group Date: Mon, 12 Dec 2022 20:46:48 +0600 Message-Id: <20221212144654.2650-6-savvamtr@gmail.com> In-Reply-To: <20221212144654.2650-1-savvamtr@gmail.com> References: <20221212144654.2650-1-savvamtr@gmail.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,savvamtr@gmail.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1670856426; bh=KCLlbUmrgmJMPgfeXykPXN/Mf8ue35d8JlYNDkUTUaU=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=c9rhpmnni+UAF7lt/zdu46v43eCa6CRD/bZWgiAFxDntK9T4vriNZ/cS6P5gxFBxf29 yu5MJSYGELlI8pk7Wwj8CwiYKlQd8+nsYvFiODkJaYNz9FuYnsUf+eApGIeGrlz0ERbyj GP8SyJSeer2jNifmZJWfOGsgyj7t8x8wqyc= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1670856428278100022 Content-Type: text/plain; charset="utf-8" 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: e55f0527dde48a5f139c1b8f35acc4e6b59dd794 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 4c662bd1784f..adaf475ea54d 100644 --- a/Features/Ext4Pkg/Ext4Dxe/Superblock.c +++ b/Features/Ext4Pkg/Ext4Dxe/Superblock.c @@ -243,6 +243,11 @@ Ext4OpenSuperblock ( =20 DEBUG ((DEBUG_FS, "Read only =3D %u\n", Partition->ReadOnly)); =20 + if (Sb->s_inodes_per_group =3D=3D 0) { + DEBUG ((DEBUG_ERROR, "[ext4] Inodes per group can not be zero\n")); + return EFI_VOLUME_CORRUPTED; + } + Partition->BlockSize =3D (UINT32)LShiftU64 (1024, Sb->s_log_block_size); =20 // The size of a block group can also be calculated as 8 * Partition->Bl= ockSize --=20 2.38.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#97265): https://edk2.groups.io/g/devel/message/97265 Mute This Topic: https://groups.io/mt/95622333/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Thu May 2 21:01:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+97266+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+97266+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1670856427; cv=none; d=zohomail.com; s=zohoarc; b=gFDJ3VKyjkvazE9msMs6JRDJWDCO7nLTSle44JBSBwbN/e3GHNNucrwVIMTIMR02NIoVoSh+GLyoRqOPNodCTw/L8liV0GgvCwa1Wm3BfFHuS59w79xy7u860FF/2lN4WmZFL/EPbjy9M6YN/C3RKkzQZKvgyuC7+X8N/6dTKLU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670856427; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=9M63b23P2F4wl+BRnMiugC2bp8Z2crJAFLhg1hxvsyg=; b=Xkx7Y3uUM5uLbuIn7l4VYqemy/7ROANAfNk3DZEP//fta6kcP1End5QlO9HQ7VgRU3bcfiQb28OZtwIfd06U1RLc+PSUcN9aj4OdMkN7ECgLZEVtPzMH+BjqWv9R77g69azzbPz9pNKMisOLtBlSv6TO6QO+VR5SazkjzzCoOuk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+97266+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1670856427437177.64137518820155; Mon, 12 Dec 2022 06:47:07 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id TWscYY1788612xuV7eC5iBVA; Mon, 12 Dec 2022 06:47:06 -0800 X-Received: from mail-lf1-f53.google.com (mail-lf1-f53.google.com [209.85.167.53]) by mx.groups.io with SMTP id smtpd.web11.45003.1670856424392905373 for ; Mon, 12 Dec 2022 06:47:06 -0800 X-Received: by mail-lf1-f53.google.com with SMTP id p36so18957318lfa.12 for ; Mon, 12 Dec 2022 06:47:05 -0800 (PST) X-Gm-Message-State: PVpUzr6mMcmREwCtywu9Ujmgx1787277AA= X-Google-Smtp-Source: AA0mqf5ra5gAQLyRTXs5HX42VD9Mc0W+kes90AqqAS/cNOWANBeL1wL9mQ/B6lPXrBjmszoqsIFYaQ== X-Received: by 2002:a05:6512:2293:b0:4b5:5dea:ec68 with SMTP id f19-20020a056512229300b004b55deaec68mr5656846lfu.44.1670856424845; Mon, 12 Dec 2022 06:47:04 -0800 (PST) X-Received: from localhost.localdomain ([77.221.215.144]) by smtp.gmail.com with ESMTPSA id t4-20020a056512030400b0049c29292250sm1643313lfp.149.2022.12.12.06.47.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Dec 2022 06:47:04 -0800 (PST) From: "Savva Mitrofanov" To: devel@edk2.groups.io Cc: =?UTF-8?q?Marvin=20H=C3=A4user?= , Pedro Falcato , Vitaly Cheptsov Subject: [edk2-devel] [edk2-platforms][PATCH v2 06/11] Ext4Pkg: Add inode number validity check Date: Mon, 12 Dec 2022 20:46:49 +0600 Message-Id: <20221212144654.2650-7-savvamtr@gmail.com> In-Reply-To: <20221212144654.2650-1-savvamtr@gmail.com> References: <20221212144654.2650-1-savvamtr@gmail.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,savvamtr@gmail.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1670856426; bh=A4Ldssa0ol/RQUeoojnZ+5+a0/YR2xAWmHX2TsieAks=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=Ic4wzvCDE4y8sugHavBh3VKzuIRumRxH4sgyFmeQcpb6eZBw30vvNp59aD536pigfyF +NpHIwZQpdfMC4ePYgZp4n4Wu4moueaZoPQe4LiwbmnMB1wTPgBbJL348MnhJTrd4W7cB /ZzSieYfKhirtWuKJfUc1N9uJcMZ31enN6s= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1670856428294100024 Content-Type: text/plain; charset="utf-8" We need to validate inode number to prevent possible null-pointer dereference of directory parent in Ext4OpenDirent. Also checks that inode number valid across opened partition before we read it in Ext4ReadInode. Cc: Marvin H=C3=A4user Cc: Pedro Falcato Cc: Vitaly Cheptsov Fixes: e55f0527dde48a5f139c1b8f35acc4e6b59dd794 Signed-off-by: Savva Mitrofanov --- Features/Ext4Pkg/Ext4Dxe/Ext4Disk.h | 15 +++++++++--- Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h | 25 ++++++++++++++++++++ Features/Ext4Pkg/Ext4Dxe/BlockGroup.c | 5 ++++ Features/Ext4Pkg/Ext4Dxe/Directory.c | 10 ++++++++ 4 files changed, 52 insertions(+), 3 deletions(-) diff --git a/Features/Ext4Pkg/Ext4Dxe/Ext4Disk.h b/Features/Ext4Pkg/Ext4Dxe= /Ext4Disk.h index 1285644dcb25..6b56ce6813fc 100644 --- a/Features/Ext4Pkg/Ext4Dxe/Ext4Disk.h +++ b/Features/Ext4Pkg/Ext4Dxe/Ext4Disk.h @@ -397,7 +397,7 @@ typedef struct _Ext4Inode { UINT32 i_projid; } EXT4_INODE; =20 -#define EXT4_NAME_MAX 255 +#define EXT4_NAME_MAX 255 =20 typedef struct { UINT32 inode; @@ -469,8 +469,17 @@ typedef UINT64 EXT4_BLOCK_NR; typedef UINT32 EXT2_BLOCK_NR; typedef UINT32 EXT4_INO_NR; =20 -// 2 is always the root inode number in ext4 -#define EXT4_ROOT_INODE_NR 2 +/* Special inode numbers */ +#define EXT4_ROOT_INODE_NR 2 +#define EXT4_USR_QUOTA_INODE_NR 3 +#define EXT4_GRP_QUOTA_INODE_NR 4 +#define EXT4_BOOT_LOADER_INODE_NR 5 +#define EXT4_UNDEL_DIR_INODE_NR 6 +#define EXT4_RESIZE_INODE_NR 7 +#define EXT4_JOURNAL_INODE_NR 8 + +/* First non-reserved inode for old ext4 filesystems */ +#define EXT4_GOOD_OLD_FIRST_INODE_NR 11 =20 #define EXT4_BLOCK_FILE_HOLE 0 =20 diff --git a/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h b/Features/Ext4Pkg/Ext4Dxe/= Ext4Dxe.h index 81ba568c5947..beceb9d60dcb 100644 --- a/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h +++ b/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h @@ -287,6 +287,31 @@ Ext4GetBlockGroupDesc ( IN UINT32 BlockGroup ); =20 +/** + Retrieves the first usable non-reserved inode number from the superblock + of the opened partition. + + @param[in] Partition Pointer to the opened ext4 partition. + + @return The first usable inode number (non-reserved). +**/ +#define EXT4_FIRST_INODE_NR(Partition) = \ + ((Partition->SuperBlock.s_rev_level =3D=3D EXT4_GOOD_OLD_REV) ? = \ + EXT4_GOOD_OLD_FIRST_INODE_NR : = \ + Partition->SuperBlock.s_first_ino) + +/** + Checks inode number validity across superblock of the opened partition. + + @param[in] Partition Pointer to the opened ext4 partition. + + @return TRUE if inode number is valid. +**/ +#define EXT4_IS_VALID_INODE_NR(Partition, InodeNum) = \ + (InodeNum =3D=3D EXT4_ROOT_INODE_NR || = \ + (InodeNum >=3D EXT4_FIRST_INODE_NR(Partition) && = \ + InodeNum <=3D Partition->SuperBlock.s_inodes_count)) + /** Reads an inode from disk. =20 diff --git a/Features/Ext4Pkg/Ext4Dxe/BlockGroup.c b/Features/Ext4Pkg/Ext4D= xe/BlockGroup.c index cba96cd95afc..f34cdc5dbad7 100644 --- a/Features/Ext4Pkg/Ext4Dxe/BlockGroup.c +++ b/Features/Ext4Pkg/Ext4Dxe/BlockGroup.c @@ -50,6 +50,11 @@ Ext4ReadInode ( EXT4_BLOCK_NR InodeTableStart; EFI_STATUS Status; =20 + if (!EXT4_IS_VALID_INODE_NR (Partition, InodeNum)) { + DEBUG ((DEBUG_ERROR, "[ext4] Error reading inode: inode number %lu isn= 't valid\n", InodeNum)); + return EFI_VOLUME_CORRUPTED; + } + BlockGroupNumber =3D (UINT32)DivU64x64Remainder ( InodeNum - 1, Partition->SuperBlock.s_inodes_per_group, diff --git a/Features/Ext4Pkg/Ext4Dxe/Directory.c b/Features/Ext4Pkg/Ext4Dx= e/Directory.c index ffc0e8043076..ff476c8641e8 100644 --- a/Features/Ext4Pkg/Ext4Dxe/Directory.c +++ b/Features/Ext4Pkg/Ext4Dxe/Directory.c @@ -163,6 +163,10 @@ Ext4RetrieveDirent ( if (Entry->inode =3D=3D 0) { BlockOffset +=3D Entry->rec_len; continue; + } else if (!EXT4_IS_VALID_INODE_NR (Partition, Entry->inode)) { + DEBUG ((DEBUG_ERROR, "[ext4] Ext4RetrieveDirent directory entry in= ode number %u isn't valid\n", Entry->inode)); + Status =3D EFI_VOLUME_CORRUPTED; + goto Out; } =20 Status =3D Ext4GetUcs2DirentName (Entry, DirentUcs2Name); @@ -498,6 +502,12 @@ Ext4ReadDir ( // When inode =3D 0, it's unused. ShouldSkip =3D Entry.inode =3D=3D 0 || IsDotOrDotDot; =20 + if ((Entry.inode !=3D 0) && !EXT4_IS_VALID_INODE_NR (Partition, Entry.= inode)) { + DEBUG ((DEBUG_ERROR, "[ext4] Ext4ReadDir directory entry inode numbe= r %u isn't valid\n", Entry.inode)); + Status =3D EFI_VOLUME_CORRUPTED; + goto Out; + } + if (ShouldSkip) { Offset +=3D Entry.rec_len; continue; --=20 2.38.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#97266): https://edk2.groups.io/g/devel/message/97266 Mute This Topic: https://groups.io/mt/95622334/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Thu May 2 21:01:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+97267+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+97267+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1670856429; cv=none; d=zohomail.com; s=zohoarc; b=M6SrDbptgoWmO7Ehafh60ktfRmkwwzKvc7Hu0UlRvyyYPvZK7SRIbHZ6zAX1M3OUobKhgxBjYVLvS4kFvQ/w+yt1EDHx64mvhQ4Q5dLdVHioFSbOPQ2YDioxd+IYBb4xGG3xXRx3gNDgK7ZfsTzuykZBNKC2S3gCTbnUwCfcYpo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670856429; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=luSWOQzm6Srtkoaj9xWqtDu5b8N7q6Mrlo9S3roIYns=; b=Wid20kbXye3oIjmVlWnr+TDhdOkEE5wOQsed01Xu4utcv55YAo9pb7eAeB11BsagJ9DOKlQ763CXtSBDCOHN7R5y6+v7cHonTMMlsPzEp36WlYZhgseoaeE30mXnJ7PHWNltUZp3RtwUgSM52wZb8T93+0IO0Ii9XJ557+tLAGg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+97267+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1670856429468934.3571167529122; Mon, 12 Dec 2022 06:47:09 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id lQyNYY1788612xE4YM9CwR2L; Mon, 12 Dec 2022 06:47:08 -0800 X-Received: from mail-lf1-f54.google.com (mail-lf1-f54.google.com [209.85.167.54]) by mx.groups.io with SMTP id smtpd.web11.45005.1670856427796152696 for ; Mon, 12 Dec 2022 06:47:08 -0800 X-Received: by mail-lf1-f54.google.com with SMTP id j4so19029165lfk.0 for ; Mon, 12 Dec 2022 06:47:07 -0800 (PST) X-Gm-Message-State: BkjzG6iY8n3xbZ1zWJJODKtox1787277AA= X-Google-Smtp-Source: AA0mqf5pxUXNdoriyH6ASrY/OcWt4f7gu7fdjNbQECqE+J+hVjBJAoXHTkvC8v5bGbK7sPxKeUwFCA== X-Received: by 2002:a05:6512:400e:b0:4b5:5f2b:ddf8 with SMTP id br14-20020a056512400e00b004b55f2bddf8mr5122702lfb.7.1670856425998; Mon, 12 Dec 2022 06:47:05 -0800 (PST) X-Received: from localhost.localdomain ([77.221.215.144]) by smtp.gmail.com with ESMTPSA id t4-20020a056512030400b0049c29292250sm1643313lfp.149.2022.12.12.06.47.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Dec 2022 06:47:05 -0800 (PST) From: "Savva Mitrofanov" To: devel@edk2.groups.io Cc: =?UTF-8?q?Marvin=20H=C3=A4user?= , Pedro Falcato , Vitaly Cheptsov Subject: [edk2-devel] [edk2-platforms][PATCH v2 07/11] Ext4Pkg: Fix shift out of bounds in Ext4OpenSuperblock Date: Mon, 12 Dec 2022 20:46:50 +0600 Message-Id: <20221212144654.2650-8-savvamtr@gmail.com> In-Reply-To: <20221212144654.2650-1-savvamtr@gmail.com> References: <20221212144654.2650-1-savvamtr@gmail.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,savvamtr@gmail.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1670856428; bh=EJ6FY8ToRSd3vaAbTdLDR5w51OssscN5hKDVqmyF/po=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=o2uBAqDFV0VTTmpxuWHVNE2Nk4qGBFWPOSJxVO2QC4JJBES/cesltTwYjNHnYo9+5Ma QkY1hgG/PhwGjYGWqfU0NNeVV4V4MkAU92hAONBy+2PVzlcA0KRDnMN1AJSItTJcrX/Dl yUzUMDeEPIyDq8zNUn3mcrwsT4ge4vCuHfo= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1670856430302100029 Content-Type: text/plain; charset="utf-8" Missing check for wrong s_log_block_size exponent leads to shift out of bounds. Limit block size to 2 MiB Cc: Marvin H=C3=A4user Cc: Pedro Falcato Cc: Vitaly Cheptsov Fixes: e55f0527dde48a5f139c1b8f35acc4e6b59dd794 Signed-off-by: Savva Mitrofanov --- Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h | 14 ++++++++++++++ Features/Ext4Pkg/Ext4Dxe/Superblock.c | 5 +++++ 2 files changed, 19 insertions(+) diff --git a/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h b/Features/Ext4Pkg/Ext4Dxe/= Ext4Dxe.h index beceb9d60dcb..a7e138e99561 100644 --- a/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h +++ b/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h @@ -40,6 +40,20 @@ #define EXT4_EFI_PATH_MAX 4096 #define EXT4_DRIVER_VERSION 0x0000 =20 +// +// The EXT4 Specification doesn't strictly limit block size and this value= could be up to 2^31, +// but in practice it is limited by PAGE_SIZE due to performance significa= nt impact. +// Many EXT4 implementations have size of block limited to PAGE_SIZE. In m= any cases it's limited +// to 4096, which is a commonly supported page size on most MMU-capable ha= rdware, and up to 65536. +// So, to take a balance between compatibility and security measures, it i= s decided to use the +// value of 2MiB as the limit, which is equal to page size on new hardware. +// As for supporting big block sizes, EXT4 has a RO_COMPAT_FEATURE called = BIGALLOC, which changes +// EXT4 to use clustered allocation, so that each bit in the ext4 block al= location bitmap addresses +// a power of two number of blocks. So it would be wiser to implement and = use this feature +// if there is such a need instead of big block size. +// +#define EXT4_LOG_BLOCK_SIZE_MAX 11 + /** Opens an ext4 partition and installs the Simple File System protocol. =20 diff --git a/Features/Ext4Pkg/Ext4Dxe/Superblock.c b/Features/Ext4Pkg/Ext4D= xe/Superblock.c index adaf475ea54d..ffe66a8bb847 100644 --- a/Features/Ext4Pkg/Ext4Dxe/Superblock.c +++ b/Features/Ext4Pkg/Ext4Dxe/Superblock.c @@ -248,6 +248,11 @@ Ext4OpenSuperblock ( return EFI_VOLUME_CORRUPTED; } =20 + if (Sb->s_log_block_size > EXT4_LOG_BLOCK_SIZE_MAX) { + DEBUG ((DEBUG_ERROR, "[ext4] SuperBlock s_log_block_size %lu is too bi= g\n", Sb->s_log_block_size)); + return EFI_UNSUPPORTED; + } + Partition->BlockSize =3D (UINT32)LShiftU64 (1024, Sb->s_log_block_size); =20 // The size of a block group can also be calculated as 8 * Partition->Bl= ockSize --=20 2.38.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#97267): https://edk2.groups.io/g/devel/message/97267 Mute This Topic: https://groups.io/mt/95622335/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Thu May 2 21:01:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+97268+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+97268+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1670856429; cv=none; d=zohomail.com; s=zohoarc; b=S6vAkAWunG6wtuVwKidP3dh+RpxRcJnxVQrwGcZ6RJT+raP4h0nIvNNl8qOcayI9bmhPD0do7zPFY/E3ulykJA4IB0BT7E3DesxMqAFzj69i6tQbol3rh3YtR5SZ+59T9a9TctwSFtUVxHYuI+2qcta1GzRT5vw5lkuxVpd0C2E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670856429; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=IuDRRTC2yErjP9WPsl76K3jdMSyZLq5rX4t6aCxSbjE=; b=k+RYr8BZXsaTcxsq4Cj9pzUGUlwQ0nO3o3/Wdf2hJrNJyPXO1UOr3b8ZX+kCaEv8cDTjsIUh9WcB5T2uE2ZGTfvp2fm4z/qA4jMPDhgi/qdldcSPp61vymRLu93cU1vbrCfaB2bzjBHhrAl4WA03QYFkB0psz71kAP8cU8MFtVE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+97268+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1670856429812145.28572043391114; Mon, 12 Dec 2022 06:47:09 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id jaNcYY1788612xA4W2TMaoLd; Mon, 12 Dec 2022 06:47:09 -0800 X-Received: from mail-lf1-f48.google.com (mail-lf1-f48.google.com [209.85.167.48]) by mx.groups.io with SMTP id smtpd.web10.44807.1670856428797007688 for ; Mon, 12 Dec 2022 06:47:09 -0800 X-Received: by mail-lf1-f48.google.com with SMTP id 1so18982862lfz.4 for ; Mon, 12 Dec 2022 06:47:08 -0800 (PST) X-Gm-Message-State: c5Vm6hM1fXEiW1gfSeVihUhQx1787277AA= X-Google-Smtp-Source: AA0mqf4Bj7JiQDatxp13AVUwxSAIzKkrM+SRN4KWxvR17y8I+DM3l1M54KY/7S0RN6V0J8J0FEznBQ== X-Received: by 2002:a05:6512:2186:b0:4a4:68b9:66cc with SMTP id b6-20020a056512218600b004a468b966ccmr4219671lft.23.1670856426983; Mon, 12 Dec 2022 06:47:06 -0800 (PST) X-Received: from localhost.localdomain ([77.221.215.144]) by smtp.gmail.com with ESMTPSA id t4-20020a056512030400b0049c29292250sm1643313lfp.149.2022.12.12.06.47.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Dec 2022 06:47:06 -0800 (PST) From: "Savva Mitrofanov" To: devel@edk2.groups.io Cc: =?UTF-8?q?Marvin=20H=C3=A4user?= , Pedro Falcato , Vitaly Cheptsov Subject: [edk2-devel] [edk2-platforms][PATCH v2 08/11] Ext4Pkg: Corrects integer overflow check logic in DiskUtil Date: Mon, 12 Dec 2022 20:46:51 +0600 Message-Id: <20221212144654.2650-9-savvamtr@gmail.com> In-Reply-To: <20221212144654.2650-1-savvamtr@gmail.com> References: <20221212144654.2650-1-savvamtr@gmail.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,savvamtr@gmail.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1670856429; bh=PFPTqf8j79nYG6iLlv4uaxWjSHhPzIekeikcn8KtlZk=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=uX7yDURgyuDNa26WEkbojqZ5mZQk0YkS1kJGJ6ZFmz+HGR7fUbeEZfizMRNxlTcAeyR jQ64Wt40MsdzsB8O3ysliW1FsOiqvKA+p23L6bfT7VVkizCLU4D/fkxwJyhIg8miHUyTj 3wiZBfP6O8TNMHjPymhzq/CSsfJDmLyUVYQ= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1670856430309100031 Content-Type: text/plain; charset="utf-8" Corrects multiplication overflow check code Cc: Marvin H=C3=A4user Cc: Pedro Falcato Cc: Vitaly Cheptsov Fixes: e55f0527dde48a5f139c1b8f35acc4e6b59dd794 Signed-off-by: Savva Mitrofanov --- Features/Ext4Pkg/Ext4Pkg.dsc | 2 +- Features/Ext4Pkg/Ext4Dxe/DiskUtil.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Features/Ext4Pkg/Ext4Pkg.dsc b/Features/Ext4Pkg/Ext4Pkg.dsc index 59bc327ebf6e..621c63eaf92d 100644 --- a/Features/Ext4Pkg/Ext4Pkg.dsc +++ b/Features/Ext4Pkg/Ext4Pkg.dsc @@ -46,7 +46,7 @@ DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf OrderedCollectionLib|MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib= /BaseOrderedCollectionRedBlackTreeLib.inf BaseUcs2Utf8Lib|RedfishPkg/Library/BaseUcs2Utf8Lib/BaseUcs2Utf8Lib.inf - =20 + # # Required for stack protector support # diff --git a/Features/Ext4Pkg/Ext4Dxe/DiskUtil.c b/Features/Ext4Pkg/Ext4Dxe= /DiskUtil.c index 32da35f7d9f5..c4af956da926 100644 --- a/Features/Ext4Pkg/Ext4Dxe/DiskUtil.c +++ b/Features/Ext4Pkg/Ext4Dxe/DiskUtil.c @@ -60,11 +60,11 @@ Ext4ReadBlocks ( // Check for overflow on the block -> byte conversions. // Partition->BlockSize is never 0, so we don't need to check for that. =20 - if (Offset > DivU64x32 ((UINT64)-1, Partition->BlockSize)) { + if ((NumberBlocks !=3D 0) && (DivU64x64Remainder (Offset, BlockNumber, N= ULL) !=3D Partition->BlockSize)) { return EFI_INVALID_PARAMETER; } =20 - if (Length > (UINTN)-1/Partition->BlockSize) { + if ((NumberBlocks !=3D 0) && (Length / NumberBlocks !=3D Partition->Bloc= kSize)) { return EFI_INVALID_PARAMETER; } =20 @@ -94,12 +94,12 @@ Ext4AllocAndReadBlocks ( =20 Length =3D NumberBlocks * Partition->BlockSize; =20 - if (Length > (UINTN)-1/Partition->BlockSize) { + // Check for integer overflow + if ((NumberBlocks !=3D 0) && (Length / NumberBlocks !=3D Partition->Bloc= kSize)) { return NULL; } =20 Buf =3D AllocatePool (Length); - if (Buf =3D=3D NULL) { return NULL; } --=20 2.38.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#97268): https://edk2.groups.io/g/devel/message/97268 Mute This Topic: https://groups.io/mt/95622336/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Thu May 2 21:01:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+97269+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+97269+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1670856430; cv=none; d=zohomail.com; s=zohoarc; b=IDlFg2gprWaaQuoW7Lv69UfEGuEj1dUlvSDzHhsVv09PnjBBpJecMV6/qElhLcgzqeug9WQ61CI32s4jyX75klH1gvK5NJ11m581c1QjpoH+Zl81nxr2cy0aJuhKSmDjjTDx6WHTUAa5HiZbqwEgk+NVexMdMK5BulJwe3MbDRM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670856430; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=2I35z+ORl6LnjhOs9TdexlbquQCnteQqpwkAtuahb80=; b=WAPDhe6y/FtJp/lLD7HExSBAhOJxH9TcvFMrtlDT5pIllurHiiAU8DZIKSz7xigBWS4cnipttX3DlQyxX9xSpfKiQLh4Qr1v3fdYUwBnnzgUlOnUlQySxBcYcm5m2KwRqnD32lIginzUBWT0Q2zhPAAfx/BNXPv+Zi/CC+Q051A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+97269+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1670856430449916.7543515075535; Mon, 12 Dec 2022 06:47:10 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id ee4kYY1788612xzH0tq3cSKp; Mon, 12 Dec 2022 06:47:10 -0800 X-Received: from mail-lf1-f53.google.com (mail-lf1-f53.google.com [209.85.167.53]) by mx.groups.io with SMTP id smtpd.web11.45003.1670856424392905373 for ; Mon, 12 Dec 2022 06:47:09 -0800 X-Received: by mail-lf1-f53.google.com with SMTP id p36so18957577lfa.12 for ; Mon, 12 Dec 2022 06:47:08 -0800 (PST) X-Gm-Message-State: pbT6aCRa31Wom27352hezuKDx1787277AA= X-Google-Smtp-Source: AA0mqf7VmnljBT6/PQ/TVow+xZa4r9agco5TdcGLgzsJ1eLGrb5nOr7y7s+MNV4UNRy4WvRUg+S57w== X-Received: by 2002:a05:6512:790:b0:4b5:9b8f:cc82 with SMTP id x16-20020a056512079000b004b59b8fcc82mr3758239lfr.0.1670856428223; Mon, 12 Dec 2022 06:47:08 -0800 (PST) X-Received: from localhost.localdomain ([77.221.215.144]) by smtp.gmail.com with ESMTPSA id t4-20020a056512030400b0049c29292250sm1643313lfp.149.2022.12.12.06.47.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Dec 2022 06:47:07 -0800 (PST) From: "Savva Mitrofanov" To: devel@edk2.groups.io Cc: =?UTF-8?q?Marvin=20H=C3=A4user?= , Pedro Falcato , Vitaly Cheptsov Subject: [edk2-devel] [edk2-platforms][PATCH v2 09/11] Ext4Pkg: Check that source file is directory in Ext4OpenInternal Date: Mon, 12 Dec 2022 20:46:52 +0600 Message-Id: <20221212144654.2650-10-savvamtr@gmail.com> In-Reply-To: <20221212144654.2650-1-savvamtr@gmail.com> References: <20221212144654.2650-1-savvamtr@gmail.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,savvamtr@gmail.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1670856430; bh=e/iCVMvvjDdYPwKNed5Mvsv0Vkana1L6ANl124z99Lg=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=jHJ0sIzFq5U8mLS3swCejA+sCcXkieM24Vgj/JPyh7b/8v7IFPer9RJyEstFYTjX4uV PXsSlwQoMVkTrwg2wAt9jmsygx6oHkRa/eNFShm2euOvInKt74cZ4owYNxiYAJnXBTA8O 6QwQZiVa4y6R2JXKQciGohXPsP7SuxFoMQo= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1670856432411100037 Content-Type: text/plain; charset="utf-8" This check already present in the while loop below, but absent for cases when input file is nameless, so to handle assertion in Ext4ReadFile we need to add it at the top of function Cc: Marvin H=C3=A4user Cc: Pedro Falcato Cc: Vitaly Cheptsov Fixes: e55f0527dde48a5f139c1b8f35acc4e6b59dd794 Signed-off-by: Savva Mitrofanov --- Features/Ext4Pkg/Ext4Dxe/File.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Features/Ext4Pkg/Ext4Dxe/File.c b/Features/Ext4Pkg/Ext4Dxe/Fil= e.c index 04198a53bfc0..20a0194a5793 100644 --- a/Features/Ext4Pkg/Ext4Dxe/File.c +++ b/Features/Ext4Pkg/Ext4Dxe/File.c @@ -207,6 +207,11 @@ Ext4OpenInternal ( Level =3D 0; =20 DEBUG ((DEBUG_FS, "[ext4] Ext4OpenInternal %s\n", FileName)); + + if (!Ext4FileIsDir (Current)) { + return EFI_INVALID_PARAMETER; + } + // If the path starts with a backslash, we treat the root directory as t= he base directory if (FileName[0] =3D=3D L'\\') { FileName++; @@ -219,6 +224,10 @@ Ext4OpenInternal ( return EFI_ACCESS_DENIED; } =20 + if (!Ext4FileIsDir (Current)) { + return EFI_INVALID_PARAMETER; + } + // Discard leading path separators while (FileName[0] =3D=3D L'\\') { FileName++; @@ -242,10 +251,6 @@ Ext4OpenInternal ( =20 DEBUG ((DEBUG_FS, "[ext4] Opening %s\n", PathSegment)); =20 - if (!Ext4FileIsDir (Current)) { - return EFI_INVALID_PARAMETER; - } - if (!Ext4IsLastPathSegment (FileName)) { if (!Ext4DirCanLookup (Current)) { return EFI_ACCESS_DENIED; --=20 2.38.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#97269): https://edk2.groups.io/g/devel/message/97269 Mute This Topic: https://groups.io/mt/95622337/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Thu May 2 21:01:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+97270+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+97270+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1670856432; cv=none; d=zohomail.com; s=zohoarc; b=RVNWXVE2iXXDBV3wTZeXS3VsREDdWdVvUQO75WxEV1sxAHx+GtFHvjxyLvDp4In5f2WRM5rmYfNYXr8pGJwlGL+wLBkOOyd3jwuBxHfHDCz9Wukw7r/nDgR7aY02/YKe7yGVnN+e8n2aLJ9YaijQXJAZan6PINkkYT2Xbe9FeAo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670856432; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=D/eHBvrgq8NQ1uLHefqtZWezZvFOHvQzxrBtcUce3Hc=; b=IztUz/emdgM8/YYwWPWi0/trT5XWJ2bJxER4qyJROnK9m46p8wQAPgUvocSaT9g4NAzUZGpLkuhN8sIb22K1gjqKC6tI6ZHxkfVWRHuS0SBFvX/oiBLGhVTt+P/8wDlfOz0Dz1NCZcYfJxLquhJePHmzetcIGyMkMLmSc1GJlpw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+97270+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1670856432741664.4403085270036; Mon, 12 Dec 2022 06:47:12 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id XegDYY1788612x1OihsmoUog; Mon, 12 Dec 2022 06:47:11 -0800 X-Received: from mail-lf1-f47.google.com (mail-lf1-f47.google.com [209.85.167.47]) by mx.groups.io with SMTP id smtpd.web10.44810.1670856431021873589 for ; Mon, 12 Dec 2022 06:47:11 -0800 X-Received: by mail-lf1-f47.google.com with SMTP id p8so18950657lfu.11 for ; Mon, 12 Dec 2022 06:47:10 -0800 (PST) X-Gm-Message-State: 6u8MlGVm7s7MV59lDS20qKolx1787277AA= X-Google-Smtp-Source: AA0mqf4gA7I0zVKKyWlEg608DGJ1eTlfsW/Xo4riL6vhJ4lQcehGR4IhVx1aNPjuYfL3IumlFQ9h5g== X-Received: by 2002:a05:6512:3c88:b0:4b5:2f1e:7d3b with SMTP id h8-20020a0565123c8800b004b52f1e7d3bmr6009314lfv.33.1670856429197; Mon, 12 Dec 2022 06:47:09 -0800 (PST) X-Received: from localhost.localdomain ([77.221.215.144]) by smtp.gmail.com with ESMTPSA id t4-20020a056512030400b0049c29292250sm1643313lfp.149.2022.12.12.06.47.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Dec 2022 06:47:08 -0800 (PST) From: "Savva Mitrofanov" To: devel@edk2.groups.io Cc: =?UTF-8?q?Marvin=20H=C3=A4user?= , Pedro Falcato , Vitaly Cheptsov Subject: [edk2-devel] [edk2-platforms][PATCH v2 10/11] Ext4Pkg: Check VolumeName allocation correctness in Ext4GetVolumeName Date: Mon, 12 Dec 2022 20:46:53 +0600 Message-Id: <20221212144654.2650-11-savvamtr@gmail.com> In-Reply-To: <20221212144654.2650-1-savvamtr@gmail.com> References: <20221212144654.2650-1-savvamtr@gmail.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,savvamtr@gmail.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1670856431; bh=e1EO0OwJoRlIjv1fwHOza8Em9/KYG2bN9HfrhW3wpTw=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=kwU94z17HllkVJ3XfTYxcYIHESeUTpeKvH/w1KOcoHkDrlelPSJOjexDvqFh45CxDBh pGq7skUcY7IGHPK064BK4r0hnJv9UGhS91fplgrj+OfW2SyDwgirFh1ojbwvJqhlLHVuJ Z3b+zV/JyOV3EEZqwdDOjWXrn3rkpNmcXbI= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1670856434316100044 Content-Type: text/plain; charset="utf-8" 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=C3=A4user Cc: Pedro Falcato Cc: Vitaly Cheptsov Fixes: e55f0527dde48a5f139c1b8f35acc4e6b59dd794 Signed-off-by: Savva Mitrofanov --- 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/Fil= e.c index 20a0194a5793..085cb7236957 100644 --- a/Features/Ext4Pkg/Ext4Dxe/File.c +++ b/Features/Ext4Pkg/Ext4Dxe/File.c @@ -719,7 +719,11 @@ Ext4GetVolumeName ( =20 VolNameLength =3D StrLen (VolumeName); } else { - VolumeName =3D AllocateZeroPool (sizeof (CHAR16)); + VolumeName =3D AllocateZeroPool (sizeof (CHAR16)); + if (VolumeName =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; + } + VolNameLength =3D 0; } =20 @@ -786,7 +790,9 @@ Ext4GetFilesystemInfo ( Info->VolumeSize =3D MultU64x32 (TotalBlocks, Part->BlockSize); Info->FreeSpace =3D MultU64x32 (FreeBlocks, Part->BlockSize); =20 - StrCpyS (Info->VolumeLabel, VolNameLength + 1, VolumeName); + Status =3D StrCpyS (Info->VolumeLabel, VolNameLength + 1, VolumeName); + + ASSERT_EFI_ERROR (Status); =20 FreePool (VolumeName); =20 diff --git a/Features/Ext4Pkg/Ext4Dxe/Inode.c b/Features/Ext4Pkg/Ext4Dxe/In= ode.c index 5ccb4d2bfc42..2977238d687c 100644 --- a/Features/Ext4Pkg/Ext4Dxe/Inode.c +++ b/Features/Ext4Pkg/Ext4Dxe/Inode.c @@ -230,7 +230,7 @@ Ext4AllocateInode ( =20 Inode =3D AllocateZeroPool (InodeSize); =20 - if (!Inode) { + if (Inode =3D=3D NULL) { return NULL; } =20 --=20 2.38.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#97270): https://edk2.groups.io/g/devel/message/97270 Mute This Topic: https://groups.io/mt/95622339/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Thu May 2 21:01:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+97271+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+97271+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1670856433; cv=none; d=zohomail.com; s=zohoarc; b=Gv2si/H5yIBQtjir4OPS6k26LAzQdQTVFy1OAd9e2y4R2De4ZxzVjH84Upg4mtR7wY076klDlHoxKJHs4c9ErI1tYvsddHD06x00R1uHm4eJgd+0mbMWzkmDtDdKIdUrlyDQ2MN0LAFgF/yeH7VKPQx4Y8jlMvK3x7roz9OHjxQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670856433; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=VeqybtWvgbJTaf+iKYNuKXs+J8WwLpltmTjdzu8qupY=; b=cIvZyMcH6IIAlpUVnDnrtTXkwnbfJhvysaRih9o0lpSnU6LgWut/FeP8et8P6wKgwy8YpJiByZUefjiuTOV2w34jxETc1Fnsx7r8Mn+ChrFtjkl5esqrkxlF5YvwLuOnzZFQAcGVadJoEXTuqU/pkLaTQJkdusG/hiJCOU93CMY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+97271+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1670856433090996.6481439488773; Mon, 12 Dec 2022 06:47:13 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id X448YY1788612xyLOiIAd1kZ; Mon, 12 Dec 2022 06:47:12 -0800 X-Received: from mail-lf1-f46.google.com (mail-lf1-f46.google.com [209.85.167.46]) by mx.groups.io with SMTP id smtpd.web11.44999.1670856421448535571 for ; Mon, 12 Dec 2022 06:47:11 -0800 X-Received: by mail-lf1-f46.google.com with SMTP id y25so18966017lfa.9 for ; Mon, 12 Dec 2022 06:47:10 -0800 (PST) X-Gm-Message-State: 0wH82se97uuK18jTBkD3NG8sx1787277AA= X-Google-Smtp-Source: AA0mqf67FybjucBZ0nSSIZNNHYcB7DJua11FfbY9w/byUIg5mdXyGJnBevcVX1+P/TZHMmjnFj8B1w== X-Received: by 2002:ac2:4c24:0:b0:4b4:900c:3a28 with SMTP id u4-20020ac24c24000000b004b4900c3a28mr3968031lfq.60.1670856430183; Mon, 12 Dec 2022 06:47:10 -0800 (PST) X-Received: from localhost.localdomain ([77.221.215.144]) by smtp.gmail.com with ESMTPSA id t4-20020a056512030400b0049c29292250sm1643313lfp.149.2022.12.12.06.47.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Dec 2022 06:47:09 -0800 (PST) From: "Savva Mitrofanov" To: devel@edk2.groups.io Cc: =?UTF-8?q?Marvin=20H=C3=A4user?= , Pedro Falcato , Vitaly Cheptsov Subject: [edk2-devel] [edk2-platforms][PATCH v2 11/11] Ext4Pkg: Add missing exit Status in Ext4OpenDirent Date: Mon, 12 Dec 2022 20:46:54 +0600 Message-Id: <20221212144654.2650-12-savvamtr@gmail.com> In-Reply-To: <20221212144654.2650-1-savvamtr@gmail.com> References: <20221212144654.2650-1-savvamtr@gmail.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,savvamtr@gmail.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1670856432; bh=9Y7AxquD+p6huiKm8/MtTGiTej3U7b11AD0KLMxzLY8=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=oekhLoVeDYc0rO4PRbq8X9IAKQUileuuwwpiu0grnwTxe1pTPH5eFX+RAaZ6RRqHV+h +iZybVF6Wb4Z7iyAMgvrUvaF6a3u5kDsHEln2E6GL/HCKMR2fOpoOzMWHpkOccnrT3L4P i0zIU+C7PBZppybsJqZmfak6Ru0cw8hd2nU= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1670856434293100043 Content-Type: text/plain; charset="utf-8" Missing EFI_OUT_OF_RESOURCES exit status on failed Ext4CreateDentry leads to NULL-pointer dereference in Ext4GetFileInfo (passing NULL buffer in Ext4ReadDir) Cc: Marvin H=C3=A4user Cc: Pedro Falcato Cc: Vitaly Cheptsov Fixes: e55f0527dde48a5f139c1b8f35acc4e6b59dd794 Signed-off-by: Savva Mitrofanov --- Features/Ext4Pkg/Ext4Dxe/Directory.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Features/Ext4Pkg/Ext4Dxe/Directory.c b/Features/Ext4Pkg/Ext4Dx= e/Directory.c index ff476c8641e8..efdce1477246 100644 --- a/Features/Ext4Pkg/Ext4Dxe/Directory.c +++ b/Features/Ext4Pkg/Ext4Dxe/Directory.c @@ -260,7 +260,8 @@ Ext4OpenDirent ( } else { File->Dentry =3D Ext4CreateDentry (FileName, Directory->Dentry); =20 - if (!File->Dentry) { + if (File->Dentry =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; goto Error; } } --=20 2.38.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#97271): https://edk2.groups.io/g/devel/message/97271 Mute This Topic: https://groups.io/mt/95622340/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-