From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 3A55E9418A3 for ; Thu, 19 Oct 2023 14:16:19 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=SwYgqmhN8VVHxJmPwmg68LvcHmGKrz7PoyaEsRt3dQo=; c=relaxed/simple; d=groups.io; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From:In-Reply-To:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type:Content-Transfer-Encoding; s=20140610; t=1697724977; v=1; b=pqnYZOp/IGvfPWkSM+Sd6ZN0iuxb5FOOgFy2r9Zt/z8BYdBEnJPJ+fZc5mGStQbenxfzFjdI ToWYAniF/9ZEK/jFyfkmB4E3Pe9hQG2au93YAJZeeb71ru2kD+O9EA2ZIpbtlL37k5e/NrYytta zoSfBaTeDg3yt5D917JE1lLo= X-Received: by 127.0.0.2 with SMTP id wI7TYY7687511xnXVl6lpcKT; Thu, 19 Oct 2023 07:16:17 -0700 X-Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.groups.io with SMTP id smtpd.web10.29057.1697724977096461154 for ; Thu, 19 Oct 2023 07:16:17 -0700 X-Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-656-vTJOgm0XPsSEGwoZmGSQmw-1; Thu, 19 Oct 2023 10:16:13 -0400 X-MC-Unique: vTJOgm0XPsSEGwoZmGSQmw-1 X-Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 28A2288D02B; Thu, 19 Oct 2023 14:16:09 +0000 (UTC) X-Received: from [10.39.193.11] (unknown [10.39.193.11]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C97712026D68; Thu, 19 Oct 2023 14:16:07 +0000 (UTC) Message-ID: Date: Thu, 19 Oct 2023 16:16:06 +0200 MIME-Version: 1.0 Subject: Re: [edk2-devel] [PATCH] OvmfPkg/VirtioFsDxe: tolerate opening an abs. pathname rel. to a reg. file To: Pedro Falcato , devel@edk2.groups.io Cc: Ard Biesheuvel , Gerd Hoffmann , Jiewen Yao , Jordan Justen References: <20231018172434.91280-1-lersek@redhat.com> From: "Laszlo Ersek" In-Reply-To: X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Precedence: Bulk 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,lersek@redhat.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: pAtB5uQujS8OL00OMhsluM1vx7686176AA= Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b="pqnYZOp/"; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=redhat.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io On 10/19/23 15:50, Pedro Falcato wrote: > On Wed, Oct 18, 2023 at 6:24 PM Laszlo Ersek wrote: >> >> Referring to a file relative to a regular file makes no sense (or at least >> it cannot be implemented consistently with how a file is referred to >> relative to a directory). VirtioFsSimpleFileOpen() has enforced this >> strictly since the beginning, and a few months ago I reported USWG Mantis >> ticket #2367 [1] too, for clearing up the related confusion in the UEFI >> spec. >> >> Unfortunately, the shim boot loader contains such a bug [2] [3]. I don't >> believe the shim bug is ever going to be fixed. We can however relax the >> check in VirtioFsSimpleFileOpen() a bit: if the pathname that's being >> opened relative to a regular file is absolute, then the base file is going >> to be ignored anyway, so we can let the caller's bug slide. This happens >> to make shim work. >> >> Why this matters: UEFI-bootable Linux installer ISOs tend to come with >> shim and grub in the embedded (ElTorito) FAT image (ESP). Sometimes you >> want to build upstream shim/grub binaries, but boot the same ISO >> otherwise. The fastest way for overriding the ESP for this purpose is to >> copy its original contents to a virtio filesystem, then overwrite the shim >> and grub binaries from the host side. Note that this is different from >> direct-booting a kernel (via fw_cfg); the point is to check whether the >> just-built shim and grub are able to boot the rest of the ISO. >> >> [1] https://mantis.uefi.org/mantis/view.php?id=2367 >> [2] https://bugzilla.redhat.com/show_bug.cgi?id=1966973 >> [3] https://github.com/rhboot/shim/issues/382 >> >> Cc: Ard Biesheuvel >> Cc: Gerd Hoffmann >> Cc: Jiewen Yao >> Cc: Jordan Justen >> Signed-off-by: Laszlo Ersek >> --- >> >> Notes: >> context:-U4 >> >> OvmfPkg/VirtioFsDxe/SimpleFsOpen.c | 17 ++++++++++++++--- >> 1 file changed, 14 insertions(+), 3 deletions(-) >> >> diff --git a/OvmfPkg/VirtioFsDxe/SimpleFsOpen.c b/OvmfPkg/VirtioFsDxe/SimpleFsOpen.c >> index a13d4f6a1e2d..2ecf3d6c2325 100644 >> --- a/OvmfPkg/VirtioFsDxe/SimpleFsOpen.c >> +++ b/OvmfPkg/VirtioFsDxe/SimpleFsOpen.c >> @@ -394,22 +394,33 @@ VirtioFsSimpleFileOpen ( >> >> // >> // Referring to a file relative to a regular file makes no sense (or at least >> // it cannot be implemented consistently with how a file is referred to >> - // relative to a directory). >> + // relative to a directory). See USWG Mantis ticket #2367. >> // >> if (!VirtioFsFile->IsDirectory) { >> + BOOLEAN BugCompat; >> + >> + // >> + // Tolerate this bug in the caller if FileName is absolute. If FileName is >> + // absolute, then VirtioFsAppendPath() below will disregard >> + // VirtioFsFile->CanonicalPathname. >> + // >> + BugCompat = (FileName[0] == L'\\'); >> + >> DEBUG (( >> - DEBUG_ERROR, >> + BugCompat ? DEBUG_WARN : DEBUG_ERROR, >> ("%a: Label=\"%s\" CanonicalPathname=\"%a\" FileName=\"%s\": " >> "nonsensical request to open a file or directory relative to a regular " >> "file\n"), >> __func__, >> VirtioFs->Label, >> VirtioFsFile->CanonicalPathname, >> FileName >> )); >> - return EFI_INVALID_PARAMETER; >> + if (!BugCompat) { >> + return EFI_INVALID_PARAMETER; >> + } >> } >> >> // >> // Allocate the new VIRTIO_FS_FILE object. >> > > Aww, you should've CC'd me. Ouch! I'm sorry. I've grown to (quite mechanically) consult $EDK_TOOLS_PATH/Scripts/GetMaintainer.py for the Cc list :( > Anyway, retroactive > Acked-by: Pedro Falcato Thank you! (I've pushed the patch already, so can't record your A-b on it, but the mailing list will preserve it at least.) > > If this is the new pseudo-sanctioned behavior for filesystem drivers, > I'll make sure to do the same adjustments for Ext4Dxe. > I think that would be useful. (Of course I don't "insist" that you share my opinion on whether this new behavior is for bug compatibility with the UEFI spec and shim (which I think it is), or because it is the right/intuitive thing to do (which I don't think it is) -- just feel entirely free to word the Ext4Pkg comments and commit message as you see fit! ... And I probably don't even have to state this, but let me just state it anyway. :) ) Cheers Laszlo -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#109808): https://edk2.groups.io/g/devel/message/109808 Mute This Topic: https://groups.io/mt/102044004/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/leave/12367111/7686176/1913456212/xyzzy [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-