Konamiman/Nextor

Kernel does not check for validity of the boot sector

Eugeny1 opened this issue · 1 comments

I have made a mistake in test DEV_RW routine, and, when boot sector is being read first time, instead of moving data from ROM location to required RAM location perform reverse action, moving data from RAM to ROM (which has not effect and ROM contents are not changed). However in this case invalid data remains in the RAM sector buffer, and driver returns that it has read 1 sector successfully.
Next action of the kernel is to read sector 0xffffffff. Here's the screenshot of that is being provided as a boot sector on the first read:

wrong-boot-sector

This means that if boot sector is obviously corrupt, there may be an invalid request to the storage device (e.g. out of LBA). If connected device is floppy drive (or FDC) without checking track number there will be a risk damaging the stepper motor and its mechanism.

Possible fix could be checking for AA55 signature at the end of the boot sector if Nextor is going to treat boot sector as an MBR (Nextor must write it when initializing the volume). Alternatively, there must be some keywords in the MBR generated by Nextor wilch must be used to identify if sector read can be treated as valid MBR or not.

Nextor initially checked that AA55 signature but at some point I removed the check because it was causing issues (I don't remember the details).

I'm sorry but I won't be fixing this. If a call to your driver with incorrect parameters can damage the hardware, then it's the driver's responsibility to validate the parameters prior to performing any action. Keep in mind that your driver could be called outside of Nextor anyway.