summaryrefslogtreecommitdiff
path: root/sys/dev/softraid.c
diff options
context:
space:
mode:
authorJoel Sing <jsing@cvs.openbsd.org>2012-01-30 13:13:04 +0000
committerJoel Sing <jsing@cvs.openbsd.org>2012-01-30 13:13:04 +0000
commit2f2fe961ea62c6873d93f63427c200d60f6c3864 (patch)
treed5e12a877eaf25f93e6449cf46c218a3241504dd /sys/dev/softraid.c
parent02bd7064dcfb3c6b4e722f661625ea479d02cea2 (diff)
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.c26
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);