diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2009-06-14 00:09:41 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2009-06-14 00:09:41 +0000 |
commit | 02a365840c38e842976e2e6bfb8a24990aaa23e6 (patch) | |
tree | 40b28e93438bd0c49cdee7b2a2acc9bdab782d28 /sys/arch/hppa | |
parent | 7e97643755bb45a839c99309ba46c6c5b31c0669 (diff) |
Don't mess with the bounds in the lp if *partoffp is non-NULL, since this
indicates that writedisklabel is trying to find the location for writing
the label. If the lp is messed with, an invalid checksum is written.
done with miod and kettenis, lots of moaning and gnashing of teeth, etc
Diffstat (limited to 'sys/arch/hppa')
-rw-r--r-- | sys/arch/hppa/hppa/disksubr.c | 25 | ||||
-rw-r--r-- | sys/arch/hppa/include/disklabel.h | 4 |
2 files changed, 18 insertions, 11 deletions
diff --git a/sys/arch/hppa/hppa/disksubr.c b/sys/arch/hppa/hppa/disksubr.c index df0df856259..962dc450a6a 100644 --- a/sys/arch/hppa/hppa/disksubr.c +++ b/sys/arch/hppa/hppa/disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disksubr.c,v 1.73 2009/06/04 21:13:01 deraadt Exp $ */ +/* $OpenBSD: disksubr.c,v 1.74 2009/06/14 00:09:37 deraadt Exp $ */ /* * Copyright (c) 1999 Michael Shalayeff @@ -102,7 +102,7 @@ readliflabel(struct buf *bp, void (*strat)(struct buf *), struct lifdir *p; struct lifvol *lvp; char *msg = NULL; - int fsoff = 0, i; + int fsoff = 0, openbsdstart = MAXLIFSPACE, i; /* read LIF volume header */ bp->b_blkno = btodb(LIF_VOLSTART); @@ -113,8 +113,10 @@ readliflabel(struct buf *bp, void (*strat)(struct buf *), return "LIF volume header I/O error"; lvp = (struct lifvol *)bp->b_data; - if (lvp->vol_id != LIF_VOL_ID) + if (lvp->vol_id != LIF_VOL_ID) { + openbsdstart = 0; goto finished; + } dbp = geteblk(LIF_DIRSIZE); dbp->b_dev = bp->b_dev; @@ -127,6 +129,7 @@ readliflabel(struct buf *bp, void (*strat)(struct buf *), if (biowait(dbp)) { msg = "LIF directory I/O error"; + openbsdstart = 0; goto done; } @@ -138,11 +141,12 @@ readliflabel(struct buf *bp, void (*strat)(struct buf *), if (p->dir_type == LIF_DIR_FS) { fsoff = lifstodb(p->dir_addr); + openbsdstart = 0; goto finished; } /* Only came here to find the offset... */ - if (partoffp && spoofonly) + if (partoffp) goto finished; if (p->dir_type == LIF_DIR_HPLBL) { @@ -210,12 +214,15 @@ readliflabel(struct buf *bp, void (*strat)(struct buf *), } finished: + /* record the OpenBSD partition's placement for the caller */ if (partoffp) *partoffp = fsoff; + else { + DL_SETBSTART(lp, openbsdstart); + DL_SETBEND(lp, DL_GETDSIZE(lp)); /* XXX */ + } - DL_SETBSTART(lp, fsoff); - DL_SETBEND(lp, DL_GETDSIZE(lp)); /* XXX */ - + /* don't read the on-disk label if we are in spoofed-only mode */ if (spoofonly) goto done; @@ -223,14 +230,12 @@ finished: bp->b_bcount = lp->d_secsize; bp->b_flags = B_BUSY | B_READ | B_RAW; (*strat)(bp); - - /* if successful, locate disk label within block and validate */ if (biowait(bp)) { msg = "disk label I/O error"; goto done; } - return checkdisklabel(bp->b_data + LABELOFFSET, lp, fsoff, + return checkdisklabel(bp->b_data + LABELOFFSET, lp, openbsdstart, DL_GETDSIZE(lp)); /* XXX */ done: diff --git a/sys/arch/hppa/include/disklabel.h b/sys/arch/hppa/include/disklabel.h index 701535bf4c2..6f1b84abbe6 100644 --- a/sys/arch/hppa/include/disklabel.h +++ b/sys/arch/hppa/include/disklabel.h @@ -1,4 +1,4 @@ -/* $OpenBSD: disklabel.h,v 1.21 2007/06/20 18:15:45 deraadt Exp $ */ +/* $OpenBSD: disklabel.h,v 1.22 2009/06/14 00:09:39 deraadt Exp $ */ /* * Copyright (c) 1994 Christopher G. Demetriou @@ -126,4 +126,6 @@ struct hpux_label { #define lifstob(s) ((s) * LIF_SECTSIZE) #define lifstodb(s) ((s) * LIF_SECTSIZE / DEV_BSIZE) +#define MAXLIFSPACE 256 /* 512 byte blocks */ + #endif /* _MACHINE_DISKLABEL_H_ */ |