From: Lukas Czerner <lczerner@redhat.com>
To: Daniel Ng <danielng@google.com>
Cc: linux-ext4@vger.kernel.org, Sarthak Kukreti <sarthakkukreti@google.com>
Subject: Re: [BUG] fsck unable to resolve filenames that include '='
Date: Wed, 3 Aug 2022 16:31:13 +0200 [thread overview]
Message-ID: <20220803143113.frmayykhlhvcqkxg@fedora> (raw)
In-Reply-To: <CANFuW3eGgyeWba-2GjDtdhYvX2fV7-dcrHn-4O8QAeHDERAbqw@mail.gmail.com>
On Tue, Aug 02, 2022 at 06:21:56PM +1000, Daniel Ng wrote:
> Hi,
>
> I've run into an issue when trying to use fsck with an ext4 image when
> it has '=' in its name.
>
> Repro steps:
> 1. fallocate -l 1G test=.img
> 2. mkfs.ext4 test=.img
> 3. fsck test=.img
>
> Response:
> 'fsck.ext4: Unable to resolve '<path>/test=.img'
>
> Expected:
> fsck to do it's thing.
>
> Observations:
> Originally I wasn't sure what the source was, I thought that maybe
> mkfs wasn't creating the image appropriately.
> However, I've tried:
> - renaming the image
> - creating a hard-link to the image
>
> Running fsck on either the renamed image, or the hard-link, works as expected.
>
> Kernel version: Linux version 4.19.251-13516-ga0bcf8d80077
> Environment: Running on a Chromebook
>
> Kind regards,
> Daniel
Hi Daniel,
yeah, that's a good catch. The problem is that various e2fsprogs tools
(at least tune2fs and e2fsck) are using blkid_get_devname() to get the
device name without ever checking if we already got the actual existing
device name.
The reason to call blkid_get_devname() at all is to get device in the
form of NAME=value (like for example UUID=uuid, or LABEL=volume-label).
However if we blindly pass in the device (or in this case regular file)
name with an equal sign in it, the blkid_get_devname just returns whatever
it can find by that tag. Which is likely nothing.
Unless of course, you're trying to use e2fsck, or tune2fs on a file with
an actual filename LABEL=volume-label and you have actual file system
with 'volume-label' LABEL ;) That's a problematic behavior and depending
on how we go about fixing it it could be potentialy exploitable...
Maybe something like this:
1. look for the actual block device first
2. if none is found call blkid_get_devname()
3. if that didn't return anything maybe see if have a regular
file and work with that
4. if we still get nothing, then we're "Unable to resolve..."
Thoughts?
-Lukas
next prev parent reply other threads:[~2022-08-03 14:31 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-02 8:21 [BUG] fsck unable to resolve filenames that include '=' Daniel Ng
2022-08-03 14:31 ` Lukas Czerner [this message]
2022-08-05 5:32 ` Daniel Ng
2022-08-05 7:38 ` Lukas Czerner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220803143113.frmayykhlhvcqkxg@fedora \
--to=lczerner@redhat.com \
--cc=danielng@google.com \
--cc=linux-ext4@vger.kernel.org \
--cc=sarthakkukreti@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox