On Mon, 22 Jul 2013, Kenneth R Westerback wrote:
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.
Well, it trusts the disk label in what it says the sector size is, but on
the other hand it ignores what the disklabel says about the total number
of sectors (and the size of the 'c' partition). Strange.
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.
Don't hesitate to ask if anything is not clear in 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.
One would hope there is a chance to edit (fix) the sector size value with
disklabel(8). But obviously, once it has been changed, the disk label
cannot be written to disk again.
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".
In some cases disks can be connected to computers in more than on way and
in each way its host will be presented with a different sector size. I
made an attemt to simulate it. I just didn't expect it could silently
influence hardware drivers.
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.
I don't think so. If I see the number of sector the drive reported both
when inside an USB enclosure and connected directly to SATA controller, I
believe that it was a standard 512-byte sector SATA hard drive and only
the kernel got fooled by the disk label it found on it.
In fact, that was the real life situation I wanted to model in my
experiments - what will happen if the disk is taken out from a USB
enclosure which pretends it to be a 4k-sector drive and is connected to a
SATA controller as a standard 512-byte/sector drive.
Regards,
David