From nobody Tue Feb 10 10:04:22 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+99453+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+99453+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1675333306; cv=none; d=zohomail.com; s=zohoarc; b=Wfjx0TrLBd9MBlCnjxDPlDivMfK6mQ2G9hbTyz7E4GHNKvJI0nzPIZPFKcw/2tLJriSX9D9lrWH+6nS2EAn3rJGsiD6gielp3tMNVU91RFfbqyNO0qvGRdD8L5+oHQJeEYWiBr61YghiP5cgc36NSHrAmKrQf94s8ZtW1QPnIxo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675333306; 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=xz/cxcPDgsOMiWhnoUrvL/jUIUBdv74BlUp5PKnpAL8=; b=dmGHi+TEEV6iFscEVZU0R4ZBJFqddJAMsn5LKl/tNyRkRK8hnIjRYvag4mb1TViNVF5TslA3TTOpJ8eJ4Di/pBVffg+dc+GWHnD19mdVAUMzNBoTY2/Ia8Qj//ufn+UTGhhc33ZFAZPeOEUyZrQrcE5jjnBDuwAjh/mgE4cXupE= 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+99453+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 1675333306625386.8624147201583; Thu, 2 Feb 2023 02:21:46 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id PQB7YY1788612x1oJQaXaynM; Thu, 02 Feb 2023 02:21:46 -0800 X-Received: from mail-ej1-f49.google.com (mail-ej1-f49.google.com [209.85.218.49]) by mx.groups.io with SMTP id smtpd.web10.11487.1675333300851208931 for ; Thu, 02 Feb 2023 02:21:45 -0800 X-Received: by mail-ej1-f49.google.com with SMTP id m2so4525218ejb.8 for ; Thu, 02 Feb 2023 02:21:44 -0800 (PST) X-Gm-Message-State: b1ECM1CypZLOOw6cheQ7det2x1787277AA= X-Google-Smtp-Source: AK7set97UMS3YRKzfadnF58/1/bC6rt6KOzydsRL3hXD8iZ2+1tIPZIw+3dNKQvFNEcQW8oHrRvIIQ== X-Received: by 2002:a17:906:4fc7:b0:87b:1be:a8c2 with SMTP id i7-20020a1709064fc700b0087b01bea8c2mr6302649ejw.73.1675333304365; Thu, 02 Feb 2023 02:21:44 -0800 (PST) X-Received: from localhost.localdomain ([176.62.67.29]) by smtp.gmail.com with ESMTPSA id ci22-20020a170906c35600b0087bcda2b07bsm10013121ejb.202.2023.02.02.02.21.43 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 02 Feb 2023 02:21:44 -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 v4 07/12] Ext4Pkg: Check that source file is directory in Ext4OpenInternal Date: Thu, 2 Feb 2023 16:21:28 +0600 Message-Id: <20230202102133.51606-8-savvamtr@gmail.com> In-Reply-To: <20230202102133.51606-1-savvamtr@gmail.com> References: <20230202102133.51606-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=1675333306; bh=qAn6Sh9X1+ZzlbIsvcPrvkYlGvoNdBGnIQBjdC4DRG4=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=SVWUJ/KWO46RvR6QgM2ilQJfK/OaGg6SGGyxlzBXX5pky9RhF/LcI0glb1Ip5y9IXen pQa4d9B7h7iDCmnZ5cPv9CUkMY/dFzPsC8l6ufXnmqrCrt3YfNqothKguqwgVvE9IL39i RD936QDYD4QB1+PJvmX8WlrL8lfWaUf2JWo= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1675333307208100023 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: Pedro Falcato Reviewed-by: Marvin H=C3=A4user --- 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.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 (#99453): https://edk2.groups.io/g/devel/message/99453 Mute This Topic: https://groups.io/mt/96697372/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-