diff options
author | 2013-11-05 08:55:58 +0000 | |
---|---|---|
committer | 2013-11-05 08:55:58 +0000 | |
commit | 571fcd44e3980bb94c90ac56a89bd06dcd7d927a (patch) | |
tree | 94dc8026b70b77fdce1ee513fed9a1a2d359ea8d | |
parent | Change an #if 0 surrounding a debug printf into a DPRINTF instead. (diff) | |
download | wireguard-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@
-rw-r--r-- | sys/dev/softraid_raid0.c | 5 | ||||
-rw-r--r-- | sys/dev/softraid_raid6.c | 6 | ||||
-rw-r--r-- | sys/dev/softraid_raidp.c | 6 |
3 files changed, 9 insertions, 8 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); } diff --git a/sys/dev/softraid_raid6.c b/sys/dev/softraid_raid6.c index d5068d4ab34..6fb453847c8 100644 --- a/sys/dev/softraid_raid6.c +++ b/sys/dev/softraid_raid6.c @@ -1,4 +1,4 @@ -/* $OpenBSD: softraid_raid6.c,v 1.54 2013/11/01 17:36:19 krw Exp $ */ +/* $OpenBSD: softraid_raid6.c,v 1.55 2013/11/05 08:55:58 reyk Exp $ */ /* * Copyright (c) 2009 Marco Peereboom <marco@peereboom.us> * Copyright (c) 2009 Jordan Hargrave <jordan@openbsd.org> @@ -130,8 +130,8 @@ sr_raid6_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 - 2); + ~(((u_int64_t)sd->sd_meta->ssdi.ssd_strip_size >> + DEV_BSHIFT) - 1)) * (no_chunk - 2); return sr_raid6_init(sd); } diff --git a/sys/dev/softraid_raidp.c b/sys/dev/softraid_raidp.c index 4e52b25eb6a..54e2a3ccee4 100644 --- a/sys/dev/softraid_raidp.c +++ b/sys/dev/softraid_raidp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: softraid_raidp.c,v 1.52 2013/11/04 21:02:57 deraadt Exp $ */ +/* $OpenBSD: softraid_raidp.c,v 1.53 2013/11/05 08:55:58 reyk Exp $ */ /* * Copyright (c) 2009 Marco Peereboom <marco@peereboom.us> * Copyright (c) 2009 Jordan Hargrave <jordan@openbsd.org> @@ -109,8 +109,8 @@ sr_raidp_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 - 1); + ~(((u_int64_t)sd->sd_meta->ssdi.ssd_strip_size >> + DEV_BSHIFT) - 1)) * (no_chunk - 1); return sr_raidp_init(sd); } |