Re: [PATCH] fs/partitions/msdos.c Guard against negative sizes

From: Andries.Brouwer@cwi.nl
Date: Mon Jan 27 2003 - 11:48:12 EST


    u32 start = START_SECT(p)*sector_size;
    u32 size = NR_SECTS(p)*sector_size;
    And this looks as if it was calculated in bytes

But it is not. It converts hardware sector size units
to 512-byte units. For example, some MO disks use
2048-byte sectors, and also have the partition tables
in that unit.

    What about overflow?

More detailed checking of the table is certainly possible.

[But then, weird tables only occur when people fiddle with
the partition table themselves. Or when an accident happened.
I am not sure inhibiting access to partitions that look strange
is useful. It might make rescue operations difficult or impossible.]

    And btw, when can a partition that extends beyond the end
    be "allowed or even necessary"?

One reason is that "the end" is not well-defined. E.g.,
disk manufacturers invent jumpers that make the disk appear
smaller than it is in reality in order to avoid BIOS bugs.
See http://www.win.tue.nl/~aeb/linux/Large-Disk-11.html#ss11.3

In many cases the kernel option CONFIG_IDEDISK_STROKE will tell
the kernel to automatically fix up fake lengths. If that doesn't
work, a user mode utility may be needed to give the disk full size.
Since that utility is run after the kernel does the partition detection,
it is often easiest to let the last logical partition start just before
the fake end.

Andries
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Fri Jan 31 2003 - 22:00:17 EST