Util-Linux package development
 help / color / mirror / Atom feed
From: Demi Marie Obenour <demiobenour@gmail.com>
To: Karel Zak <kzak@redhat.com>
Cc: util-linux@vger.kernel.org
Subject: Re: Ensuring that mount(8) will always interpret a filesystem correctly
Date: Tue, 10 Dec 2024 00:11:49 -0500	[thread overview]
Message-ID: <114fa16d-5908-4300-96a0-23203c7470af@gmail.com> (raw)
In-Reply-To: <zxqdvuyhtmas5apcnop7kleh2b24sboscyaosgkyqqfz4nlsdf@rmgdzivamwdw>

On 12/9/24 5:26 AM, Karel Zak wrote:
> 
>  Hi Demi,
> 
> On Sat, Dec 07, 2024 at 08:45:32PM GMT, Demi Marie Obenour wrote:
>> Is there a guarantee that if all data before the filesystem superblock is
>> zero, and that the filesystem never writes to this region, libblkid (and
>> thus, presumably, mount(8)) will always mount the filesystem with the
>> correct filesystem type, even if e.g. someone writes a file containing
>> a superblock of a different filesystem and the filesystem happens to put
>> it where that superblock is valid?
> 
> the libblkid library offers multiple modes, with "safe mode" being the
> default for detecting filesystems. In this mode, the library checks
> for any additional valid superblocks on the device. There are
> exceptions for certain filesystems on CD/DVD media (such as udf and
> iso), but for regular filesystems, sharing the same device is not
> allowed.
> 
> There is also an option to specify that a superblock is only valid if
> no other area is using it (using blkid_probe_set_wiper() and
> blkid_probe_use_wiper()). However, this is only used for LVM and
> bcache.
> 
> The library does not require that there are zeros before the
> superblock, as not all mkfs-like programs zero out all areas.
> 
> In recent years, there have been no reports of collisions. In the
> entire history of the library, the only collisions I can recall are
> with swap areas and luks, and occasionally with poorly detected FAT
> filesystems (due to the messy design of FAT).

Was https://github.com/util-linux/util-linux/issues/1305 a
collision between ZFS and ext4?

>> The motivation for this message is that systemd-gpt-generator generates
>> mountpoints based on Discoverable Partition Specification GUIDs.  These
>> indicate the mountpoint of the partition but not the filesystem type.
> 
> Filesystem auto-detection is a common feature. The situation is
> similar to having an "auto" fstype in fstab. The systemd-gpt-generator
> simply identifies the partition as "/usr" (or any other mountpoint)
> and the rest is usual scenario.> 
>> If a correctly-produced filesystem image will always continue to be
>> recognized as the correct type, this is fine.  Otherwise, an unlucky
>> combination of writes to the filesystem and filesystem allocation decisions
>> could cause the filesystem to start being mounted as the wrong type, which
>> would be very bad.  According to https://github.com/util-linux/util-linux/issues/1305,
>> libblkid can indeed probe for subsequent superblocks after the first one it
>> finds.
> 
> I believe the situation would be the same even without the
> Discoverable Partition Specification. The kernel always divides the
> whole disk into partitions, and libblkid/mount utilizes these
> partitions. Therefore, the filesystems are automatically separated by
> the partition table.

/etc/fstab provides an explicit filesystem type.  The Discoverable
Partition Specification doesn't.
-- 
Sincerely,
Demi Marie Obenour (she/her/hers)

  reply	other threads:[~2024-12-10  5:11 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-08  1:45 Ensuring that mount(8) will always interpret a filesystem correctly Demi Marie Obenour
2024-12-09 10:26 ` Karel Zak
2024-12-10  5:11   ` Demi Marie Obenour [this message]
2024-12-10 11:16     ` Karel Zak
2024-12-10 23:28       ` Demi Marie Obenour
2024-12-11 13:38         ` Theodore Ts'o
2024-12-14 22:08           ` Demi Marie Obenour
2024-12-15  3:20             ` Theodore Ts'o

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=114fa16d-5908-4300-96a0-23203c7470af@gmail.com \
    --to=demiobenour@gmail.com \
    --cc=kzak@redhat.com \
    --cc=util-linux@vger.kernel.org \
    /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