core/diskboot.inc: fix handover area's sanity checks
authorMichal Soltys <soltys@ziu.info>
Tue, 22 Feb 2011 23:18:00 +0000 (00:18 +0100)
committerH. Peter Anvin <hpa@linux.intel.com>
Wed, 2 Mar 2011 23:46:21 +0000 (15:46 -0800)
As the code operates with paragraph granularity, make sure that
false positives are not possible, though some false negatives
might happen with insanely placed handover area.

Bump low address check to 50h:0, to also avoid bios data area and
remove si == 0 check.

Signed-off-by: Michal Soltys <soltys@ziu.info>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
core/diskboot.inc

index 35c6469..68672e4 100644 (file)
@@ -180,16 +180,18 @@ floppy:
 ; trust that rather than what the superblock contains.
 ;
 ; Note: di points to beyond the end of PartInfo
+; Note: false negatives might slip through the handover area's sanity checks,
+;       if the region is very close (less than a paragraph) to
+;       PartInfo ; no false positives are possible though
 ;
 harddisk:
                mov dx,[di-76-10]       ; Original DS
                mov si,[di-76-12]       ; Original SI
                shr si,4
-               jz .no_partition        ; SI == 0 -> assume no partition
                add dx,si
-               cmp dx,1024 >> 4        ; DS:SI < 1K (inside the IVT)?
-               jb .no_partition
-               cmp dx,PartInfo >> 4    ; DS:SI in overwritten memory?
+               cmp dx,4fh              ; DS:SI < 50h:0 (BDA or IVT) ?
+               jbe .no_partition
+               cmp dx,(PartInfo-75)>>4 ; DS:SI in overwritten memory?
                jae .no_partition
                test byte [di-76],7Fh   ; Sanity check: "active flag" should
                jnz .no_partition       ; be 00 or 80