On Mon, Jul 22, 2013 at 01:56:16PM +0200, David Vasek wrote:
> Hello.
> 
> From the experiment below it seems that the kernel modifies its
> knowledge of a sector size of a disk hardware according to what can
> be found in the disk label sector. It does so even if the value
> found does not make sense hardware-wise and in spite of a sector
> size the hardware device driver works with. It can make the device
> completly inaccessible. The disklabel(8) command doesn't allow to
> set/change the sector size value even if it were accessible.

The kernel obtains the sector size from the hardware device whenever
the disklabel is created. It does trust the disklabel it reads from
the disk. People can abuse that trust. The interesting gyrations to
automatically convert all the fields in the disklabel from one
sector size to another are, well, *interesting*. And have never been
considered useful since there is no general mechanisms for the kernel
to read incorrectly blocked data from the disk.

> 
> Such situation also occurs if the disk label is read from a sector
> where a disk label is not expected - this was already a subject of
> my previous report.

Still working on puzzling out that report.

> 
> It effectively means that if there is wrong data on the drive, you
> don't have a chance to analyze the situation or fix it. You can't
> even view the fdisk (MBR) partition table.

Correct.

> 
> In the following example I copied an image of a 512-byte sector USB
> drive (sd5) to a clean 4k-sector USB drive (sd4). The source drive
> contained an OpenBSD fdisk partition with a disklabel partition and
> a functional filesystem. After that, kernel can't read any data from
> that 4k-sector drive, causing errors at umass(4) driver level.
> Please note the output of "disklabel sd4" before and after copying
> the image and the difference in sector size there.

Bits directly plopped from a device with one sector size to another
device with a different sector size all pass through a gate having
a large sign over it containing the words: "Lasciate ogne speranza,
voi ch'intrate".

> 
> My guess is that this issue could be related to this one about a year ago:
> http://marc.info/?l=openbsd-misc&m=134027998905971&w=2

Nope. That problem had to do with wd(4) not supporting 4K sectors.
Only sd(4) will even make an attempt to handle sector sizes other
than 512 bytes.

.... Ken

Reply via email to