mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 10:37:35 +03:00
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 <dinatale2@llnl.gov>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: loli10K <ezomori.nozomu@gmail.com>
Closes #5878
This commit is contained in:
+12
-1
@@ -70,6 +70,7 @@
|
||||
#include <libintl.h>
|
||||
#include <libnvpair.h>
|
||||
#include <limits.h>
|
||||
#include <sys/spa.h>
|
||||
#include <scsi/scsi.h>
|
||||
#include <scsi/sg.h>
|
||||
#include <stdio.h>
|
||||
@@ -721,8 +722,18 @@ make_leaf_vdev(nvlist_t *props, const char *arg, uint64_t is_log)
|
||||
char *value = NULL;
|
||||
|
||||
if (nvlist_lookup_string(props,
|
||||
zpool_prop_to_name(ZPOOL_PROP_ASHIFT), &value) == 0)
|
||||
zpool_prop_to_name(ZPOOL_PROP_ASHIFT), &value) == 0) {
|
||||
zfs_nicestrtonum(NULL, value, &ashift);
|
||||
if (ashift != 0 &&
|
||||
(ashift < ASHIFT_MIN || ashift > ASHIFT_MAX)) {
|
||||
(void) fprintf(stderr,
|
||||
gettext("invalid 'ashift=%" PRIu64 "' "
|
||||
"property: only values between %" PRId32 " "
|
||||
"and %" PRId32 " are allowed.\n"),
|
||||
ashift, ASHIFT_MIN, ASHIFT_MAX);
|
||||
return (NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user