Set MBR bootloader code to busy loop on x86
Booting from one of our images on a PC could be seriously harmful. This
patch adds a few standard instructions to the MBR bootloader code to
hang a booting PC if someone tries to boot from our image.
Change-Id: I85af964595c7c63cbb5e456db87d30cfdb6ddadc
Test: Updated unit tests pass
Bug: None
diff --git a/bpttool b/bpttool
index 1f1bfef..861fe6b 100755
--- a/bpttool
+++ b/bpttool
@@ -552,7 +552,7 @@
lba_end = settings.disk_size/DISK_SECTOR_SIZE - 1
start_chs = self._lba_to_chs(lba_start)
end_chs = self._lba_to_chs(lba_end)
- pmbr = struct.pack('<446x' # Padding to get to offset 446 (0x1be).
+ pmbr = struct.pack('<446s' # Bootloader code
'B' # Status.
'BBB' # CHS start.
'B' # Partition type.
@@ -561,6 +561,7 @@
'I' # Number of sectors in partition.
'48x' # Padding to get to offset 510 (0x1fe).
'BB', # Boot signature.
+ '\xfa\xeb\xfe', # cli ; jmp $ (x86)
0x00,
start_chs[0], start_chs[1], start_chs[2],
0xee, # MBR Partition Type: GPT protective MBR.
diff --git a/test/expected_json_stacked_change_flags.bin b/test/expected_json_stacked_change_flags.bin
index 602e5c5..2fb6ee3 100644
--- a/test/expected_json_stacked_change_flags.bin
+++ b/test/expected_json_stacked_change_flags.bin
Binary files differ