summaryrefslogtreecommitdiffstats
path: root/module/zcommon/zfs_prop.c
diff options
context:
space:
mode:
Diffstat (limited to 'module/zcommon/zfs_prop.c')
-rw-r--r--module/zcommon/zfs_prop.c99
1 files changed, 96 insertions, 3 deletions
diff --git a/module/zcommon/zfs_prop.c b/module/zcommon/zfs_prop.c
index 93c89e4aa..67faa07e7 100644
--- a/module/zcommon/zfs_prop.c
+++ b/module/zcommon/zfs_prop.c
@@ -33,6 +33,7 @@
#include <sys/zfs_acl.h>
#include <sys/zfs_ioctl.h>
#include <sys/zfs_znode.h>
+#include <sys/dsl_crypt.h>
#include "zfs_prop.h"
#include "zfs_deleg.h"
@@ -119,6 +120,26 @@ zfs_prop_init(void)
{ NULL }
};
+ static zprop_index_t crypto_table[] = {
+ { "on", ZIO_CRYPT_ON },
+ { "off", ZIO_CRYPT_OFF },
+ { "aes-128-ccm", ZIO_CRYPT_AES_128_CCM },
+ { "aes-192-ccm", ZIO_CRYPT_AES_192_CCM },
+ { "aes-256-ccm", ZIO_CRYPT_AES_256_CCM },
+ { "aes-128-gcm", ZIO_CRYPT_AES_128_GCM },
+ { "aes-192-gcm", ZIO_CRYPT_AES_192_GCM },
+ { "aes-256-gcm", ZIO_CRYPT_AES_256_GCM },
+ { NULL }
+ };
+
+ static zprop_index_t keyformat_table[] = {
+ { "none", ZFS_KEYFORMAT_NONE },
+ { "raw", ZFS_KEYFORMAT_RAW },
+ { "hex", ZFS_KEYFORMAT_HEX },
+ { "passphrase", ZFS_KEYFORMAT_PASSPHRASE },
+ { NULL }
+ };
+
static zprop_index_t snapdir_table[] = {
{ "hidden", ZFS_SNAPDIR_HIDDEN },
{ "visible", ZFS_SNAPDIR_VISIBLE },
@@ -193,6 +214,13 @@ zfs_prop_init(void)
{ NULL }
};
+ static zprop_index_t keystatus_table[] = {
+ { "none", ZFS_KEYSTATUS_NONE},
+ { "unavailable", ZFS_KEYSTATUS_UNAVAILABLE},
+ { "available", ZFS_KEYSTATUS_AVAILABLE},
+ { NULL }
+ };
+
static zprop_index_t logbias_table[] = {
{ "latency", ZFS_LOGBIAS_LATENCY },
{ "throughput", ZFS_LOGBIAS_THROUGHPUT },
@@ -351,12 +379,16 @@ zfs_prop_init(void)
PROP_DEFAULT, ZFS_TYPE_FILESYSTEM, "on | off | noauto",
"CANMOUNT", canmount_table);
- /* readonly index (boolean) properties */
+ /* readonly index properties */
zprop_register_index(ZFS_PROP_MOUNTED, "mounted", 0, PROP_READONLY,
ZFS_TYPE_FILESYSTEM, "yes | no", "MOUNTED", boolean_table);
zprop_register_index(ZFS_PROP_DEFER_DESTROY, "defer_destroy", 0,
PROP_READONLY, ZFS_TYPE_SNAPSHOT, "yes | no", "DEFER_DESTROY",
boolean_table);
+ zprop_register_index(ZFS_PROP_KEYSTATUS, "keystatus",
+ ZFS_KEYSTATUS_NONE, PROP_READONLY, ZFS_TYPE_DATASET,
+ "none | unavailable | available",
+ "KEYSTATUS", keystatus_table);
/* set once index properties */
zprop_register_index(ZFS_PROP_NORMALIZE, "normalization", 0,
@@ -367,6 +399,15 @@ zfs_prop_init(void)
ZFS_CASE_SENSITIVE, PROP_ONETIME, ZFS_TYPE_FILESYSTEM |
ZFS_TYPE_SNAPSHOT,
"sensitive | insensitive | mixed", "CASE", case_table);
+ zprop_register_index(ZFS_PROP_KEYFORMAT, "keyformat",
+ ZFS_KEYFORMAT_NONE, PROP_ONETIME_DEFAULT,
+ ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
+ "none | raw | hex | passphrase", "KEYFORMAT", keyformat_table);
+ zprop_register_index(ZFS_PROP_ENCRYPTION, "encryption",
+ ZIO_CRYPT_DEFAULT, PROP_ONETIME, ZFS_TYPE_DATASET,
+ "on | off | aes-128-ccm | aes-192-ccm | aes-256-ccm | "
+ "aes-128-gcm | aes-192-gcm | aes-256-gcm", "ENCRYPTION",
+ crypto_table);
/* set once index (boolean) properties */
zprop_register_index(ZFS_PROP_UTF8ONLY, "utf8only", 0, PROP_ONETIME,
@@ -409,6 +450,12 @@ zfs_prop_init(void)
"receive_resume_token",
NULL, PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
"<string token>", "RESUMETOK");
+ zprop_register_string(ZFS_PROP_ENCRYPTION_ROOT, "encryptionroot", NULL,
+ PROP_READONLY, ZFS_TYPE_DATASET, "<filesystem | volume>",
+ "ENCROOT");
+ zprop_register_string(ZFS_PROP_KEYLOCATION, "keylocation",
+ "none", PROP_DEFAULT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
+ "prompt | <file URI>", "KEYLOCATION");
/* readonly number properties */
zprop_register_number(ZFS_PROP_USED, "used", 0, PROP_READONLY,
@@ -456,6 +503,9 @@ zfs_prop_init(void)
ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, "<uint64>", "GUID");
zprop_register_number(ZFS_PROP_CREATETXG, "createtxg", 0, PROP_READONLY,
ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, "<uint64>", "CREATETXG");
+ zprop_register_number(ZFS_PROP_PBKDF2_ITERS, "pbkdf2iters",
+ 0, PROP_ONETIME_DEFAULT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
+ "<iters>", "PBKDF2ITERS");
/* default number properties */
zprop_register_number(ZFS_PROP_QUOTA, "quota", 0, PROP_DEFAULT,
@@ -503,6 +553,11 @@ zfs_prop_init(void)
PROP_TYPE_NUMBER, PROP_READONLY, ZFS_TYPE_DATASET, "INCONSISTENT");
zprop_register_hidden(ZFS_PROP_PREV_SNAP, "prevsnap", PROP_TYPE_STRING,
PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "PREVSNAP");
+ zprop_register_hidden(ZFS_PROP_PBKDF2_SALT, "pbkdf2salt",
+ PROP_TYPE_NUMBER, PROP_ONETIME_DEFAULT,
+ ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "PBKDF2SALT");
+ zprop_register_hidden(ZFS_PROP_KEY_GUID, "keyguid", PROP_TYPE_NUMBER,
+ PROP_READONLY, ZFS_TYPE_DATASET, "KEYGUID");
/*
* Property to be removed once libbe is integrated
@@ -650,7 +705,8 @@ boolean_t
zfs_prop_readonly(zfs_prop_t prop)
{
return (zfs_prop_table[prop].pd_attr == PROP_READONLY ||
- zfs_prop_table[prop].pd_attr == PROP_ONETIME);
+ zfs_prop_table[prop].pd_attr == PROP_ONETIME ||
+ zfs_prop_table[prop].pd_attr == PROP_ONETIME_DEFAULT);
}
/*
@@ -659,7 +715,8 @@ zfs_prop_readonly(zfs_prop_t prop)
boolean_t
zfs_prop_setonce(zfs_prop_t prop)
{
- return (zfs_prop_table[prop].pd_attr == PROP_ONETIME);
+ return (zfs_prop_table[prop].pd_attr == PROP_ONETIME ||
+ zfs_prop_table[prop].pd_attr == PROP_ONETIME_DEFAULT);
}
const char *
@@ -694,6 +751,40 @@ zfs_prop_inheritable(zfs_prop_t prop)
zfs_prop_table[prop].pd_attr == PROP_ONETIME);
}
+/*
+ * Returns TRUE if property is one of the encryption properties that requires
+ * a loaded encryption key to modify.
+ */
+boolean_t
+zfs_prop_encryption_key_param(zfs_prop_t prop)
+{
+ /*
+ * keylocation does not count as an encryption property. It can be
+ * changed at will without needing the master keys.
+ */
+ return (prop == ZFS_PROP_PBKDF2_SALT || prop == ZFS_PROP_PBKDF2_ITERS ||
+ prop == ZFS_PROP_KEYFORMAT);
+}
+
+/*
+ * Helper function used by both kernelspace and userspace to check the
+ * keylocation property. If encrypted is set, the keylocation must be valid
+ * for an encrypted dataset.
+ */
+boolean_t
+zfs_prop_valid_keylocation(const char *str, boolean_t encrypted)
+{
+ if (strcmp("none", str) == 0)
+ return (!encrypted);
+ else if (strcmp("prompt", str) == 0)
+ return (B_TRUE);
+ else if (strlen(str) > 8 && strncmp("file:///", str, 8) == 0)
+ return (B_TRUE);
+
+ return (B_FALSE);
+}
+
+
#ifndef _KERNEL
/*
@@ -774,6 +865,8 @@ EXPORT_SYMBOL(zfs_prop_default_string);
EXPORT_SYMBOL(zfs_prop_default_numeric);
EXPORT_SYMBOL(zfs_prop_readonly);
EXPORT_SYMBOL(zfs_prop_inheritable);
+EXPORT_SYMBOL(zfs_prop_encryption_key_param);
+EXPORT_SYMBOL(zfs_prop_valid_keylocation);
EXPORT_SYMBOL(zfs_prop_setonce);
EXPORT_SYMBOL(zfs_prop_to_name);
EXPORT_SYMBOL(zfs_name_to_prop);