aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorLOLi <[email protected]>2017-03-29 02:21:11 +0200
committerBrian Behlendorf <[email protected]>2017-03-28 17:21:11 -0700
commitff61d1a4959065aa99d52489438f6737765987c6 (patch)
treefd69cf41719b077ee6408b19cba70ae15c6491db /lib
parent12aec7dcd9b1f4c86eb71d5b9dc737433ee93167 (diff)
Check ashift validity in 'zpool add'
df83110 added the ability to specify a custom "ashift" value from the command line in 'zpool add' and 'zpool attach'. This commit adds additional checks to the provided ashift to prevent invalid values from being used, which could result in disastrous consequences for the whole pool. Additionally provide ASHIFT_MAX and ASHIFT_MIN definitions in spa.h. Reviewed-by: Giuseppe Di Natale <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: loli10K <[email protected]> Closes #5878
Diffstat (limited to 'lib')
-rw-r--r--lib/libzfs/libzfs_pool.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/libzfs/libzfs_pool.c b/lib/libzfs/libzfs_pool.c
index 616f5061f..16fff89e6 100644
--- a/lib/libzfs/libzfs_pool.c
+++ b/lib/libzfs/libzfs_pool.c
@@ -538,10 +538,13 @@ zpool_valid_proplist(libzfs_handle_t *hdl, const char *poolname,
goto error;
}
- if (intval != 0 && (intval < 9 || intval > 13)) {
+ if (intval != 0 &&
+ (intval < ASHIFT_MIN || intval > ASHIFT_MAX)) {
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
- "property '%s' number %d is invalid."),
- propname, intval);
+ "invalid '%s=%d' property: only values "
+ "between %" PRId32 " and %" PRId32 " "
+ "are allowed.\n"),
+ propname, intval, ASHIFT_MIN, ASHIFT_MAX);
(void) zfs_error(hdl, EZFS_BADPROP, errbuf);
goto error;
}