From: krw Date: Fri, 2 Sep 2022 12:24:26 +0000 (+0000) Subject: Relax GTP header validity check by allowing 1 sector size usable X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=9dfb435af5176bab3d98bfc6210d550575e6bd66;p=openbsd Relax GTP header validity check by allowing 1 sector size usable LBA area (gh_lba_start == gh_lba_end) and allowing either or both of gh_lba_start and gh_lba_end to exceed the size of the disk the GPT currently inhabits. Reduces false negatives and inappropriate fall through to MBR spoofing and allows repair of otherwise valid GPT. --- diff --git a/sys/kern/subr_disk.c b/sys/kern/subr_disk.c index 94a67927f3e..cac0b450026 100644 --- a/sys/kern/subr_disk.c +++ b/sys/kern/subr_disk.c @@ -1,4 +1,4 @@ -/* $OpenBSD: subr_disk.c,v 1.255 2022/09/01 13:45:27 krw Exp $ */ +/* $OpenBSD: subr_disk.c,v 1.256 2022/09/02 12:24:26 krw Exp $ */ /* $NetBSD: subr_disk.c,v 1.17 1996/03/16 23:17:08 christos Exp $ */ /* @@ -484,8 +484,7 @@ gpt_get_hdr(struct buf *bp, void (*strat)(struct buf *), struct disklabel *lp, if (letoh64(ngh.gh_sig) == GPTSIGNATURE && letoh32(ngh.gh_rev) == GPTREVISION && - size == GPTMINHDRSIZE && lbastart < lbaend && - lbastart < DL_GETDSIZE(lp) && lbaend < DL_GETDSIZE(lp) && + size == GPTMINHDRSIZE && lbastart <= lbaend && partsize == GPTMINPARTSIZE && lp->d_secsize % partsize == 0 && csum == ngh.gh_csum) *gh = ngh;