diff options
author | Joel Sing <jsing@cvs.openbsd.org> | 2012-01-30 13:13:04 +0000 |
---|---|---|
committer | Joel Sing <jsing@cvs.openbsd.org> | 2012-01-30 13:13:04 +0000 |
commit | 2f2fe961ea62c6873d93f63427c200d60f6c3864 (patch) | |
tree | d5e12a877eaf25f93e6449cf46c218a3241504dd /sys | |
parent | 02bd7064dcfb3c6b4e722f661625ea479d02cea2 (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')
-rw-r--r-- | sys/dev/softraid.c | 26 | ||||
-rw-r--r-- | sys/dev/softraid_crypto.c | 12 |
2 files changed, 36 insertions, 2 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); diff --git a/sys/dev/softraid_crypto.c b/sys/dev/softraid_crypto.c index fe8c9930ba9..7e34e519e3f 100644 --- a/sys/dev/softraid_crypto.c +++ b/sys/dev/softraid_crypto.c @@ -1,4 +1,4 @@ -/* $OpenBSD: softraid_crypto.c,v 1.79 2012/01/22 11:13:32 jsing Exp $ */ +/* $OpenBSD: softraid_crypto.c,v 1.80 2012/01/30 13:13:03 jsing Exp $ */ /* * Copyright (c) 2007 Marco Peereboom <marco@peereboom.us> * Copyright (c) 2008 Hans-Joerg Hoexer <hshoexer@openbsd.org> @@ -694,6 +694,11 @@ sr_crypto_create_key_disk(struct sr_discipline *sd, 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)\n", devname, label.d_partitions[part].p_fstype); @@ -862,6 +867,11 @@ sr_crypto_read_key_disk(struct sr_discipline *sd, dev_t dev) vput(vn); 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)\n", devname, label.d_partitions[part].p_fstype); |