diff options
author | 2012-01-30 13:13:03 +0000 | |
---|---|---|
committer | 2012-01-30 13:13:03 +0000 | |
commit | 79de92d30cfd1e146ae02200bfa50a8cda702067 (patch) | |
tree | 55815e863ac77583a6998422fc62b0b4bc0c8cef /sys/dev/softraid.c | |
parent | fix format string (diff) | |
download | wireguard-openbsd-79de92d30cfd1e146ae02200bfa50a8cda702067.tar.xz wireguard-openbsd-79de92d30cfd1e146ae02200bfa50a8cda702067.zip |
Prevent softraid from being used with devices that do not have a sector
size of 512 bytes - any other size is not currently supported.
ok krw@
Diffstat (limited to 'sys/dev/softraid.c')
-rw-r--r-- | sys/dev/softraid.c | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/sys/dev/softraid.c b/sys/dev/softraid.c index 2482403d405..23cfad272b1 100644 --- a/sys/dev/softraid.c +++ b/sys/dev/softraid.c @@ -1,4 +1,4 @@ -/* $OpenBSD: softraid.c,v 1.273 2012/01/28 14:40:04 jsing Exp $ */ +/* $OpenBSD: softraid.c,v 1.274 2012/01/30 13:13:03 jsing Exp $ */ /* * Copyright (c) 2007, 2008, 2009 Marco Peereboom <marco@peereboom.us> * Copyright (c) 2008 Chris Kuethe <ckuethe@openbsd.org> @@ -1045,6 +1045,13 @@ sr_meta_native_bootprobe(struct sr_softc *sc, dev_t devno, } vput(vn); + /* Make sure this is a 512-byte/sector device. */ + if (label.d_secsize != DEV_BSIZE) { + DNPRINTF(SR_D_META, "%s: %s has unsupported sector size (%d)", + DEVNAME(sc), devname, label.d_secsize); + goto done; + } + md = malloc(SR_META_SIZE * 512, M_DEVBUF, M_ZERO | M_NOWAIT); if (md == NULL) { sr_error(sc, "not enough memory for metadata buffer"); @@ -1545,6 +1552,13 @@ sr_meta_native_probe(struct sr_softc *sc, struct sr_chunk *ch_entry) } bcopy(label.d_uid, ch_entry->src_duid, sizeof(ch_entry->src_duid)); + /* Make sure this is a 512-byte/sector device. */ + if (label.d_secsize != DEV_BSIZE) { + sr_error(sc, "%s has unsupported sector size (%d)", + devname, label.d_secsize); + goto unwind; + } + /* make sure the partition is of the right type */ if (label.d_partitions[part].p_fstype != FS_RAID) { DNPRINTF(SR_D_META, @@ -2634,6 +2648,11 @@ sr_hotspare(struct sr_softc *sc, dev_t dev) vput(vn); goto fail; } + if (label.d_secsize != DEV_BSIZE) { + sr_error(sc, "%s has unsupported sector size (%d)", + devname, label.d_secsize); + goto fail; + } if (label.d_partitions[part].p_fstype != FS_RAID) { sr_error(sc, "%s partition not of type RAID (%d)", devname, label.d_partitions[part].p_fstype); @@ -2930,6 +2949,11 @@ sr_rebuild_init(struct sr_discipline *sd, dev_t dev, int hotspare) DEVNAME(sc)); goto done; } + if (label.d_secsize != DEV_BSIZE) { + sr_error(sc, "%s has unsupported sector size (%d)", + devname, label.d_secsize); + goto done; + } if (label.d_partitions[part].p_fstype != FS_RAID) { sr_error(sc, "%s partition not of type RAID (%d)", devname, label.d_partitions[part].p_fstype); |