summaryrefslogtreecommitdiffstats
path: root/sys/dev/softraid_raid0.c
diff options
context:
space:
mode:
authorreyk <reyk@openbsd.org>2013-11-05 08:55:58 +0000
committerreyk <reyk@openbsd.org>2013-11-05 08:55:58 +0000
commit571fcd44e3980bb94c90ac56a89bd06dcd7d927a (patch)
tree94dc8026b70b77fdce1ee513fed9a1a2d359ea8d /sys/dev/softraid_raid0.c
parentChange an #if 0 surrounding a debug printf into a DPRINTF instead. (diff)
downloadwireguard-openbsd-571fcd44e3980bb94c90ac56a89bd06dcd7d927a.tar.xz
wireguard-openbsd-571fcd44e3980bb94c90ac56a89bd06dcd7d927a.zip
Fix RAID levels 0, 4, 5, and 6 with partitions larger than 2TB.
A 64bit bit operation with the 32bit strip size could overflow and result in ridiculously small volumes when using large partitions (eg. 4x 3TB in RAID 5 resulted in a ~2TB volume). It is fixed by casting the strip size to an unsigned 64bit value. ok tedu@ millert@ deraadt@
Diffstat (limited to 'sys/dev/softraid_raid0.c')
-rw-r--r--sys/dev/softraid_raid0.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/sys/dev/softraid_raid0.c b/sys/dev/softraid_raid0.c
index 0bb6a1834c2..570a213271f 100644
--- a/sys/dev/softraid_raid0.c
+++ b/sys/dev/softraid_raid0.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: softraid_raid0.c,v 1.42 2013/11/01 17:36:19 krw Exp $ */
+/* $OpenBSD: softraid_raid0.c,v 1.43 2013/11/05 08:55:58 reyk Exp $ */
/*
* Copyright (c) 2008 Marco Peereboom <marco@peereboom.us>
*
@@ -84,7 +84,8 @@ sr_raid0_create(struct sr_discipline *sd, struct bioc_createraid *bc,
*/
sd->sd_meta->ssdi.ssd_strip_size = MAXPHYS;
sd->sd_meta->ssdi.ssd_size = (coerced_size &
- ~((sd->sd_meta->ssdi.ssd_strip_size >> DEV_BSHIFT) - 1)) * no_chunk;
+ ~(((u_int64_t)sd->sd_meta->ssdi.ssd_strip_size >>
+ DEV_BSHIFT) - 1)) * no_chunk;
return sr_raid0_init(sd);
}