From nobody Sat Feb 7 07:10:02 2026 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+99143+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+99143+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1674811797; cv=none; d=zohomail.com; s=zohoarc; b=A5vew0Q8Iow55X8+QykQiTYOgDk/HDzXi5LfQBZO3RbdaJaNrI+2O2hkPl7rEtxbHs58ISx3UXkqmQPiHEviUqpBOjTx8b5r3i9Xx7GPBVQHoRsUmI5aKgK5JXFTlouH8B1ZCIQUTVgWkQcRifPTj3lai4q2rXQMFOjKGXH8SPg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1674811797; 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=5Ju/gJ7m4/zrNTU0VhX9uXgcfWnmvv+MZQegKIawe9U=; b=LIuIDS8Zky8aPazKHWE041DZ/3cJHE9FKEdWFj1oNV9PpAtffJaX2hFbhIzZxvVKC0VAlJwBQFRlDPNirdiMQFVYZR/L9McFVKwfLCVQf3VOxyPjP/cbUnSGQ+ekWaTvyhzL9I2fjmYTBAUNK1oL9Tk0gTAxMlxy2iPnkcMYdME= 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+99143+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 1674811797231391.1554052935443; Fri, 27 Jan 2023 01:29:57 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id eMyvYY1788612x0Cu3kAK6se; Fri, 27 Jan 2023 01:29:56 -0800 X-Received: from mail-lj1-f179.google.com (mail-lj1-f179.google.com [209.85.208.179]) by mx.groups.io with SMTP id smtpd.web10.98482.1674811795893637453 for ; Fri, 27 Jan 2023 01:29:56 -0800 X-Received: by mail-lj1-f179.google.com with SMTP id j15so3962629ljg.8 for ; Fri, 27 Jan 2023 01:29:55 -0800 (PST) X-Gm-Message-State: DZajiuHyMoMnjsni02xGeWrvx1787277AA= X-Google-Smtp-Source: AMrXdXtCznDUgCro4sy6yWhfSTLi3Ao7AAmXw3qmIzqG0CGuqaF2feVVFv0jxB+kh4rGMSeovVFgTw== X-Received: by 2002:a2e:a9a4:0:b0:28b:74b5:590e with SMTP id x36-20020a2ea9a4000000b0028b74b5590emr12974607ljq.50.1674811793727; Fri, 27 Jan 2023 01:29:53 -0800 (PST) X-Received: from localhost.localdomain ([176.62.67.29]) by smtp.gmail.com with ESMTPSA id t11-20020a056512068b00b004cc8196a308sm229071lfe.98.2023.01.27.01.29.52 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 27 Jan 2023 01:29:53 -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 v3 07/11] Ext4Pkg: Check that source file is directory in Ext4OpenInternal Date: Fri, 27 Jan 2023 15:29:41 +0600 Message-Id: <20230127092945.94389-8-savvamtr@gmail.com> In-Reply-To: <20230127092945.94389-1-savvamtr@gmail.com> References: <20230127092945.94389-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=1674811796; bh=9H/R5cAea4qLASmeL38zAO4xfMeNqANqlp74kKrNvlI=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=jPm/HVQYwfR8EzEv3PDAS3EU/B2UUe+xaEiXNR/zT5xneLlkbr4o2nhLw8+VchgSWuo lDMshVT9blpGH9GJZuf1cv+Ixd7S5uRiKxf00Pu6M9g+Cw2jNvukA80AA0LifkE6qn5Wy x7RadQ2KhhG+XDOB7LF6Fs9RYUXeiY38ijc= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1674811798661100032 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: d9ceedca6c8f ("Ext4Pkg: Add Ext4Dxe driver.") Signed-off-by: Savva Mitrofanov Reviewed-by: Marvin H=C3=A4user Reviewed-by: Pedro Falcato --- 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 8dfe324255f4..9dde4a5d1a2d 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.39.0 -=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 (#99143): https://edk2.groups.io/g/devel/message/99143 Mute This Topic: https://groups.io/mt/96562696/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-