Re: Cache coherency bug: stale reads on /dev/sda1

From: Joshua Hudson
Date: Sun Aug 27 2023 - 10:40:37 EST


On Sat, Aug 26, 2023 at 9:17 PM Al Viro <viro@xxxxxxxxxxxxxxxxxx> wrote:
>
> On Sat, Aug 26, 2023 at 07:38:57PM -0700, Joshua Hudson wrote:
> > "Whole disk and all partitions have page caches of their own."
> >
> > That's so bad.
> >
> > I can think of numerous cases where this will cause problems; including
> > some I encountered last year and did not understand at the time. Manipulating
> > EFI partitions through the whole disk device makes sense because FAT filesystems
> > *know their offset on the disk*, and some of the existing tools really
> > don't like being
> > given a partition device.
>
> Explain, please. How does FAT filesystem know its offset on disk?
> Since when? It had always been possible to copy a FAT image into
> a partition verbatim and it works no matter where on disk that
> partition happens to be...
>
> Has that changed at some point? Do you have any references? Ideally
> with some kind of rationale for that weirdness...
>
> Or am I misparsing what you wrote?

(Good news: finally found the invisible button to edit reply quote)

Offset 0x1C into the FAT filesystem is defined as "Count of hidden
sectors preceding
the partition that contains this FAT volume." It's been there since
DOS 3.0. The Linux
Kernel does not care what's in this field, but I have tools that have
a hard time of it
not being there. One example of a tool is BootDuet.

The rationale is to reduce the number of tools that have to walk the
partition table, the
most obvious one being the boot sector itself which doesn't have room.

With random BIOS bugs in UEFI still; I would *not* want to find out
what happens with
a wrong value here on an EFI partition.

Source: https://en.wikipedia.org/wiki/Design_of_the_FAT_file_system

(The field changed size; you actually want to read the entry under DOS 3.31)