From ac536cd553a9e79db825666048519092c008d972 Mon Sep 17 00:00:00 2001 From: krw Date: Wed, 20 Dec 2017 02:02:31 +0000 Subject: [PATCH] Add a sanity check on the number of chunks being assembled into a volume, to enure the on-disk metadata and the in-memory metadata agree. --- sys/dev/softraid.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/sys/dev/softraid.c b/sys/dev/softraid.c index aa1d001e5ad..6923962d32f 100644 --- a/sys/dev/softraid.c +++ b/sys/dev/softraid.c @@ -1,4 +1,4 @@ -/* $OpenBSD: softraid.c,v 1.386 2017/12/14 20:23:13 deraadt Exp $ */ +/* $OpenBSD: softraid.c,v 1.387 2017/12/20 02:02:31 krw Exp $ */ /* * Copyright (c) 2007, 2008, 2009 Marco Peereboom * Copyright (c) 2008 Chris Kuethe @@ -3427,6 +3427,13 @@ sr_ioctl_createraid(struct sr_softc *sc, struct bioc_createraid *bc, } else { + /* Ensure we are assembling the correct # of chunks. */ + if (sd->sd_meta->ssdi.ssd_chunk_no != no_chunk) { + sr_error(sc, "volume chunk count does not match metadata " + "chunk count"); + goto unwind; + } + /* Ensure metadata level matches requested assembly level. */ if (sd->sd_meta->ssdi.ssd_level != bc->bc_level) { sr_error(sc, "volume level does not match metadata " -- 2.20.1