From 0da7212d11854a705dc46b9a01cba9ac0ed0f214 Mon Sep 17 00:00:00 2001 From: jsing Date: Wed, 28 Dec 2011 16:02:45 +0000 Subject: Avoid the use of an invalid disklabel by setting a DK_LABELVALID flag if we correctly read and validated the disklabel. Always check that this flag is set before using the DUID from the disklabel. Discussed with deraadt@ ok krw@ --- sys/dev/softraid.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'sys/dev/softraid.c') diff --git a/sys/dev/softraid.c b/sys/dev/softraid.c index 1eee7e40c93..a30870140e2 100644 --- a/sys/dev/softraid.c +++ b/sys/dev/softraid.c @@ -1,4 +1,4 @@ -/* $OpenBSD: softraid.c,v 1.260 2011/12/26 14:54:52 jsing Exp $ */ +/* $OpenBSD: softraid.c,v 1.261 2011/12/28 16:02:45 jsing Exp $ */ /* * Copyright (c) 2007, 2008, 2009 Marco Peereboom * Copyright (c) 2008 Chris Kuethe @@ -3389,6 +3389,7 @@ sr_ioctl_installboot(struct sr_softc *sc, struct bioc_installboot *bb) if (!strncmp(dk->dk_name, bb->bb_dev, sizeof(bb->bb_dev))) break; if (dk == NULL || dk->dk_label == NULL || + (dk->dk_flags & DKF_LABELVALID) == 0 || bcmp(dk->dk_label->d_uid, &duid, sizeof(duid)) == 0) { printf("%s: failed to get DUID for softraid volume!\n", DEVNAME(sd->sd_sc)); -- cgit v1.2.3-59-g8ed1b