mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Re: VFS issues (was: Re: 2.5.5-pre1: mounting NTFS partitions -t VFAT)
@ 2002-02-19 12:21 Andries.Brouwer
  0 siblings, 0 replies; 7+ messages in thread
From: Andries.Brouwer @ 2002-02-19 12:21 UTC (permalink / raw)
  To: hirofumi, josh; +Cc: linux-kernel

    From: Jos Hulzink <josh@stack.nl>

    On Mon, 18 Feb 2002, OGAWA Hirofumi wrote:

    > Jos Hulzink <josh@stack.nl> writes:
    >
    > > What lacks is a fingerprint detector, and iirc -long time ago- FAT has a
    > > very easy to detect fingerprint.
    > >
    > > I'll dig into FAT documentation tonight.
    >
    > I read the document repeatedly and did much tests. If you read the
    > document, you may use BS_OEMName or BS_FilSysType, however, these
    > don't have a meaning.

    Hmmm. You seem to be right there. In my OS (IBM PC only) I checked the
    partition table (see below).

    The first question I want answered: Should I just call myself stupid for
    trying to mount NTFS as VFAT, or should we consider this a real issue that
    needs fixing ? (I see the problem as a generic problem. There must be
    other combinations of filesystems and partition types that pass the
    test, but are wrong). IMHO the latter, for every lost partition makes an
    angry linux user.

    Anyway. I have already been thinking further. Maybe I'm talking nonsense,
    but I'll give it a try.

    The type of a partition is written in the partition table, or something
    similar. Maybe we should check that ?

No.

Letting mount guess is a dangerous business. There is no guarantee
it will guess right, and if mount guesses wrong and the filesystem
was mounted rw, then it may well be trashed.

Doing this right is impossible, and doing this better than today
is of questionable usefulness.

[When guessing reaches a 99.99% probability of success then before
you know it distributions will use guessing in their installation
scripts, and destroy the filesystem of only 1 in 10000 customers.
That single customer always turns out to be me.
When the probability is only 99% people are kept honest.]

FAT is one of the filesystems without really good magic.
But also with filesystems that have good magic one may make
mistakes: several filesystem types have magic in different
blocks, at different offsets. Thus, a partition can have the
magic of more than one filesystem type. This is especially likely
if it had a filesystem of one type before it was reformatted as
another type.
[Zeroing out the first few blocks upon a reformat helps a bit,
but will in some cases destroy a boot loader.]

Now about partition types. First look at
http://www.win.tue.nl/~aeb/partitions/partition_types-1.html
and then consider:
Several dozen types all imply FAT.
The Linux type 83 only says Linux but does not carry information
about the filesystem type. The NTFS type 7 is also the OS/2 type
for HPFS and other installable file systems, and is used by a
few other systems as well.
You see that this is a mess, and in reality no useful information
is to be found here, at most some vague heuristics.

Then consider that partitions can come from BSD slices or other
flavours of partition table or disk label, and that they can be
added by ioctl, so that no partition table need to be present
at all.

So, no, looking at partition types is a very bad idea.

Andries

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: VFS issues (was: Re: 2.5.5-pre1: mounting NTFS partitions -t VFAT)
  2002-02-19 10:02 ` VFS issues (was: Re: 2.5.5-pre1: mounting NTFS partitions -t VFAT) Jos Hulzink
  2002-02-19 11:52   ` Richard Russon
  2002-02-19 13:34   ` Alexander Viro
@ 2002-02-19 14:25   ` Denis Vlasenko
  2002-02-19 11:03     ` Jos Hulzink
  2 siblings, 1 reply; 7+ messages in thread
From: Denis Vlasenko @ 2002-02-19 14:25 UTC (permalink / raw)
  To: Jos Hulzink, OGAWA Hirofumi; +Cc: Linux Kernel Development

> > > What lacks is a fingerprint detector, and iirc -long time ago- FAT has
> > > a very easy to detect fingerprint.
> > >
> > > I'll dig into FAT documentation tonight.
> >
> > I read the document repeatedly and did much tests. If you read the
> > document, you may use BS_OEMName or BS_FilSysType, however, these
> > don't have a meaning.
>
> Hmmm. You seem to be right there. In my OS (IBM PC only) I checked the
> partition table (see below).
>
> The first question I want answered: Should I just call myself stupid for
> trying to mount NTFS as VFAT, or should we consider this a real issue that
> needs fixing ? (I see the problem as a generic problem. There must be
> other combinations of filesystems and partition types that pass the
> test, but are wrong). IMHO the latter, for every lost partition makes an
> angry linux user.
>
> Anyway. I have already been thinking further. Maybe I'm talking nonsense,
> but I'll give it a try.
>
> The type of a partition is written in the partition table, or something
> similar. Maybe we should check that ?

Partition type isn't available to fs driver. Think about mounting 
floppy/loopback/etc.

Seems you guys are discussing non-problem here. What really needs to be done 
is to add more sanity checks to FAT superblock detection/validation code:
* signatures like 55AA at end of 1st sector
* sane values for various superblock data (if you see "FAT copies: 146"
  it is more than enough to tell it's not a FAT, right?)

If anyone feels so inclined, please go to fs/fat/inode.c:fat_read_super()
and hack on it. Send your patches to Alexander Viro <viro@math.psu.edu>
and tighten your seatbelt ;-)

> While mounting a partition, the vfs layer tries to determine the partition
> type, and passes that info to the filesystem driver, which checks whether
> that partition type can be mounted by the driver. If no partition type is
> provided by the vfs layer (for the partition type is not available in the
> used partition table, or whatever), the fs driver must try to find out
> itself.
--
vda

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: VFS issues (was: Re: 2.5.5-pre1: mounting NTFS partitions -t VFAT)
  2002-02-19 10:02 ` VFS issues (was: Re: 2.5.5-pre1: mounting NTFS partitions -t VFAT) Jos Hulzink
  2002-02-19 11:52   ` Richard Russon
@ 2002-02-19 13:34   ` Alexander Viro
  2002-02-19 14:25   ` Denis Vlasenko
  2 siblings, 0 replies; 7+ messages in thread
From: Alexander Viro @ 2002-02-19 13:34 UTC (permalink / raw)
  To: Jos Hulzink; +Cc: OGAWA Hirofumi, Linux Kernel Development



On Tue, 19 Feb 2002, Jos Hulzink wrote:

> While mounting a partition, the vfs layer tries to determine the partition

It doesn't and it shouldn't.  mount(8) does, so there's no reason to do that
in kerenl.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: VFS issues (was: Re: 2.5.5-pre1: mounting NTFS partitions -t VFAT)
  2002-02-19 11:52   ` Richard Russon
@ 2002-02-19 12:48     ` Jos Hulzink
  0 siblings, 0 replies; 7+ messages in thread
From: Jos Hulzink @ 2002-02-19 12:48 UTC (permalink / raw)
  To: Richard Russon; +Cc: OGAWA Hirofumi, Linux Kernel Development

On Tuesday 19 February 2002 12:52, Richard Russon wrote:

> Whatever you throw at mount, you want it to fail_safe_.  i.e. in the
> worst case, do nothing.

Agreed.

> Without any help, mount (userspace) tries to determine the partition
> type.  It understands the magics of a LOT of filesystems.
>
> It looks for the NTFS magic before the DOS magic (or any of its variants).

Well, the story: I reinstalled Win2k and updated from FAT32 to NTFS, the day 
before I tested 2.5.5pre-1. I forgot to update /etc/fstab. So mount was 
called with the -t vfat option.

> Which is passed to the VFS, and the to the driver which performs some
> more rigid tests (hopefully :-)

Working on those tests, though it is hard to tell what limits are valid. I 
never saw more than 2 FATs, but can I assume there never will be more ? FAT 
has no real fingerprint, unfortunately. There are some bytes that can be 
checked, but they depend very much on the FAT version. FAT v 4.0 and higher 
have the fingerprint 'FAT' somewhere in the bootsector, but this doesn't hold 
anymore for some Win98/ME formatted partitions.

A test I'm thinking about is trying to match the FATs if there is more than 
one. You want to bail out if the FATs aren't the same anyway. The chance that 
the FAT-sectors are the same on non-FAT partitions is very small. Though this 
test can be rather slow, maybe we should only test the first sector(s).

Jos


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: VFS issues (was: Re: 2.5.5-pre1: mounting NTFS partitions -t VFAT)
  2002-02-19 10:02 ` VFS issues (was: Re: 2.5.5-pre1: mounting NTFS partitions -t VFAT) Jos Hulzink
@ 2002-02-19 11:52   ` Richard Russon
  2002-02-19 12:48     ` Jos Hulzink
  2002-02-19 13:34   ` Alexander Viro
  2002-02-19 14:25   ` Denis Vlasenko
  2 siblings, 1 reply; 7+ messages in thread
From: Richard Russon @ 2002-02-19 11:52 UTC (permalink / raw)
  To: Jos Hulzink; +Cc: OGAWA Hirofumi, Linux Kernel Development

Hi Jos,

> The first question I want answered: Should I just call myself stupid for
> trying to mount NTFS as VFAT, or should we consider this a real issue that
> needs fixing ?

Stupid?  No.
Fixing?  Yes.

Whatever you throw at mount, you want it to fail_safe_.  i.e. in the
worst case, do nothing.

> While mounting a partition, the vfs layer tries to determine the partition
> type,

Without any help, mount (userspace) tries to determine the partition
type.  It understands the magics of a LOT of filesystems.

It looks for the NTFS magic before the DOS magic (or any of its variants).

> and passes that info to the filesystem driver

Which is passed to the VFS, and the to the driver which performs some
more rigid tests (hopefully :-)

Cheers,
  FlatCap (Rich)
  ntfs@flatcap.org



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: VFS issues (was: Re: 2.5.5-pre1: mounting NTFS partitions -t VFAT)
  2002-02-19 14:25   ` Denis Vlasenko
@ 2002-02-19 11:03     ` Jos Hulzink
  0 siblings, 0 replies; 7+ messages in thread
From: Jos Hulzink @ 2002-02-19 11:03 UTC (permalink / raw)
  To: Denis Vlasenko; +Cc: OGAWA Hirofumi, Linux Kernel Development

On Tue, 19 Feb 2002, Denis Vlasenko wrote:

> > The type of a partition is written in the partition table, or something
> > similar. Maybe we should check that ?
>
> Partition type isn't available to fs driver. Think about mounting
> floppy/loopback/etc.

True. I never use floppys anymore :)

> Seems you guys are discussing non-problem here. What really needs to be done
> is to add more sanity checks to FAT superblock detection/validation code:
> * signatures like 55AA at end of 1st sector
> * sane values for various superblock data (if you see "FAT copies: 146"
>   it is more than enough to tell it's not a FAT, right?)
>
> If anyone feels so inclined, please go to fs/fat/inode.c:fat_read_super()
> and hack on it. Send your patches to Alexander Viro <viro@math.psu.edu>
> and tighten your seatbelt ;-)

Will hack tonight and see if my seatbelt is strong enough :) It has never
been used before, so maybe...

Jos


^ permalink raw reply	[flat|nested] 7+ messages in thread

* VFS issues (was: Re: 2.5.5-pre1: mounting NTFS partitions -t VFAT)
  2002-02-18 14:56 2.5.5-pre1: mounting NTFS partitions -t VFAT OGAWA Hirofumi
@ 2002-02-19 10:02 ` Jos Hulzink
  2002-02-19 11:52   ` Richard Russon
                     ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Jos Hulzink @ 2002-02-19 10:02 UTC (permalink / raw)
  To: OGAWA Hirofumi; +Cc: Linux Kernel Development

On Mon, 18 Feb 2002, OGAWA Hirofumi wrote:

> Jos Hulzink <josh@stack.nl> writes:
>
> > What lacks is a fingerprint detector, and iirc -long time ago- FAT has a
> > very easy to detect fingerprint.
> >
> > I'll dig into FAT documentation tonight.
>
> I read the document repeatedly and did much tests. If you read the
> document, you may use BS_OEMName or BS_FilSysType, however, these
> don't have a meaning.

Hmmm. You seem to be right there. In my OS (IBM PC only) I checked the
partition table (see below).

The first question I want answered: Should I just call myself stupid for
trying to mount NTFS as VFAT, or should we consider this a real issue that
needs fixing ? (I see the problem as a generic problem. There must be
other combinations of filesystems and partition types that pass the
test, but are wrong). IMHO the latter, for every lost partition makes an
angry linux user.

Anyway. I have already been thinking further. Maybe I'm talking nonsense,
but I'll give it a try.

The type of a partition is written in the partition table, or something
similar. Maybe we should check that ?

While mounting a partition, the vfs layer tries to determine the partition
type, and passes that info to the filesystem driver, which checks whether
that partition type can be mounted by the driver. If no partition type is
provided by the vfs layer (for the partition type is not available in the
used partition table, or whatever), the fs driver must try to find out
itself.

If you don't want the calls to change, another option is to move the check
to the vfs. Problem there however is that the vfs needs a "filesystem <->
partition type" table. On the other hand, this way we can add extra
security without breaking anything.

Jos


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2002-02-19 13:34 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-02-19 12:21 VFS issues (was: Re: 2.5.5-pre1: mounting NTFS partitions -t VFAT) Andries.Brouwer
  -- strict thread matches above, loose matches on Subject: below --
2002-02-18 14:56 2.5.5-pre1: mounting NTFS partitions -t VFAT OGAWA Hirofumi
2002-02-19 10:02 ` VFS issues (was: Re: 2.5.5-pre1: mounting NTFS partitions -t VFAT) Jos Hulzink
2002-02-19 11:52   ` Richard Russon
2002-02-19 12:48     ` Jos Hulzink
2002-02-19 13:34   ` Alexander Viro
2002-02-19 14:25   ` Denis Vlasenko
2002-02-19 11:03     ` Jos Hulzink

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®