Fix long-standing bug in boot1 code - can read junk from fake partition table
commit76adb3c3574e7451137604b62e41fc0ed48b021b
authorMatthew Dillon <dillon@apollo.backplane.com>
Wed, 11 Feb 2009 09:53:52 +0000 (11 01:53 -0800)
committerMatthew Dillon <dillon@apollo.backplane.com>
Wed, 11 Feb 2009 09:53:52 +0000 (11 01:53 -0800)
tree48850683a7c15d0835e3ca66ef376c0106cdd2e6
parentd07a93d31afb3322b37358ee95f15898098ec4eb
Fix long-standing bug in boot1 code - can read junk from fake partition table

boot1 reads the MBR to locate the BSD partition type (0xA5).  However, to
reduce the size of the boot1 code the 32 bit LBA for the MBR was being
loaded via the fake partition table at label 'part4', which was assumed to
contain a LBA of 0.  Unfortunately this portion of the boot1 code is not
usually written by the disklabel program and may contain garbage.

For the last few years we have worked around the issue by zeroing out
the label area before installing a new label.  We still have to do this
to avoid disklabel32/disklabel64 confusion, but with this fix forgetting
to zero the area should not cause a properly installed disklabel to fail
to boot properly.

To fix the problem, add the necessary instructions to generate a 32 bit
LBA of 0 directly for reading the MBR.  They barely fit.
sys/boot/pc32/boot2/boot1.S