diff options
author | 2017-06-12 16:39:51 +0000 | |
---|---|---|
committer | 2017-06-12 16:39:51 +0000 | |
commit | 4fe5a5deb319db7fe86b4f2cdc52c5b6e9aad276 (patch) | |
tree | def4d7963f4beeb277853a34130842b60b80e2a9 /sys/dev/softraid_crypto.c | |
parent | Upon failure, only return zero from the softraid ioctl handler when there (diff) | |
download | wireguard-openbsd-4fe5a5deb319db7fe86b4f2cdc52c5b6e9aad276.tar.xz wireguard-openbsd-4fe5a5deb319db7fe86b4f2cdc52c5b6e9aad276.zip |
Limit the maximum size of softraid crypto volumes that can be created to
the size that is currently supported (a data area of 16TB, or
2^32 * 32 + 528 blocks including the softraid metadata/boot area), rather
than successfully creating the volume and then failing during resource
allocation (without properly reporting why it failed).
Found the hard way by sharon s. <mymlact at gmx dot com>
Diffstat (limited to 'sys/dev/softraid_crypto.c')
-rw-r--r-- | sys/dev/softraid_crypto.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/sys/dev/softraid_crypto.c b/sys/dev/softraid_crypto.c index 1994300fec1..5145caa6e2d 100644 --- a/sys/dev/softraid_crypto.c +++ b/sys/dev/softraid_crypto.c @@ -1,4 +1,4 @@ -/* $OpenBSD: softraid_crypto.c,v 1.136 2017/06/12 15:15:08 jsing Exp $ */ +/* $OpenBSD: softraid_crypto.c,v 1.137 2017/06/12 16:39:51 jsing Exp $ */ /* * Copyright (c) 2007 Marco Peereboom <marco@peereboom.us> * Copyright (c) 2008 Hans-Joerg Hoexer <hshoexer@openbsd.org> @@ -137,7 +137,13 @@ sr_crypto_create(struct sr_discipline *sd, struct bioc_createraid *bc, sr_error(sd->sd_sc, "%s requires exactly one chunk", sd->sd_name); goto done; - } + } + + if (coerced_size > SR_CRYPTO_MAXSIZE) { + sr_error(sd->sd_sc, "%s exceeds maximum size (%lli > %llu)", + sd->sd_name, coerced_size, SR_CRYPTO_MAXSIZE); + goto done; + } /* Create crypto optional metadata. */ omi = malloc(sizeof(struct sr_meta_opt_item), M_DEVBUF, |