Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
core/diskboot.inc: fix handover area's sanity checks
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>
  • Loading branch information
msoltyspl authored and H. Peter Anvin committed Mar 2, 2011
1 parent 74ee14e commit 7a9ea9d
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions core/diskboot.inc
Expand Up @@ -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
Expand Down

0 comments on commit 7a9ea9d

Please sign in to comment.