summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/softraid.c13
-rw-r--r--sys/dev/softraid_crypto.c12
-rw-r--r--sys/dev/softraidvar.h7
3 files changed, 24 insertions, 8 deletions
diff --git a/sys/dev/softraid.c b/sys/dev/softraid.c
index dfa24f799f5..5f6105396c0 100644
--- a/sys/dev/softraid.c
+++ b/sys/dev/softraid.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: softraid.c,v 1.277 2012/10/08 14:22:41 jsing Exp $ */
+/* $OpenBSD: softraid.c,v 1.278 2012/10/09 11:57:33 jsing Exp $ */
/*
* Copyright (c) 2007, 2008, 2009 Marco Peereboom <marco@peereboom.us>
* Copyright (c) 2008 Chris Kuethe <ckuethe@openbsd.org>
@@ -75,6 +75,7 @@ uint32_t sr_debug = 0
struct sr_softc *softraid0;
struct sr_uuid sr_bootuuid;
+u_int8_t sr_bootkey[SR_CRYPTO_MAXKEYBYTES];
int sr_match(struct device *, void *, void *);
void sr_attach(struct device *, struct device *, void *);
@@ -1147,6 +1148,7 @@ sr_boot_assembly(struct sr_softc *sc)
struct sr_chunk *hotspare, *chunk, *last;
u_int64_t *ondisk = NULL;
dev_t *devs = NULL;
+ void *data;
char devname[32];
int rv = 0, i;
@@ -1358,6 +1360,7 @@ sr_boot_assembly(struct sr_softc *sc)
SLIST_FOREACH(bv, &bvh, sbv_link) {
bzero(&bcr, sizeof(bcr));
+ data = NULL;
/* Check if this is a hotspare "volume". */
if (bv->sbv_level == SR_HOTSPARE_LEVEL &&
@@ -1435,9 +1438,13 @@ sr_boot_assembly(struct sr_softc *sc)
bcr.bc_flags = BIOC_SCDEVT |
(bv->sbv_flags & BIOC_SCNOAUTOASSEMBLE);
+ if (bv->sbv_level == 'C' &&
+ bcmp(&sr_bootuuid, &bv->sbv_uuid, sizeof(sr_bootuuid)) == 0)
+ data = sr_bootkey;
+
rw_enter_write(&sc->sc_lock);
bio_status_init(&sc->sc_status, &sc->sc_dev);
- sr_ioctl_createraid(sc, &bcr, 0, NULL);
+ sr_ioctl_createraid(sc, &bcr, 0, data);
rw_exit_write(&sc->sc_lock);
rv++;
@@ -1812,6 +1819,8 @@ sr_attach(struct device *parent, struct device *self, void *aux)
sc->sc_shutdownhook = shutdownhook_establish(sr_shutdownhook, sc);
sr_boot_assembly(sc);
+
+ explicit_bzero(sr_bootkey, sizeof(sr_bootkey));
}
int
diff --git a/sys/dev/softraid_crypto.c b/sys/dev/softraid_crypto.c
index 5423acb2ba4..13881a8f04c 100644
--- a/sys/dev/softraid_crypto.c
+++ b/sys/dev/softraid_crypto.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: softraid_crypto.c,v 1.81 2012/10/08 14:22:41 jsing Exp $ */
+/* $OpenBSD: softraid_crypto.c,v 1.82 2012/10/09 11:57:33 jsing Exp $ */
/*
* Copyright (c) 2007 Marco Peereboom <marco@peereboom.us>
* Copyright (c) 2008 Hans-Joerg Hoexer <hshoexer@openbsd.org>
@@ -204,7 +204,11 @@ sr_crypto_assemble(struct sr_discipline *sd, struct bioc_createraid *bc,
if (sd->mds.mdd_crypto.scr_meta == NULL)
goto done;
- if (bc->bc_key_disk != NODEV) {
+ if (data != NULL) {
+ /* Kernel already has mask key. */
+ bcopy(data, sd->mds.mdd_crypto.scr_maskkey,
+ sizeof(sd->mds.mdd_crypto.scr_maskkey));
+ } else if (bc->bc_key_disk != NODEV) {
/* Read the mask key from the key disk. */
sd->mds.mdd_crypto.key_disk =
sr_crypto_read_key_disk(sd, bc->bc_key_disk);
@@ -231,8 +235,8 @@ sr_crypto_assemble(struct sr_discipline *sd, struct bioc_createraid *bc,
/* get kdf with maskkey from userland */
if (sr_crypto_get_kdf(bc, sd))
goto done;
-
- }
+ } else
+ goto done;
sd->sd_max_ccb_per_wu = sd->sd_meta->ssdi.ssd_chunk_no;
diff --git a/sys/dev/softraidvar.h b/sys/dev/softraidvar.h
index 0def3f1db9e..ab02802e899 100644
--- a/sys/dev/softraidvar.h
+++ b/sys/dev/softraidvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: softraidvar.h,v 1.117 2012/10/08 14:22:41 jsing Exp $ */
+/* $OpenBSD: softraidvar.h,v 1.118 2012/10/09 11:57:33 jsing Exp $ */
/*
* Copyright (c) 2006 Marco Peereboom <marco@peereboom.us>
* Copyright (c) 2008 Chris Kuethe <ckuethe@openbsd.org>
@@ -254,7 +254,7 @@ struct sr_aoe_config {
struct sr_boot_chunk {
struct sr_metadata *sbc_metadata;
- dev_t sbc_mm;
+ dev_t sbc_mm; /* Device major/minor. */
u_int32_t sbc_chunk_id; /* Chunk ID. */
u_int32_t sbc_state; /* Chunk state. */
@@ -332,6 +332,9 @@ extern u_int32_t sr_debug;
#define SR_VM_IGNORE_DIRTY 1
#define SR_REBUILD_IO_SIZE 128 /* blocks */
+extern struct sr_uuid sr_bootuuid;
+extern u_int8_t sr_bootkey[SR_CRYPTO_MAXKEYBYTES];
+
/* forward define to prevent dependency goo */
struct sr_softc;