aboutsummaryrefslogtreecommitdiffstats
path: root/include/sys/zfs_ioctl.h
diff options
context:
space:
mode:
authorTom Caputi <[email protected]>2017-08-14 13:36:48 -0400
committerBrian Behlendorf <[email protected]>2017-08-14 10:36:48 -0700
commitb52563034230b35f0562b6f40ad1a00f02bd9a05 (patch)
tree794ccc5160e997e280cb6e36c7778ce9f7a96548 /include/sys/zfs_ioctl.h
parent376994828fd3753aba75d492859727ca76f6a293 (diff)
Native Encryption for ZFS on Linux
This change incorporates three major pieces: The first change is a keystore that manages wrapping and encryption keys for encrypted datasets. These commands mostly involve manipulating the new DSL Crypto Key ZAP Objects that live in the MOS. Each encrypted dataset has its own DSL Crypto Key that is protected with a user's key. This level of indirection allows users to change their keys without re-encrypting their entire datasets. The change implements the new subcommands "zfs load-key", "zfs unload-key" and "zfs change-key" which allow the user to manage their encryption keys and settings. In addition, several new flags and properties have been added to allow dataset creation and to make mounting and unmounting more convenient. The second piece of this patch provides the ability to encrypt, decyrpt, and authenticate protected datasets. Each object set maintains a Merkel tree of Message Authentication Codes that protect the lower layers, similarly to how checksums are maintained. This part impacts the zio layer, which handles the actual encryption and generation of MACs, as well as the ARC and DMU, which need to be able to handle encrypted buffers and protected data. The last addition is the ability to do raw, encrypted sends and receives. The idea here is to send raw encrypted and compressed data and receive it exactly as is on a backup system. This means that the dataset on the receiving system is protected using the same user key that is in use on the sending side. By doing so, datasets can be efficiently backed up to an untrusted system without fear of data being compromised. Reviewed by: Matthew Ahrens <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Jorgen Lundman <[email protected]> Signed-off-by: Tom Caputi <[email protected]> Closes #494 Closes #5769
Diffstat (limited to 'include/sys/zfs_ioctl.h')
-rw-r--r--include/sys/zfs_ioctl.h58
1 files changed, 49 insertions, 9 deletions
diff --git a/include/sys/zfs_ioctl.h b/include/sys/zfs_ioctl.h
index c68b8770b..904588271 100644
--- a/include/sys/zfs_ioctl.h
+++ b/include/sys/zfs_ioctl.h
@@ -104,6 +104,7 @@ typedef enum drr_headertype {
/* flag #21 is reserved for a Delphix feature */
#define DMU_BACKUP_FEATURE_COMPRESSED (1 << 22)
#define DMU_BACKUP_FEATURE_LARGE_DNODE (1 << 23)
+#define DMU_BACKUP_FEATURE_RAW (1 << 24)
/*
* Mask of all supported backup features
@@ -112,7 +113,8 @@ typedef enum drr_headertype {
DMU_BACKUP_FEATURE_DEDUPPROPS | DMU_BACKUP_FEATURE_SA_SPILL | \
DMU_BACKUP_FEATURE_EMBED_DATA | DMU_BACKUP_FEATURE_LZ4 | \
DMU_BACKUP_FEATURE_RESUMING | DMU_BACKUP_FEATURE_LARGE_BLOCKS | \
- DMU_BACKUP_FEATURE_COMPRESSED | DMU_BACKUP_FEATURE_LARGE_DNODE)
+ DMU_BACKUP_FEATURE_COMPRESSED | DMU_BACKUP_FEATURE_LARGE_DNODE | \
+ DMU_BACKUP_FEATURE_RAW)
/* Are all features in the given flag word currently supported? */
#define DMU_STREAM_SUPPORTED(x) (!((x) & ~DMU_BACKUP_FEATURE_MASK))
@@ -158,18 +160,28 @@ typedef enum dmu_send_resume_token_version {
#define DRR_FLAG_FREERECORDS (1<<2)
/*
- * flags in the drr_checksumflags field in the DRR_WRITE and
- * DRR_WRITE_BYREF blocks
+ * flags in the drr_flags field in the DRR_WRITE, DRR_SPILL, DRR_OBJECT,
+ * DRR_WRITE_BYREF, and DRR_OBJECT_RANGE blocks
*/
-#define DRR_CHECKSUM_DEDUP (1<<0)
+#define DRR_CHECKSUM_DEDUP (1<<0) /* not used for DRR_SPILL blocks */
+#define DRR_RAW_ENCRYPTED (1<<1)
+#define DRR_RAW_BYTESWAP (1<<2)
#define DRR_IS_DEDUP_CAPABLE(flags) ((flags) & DRR_CHECKSUM_DEDUP)
+#define DRR_IS_RAW_ENCRYPTED(flags) ((flags) & DRR_RAW_ENCRYPTED)
+#define DRR_IS_RAW_BYTESWAPPED(flags) ((flags) & DRR_RAW_BYTESWAP)
/* deal with compressed drr_write replay records */
#define DRR_WRITE_COMPRESSED(drrw) ((drrw)->drr_compressiontype != 0)
#define DRR_WRITE_PAYLOAD_SIZE(drrw) \
(DRR_WRITE_COMPRESSED(drrw) ? (drrw)->drr_compressed_size : \
(drrw)->drr_logical_size)
+#define DRR_SPILL_PAYLOAD_SIZE(drrs) \
+ (DRR_IS_RAW_ENCRYPTED(drrs->drr_flags) ? \
+ (drrs)->drr_compressed_size : (drrs)->drr_length)
+#define DRR_OBJECT_PAYLOAD_SIZE(drro) \
+ (DRR_IS_RAW_ENCRYPTED(drro->drr_flags) ? \
+ drro->drr_raw_bonuslen : P2ROUNDUP(drro->drr_bonuslen, 8))
/*
* zfs ioctl command structure
@@ -178,7 +190,8 @@ typedef struct dmu_replay_record {
enum {
DRR_BEGIN, DRR_OBJECT, DRR_FREEOBJECTS,
DRR_WRITE, DRR_FREE, DRR_END, DRR_WRITE_BYREF,
- DRR_SPILL, DRR_WRITE_EMBEDDED, DRR_NUMTYPES
+ DRR_SPILL, DRR_WRITE_EMBEDDED, DRR_OBJECT_RANGE,
+ DRR_NUMTYPES
} drr_type;
uint32_t drr_payloadlen;
union {
@@ -205,8 +218,13 @@ typedef struct dmu_replay_record {
uint8_t drr_checksumtype;
uint8_t drr_compress;
uint8_t drr_dn_slots;
- uint8_t drr_pad[5];
+ uint8_t drr_flags;
+ uint32_t drr_raw_bonuslen;
uint64_t drr_toguid;
+ /* only nonzero if DRR_RAW_ENCRYPTED flag is set */
+ uint8_t drr_indblkshift;
+ uint8_t drr_nlevels;
+ uint8_t drr_nblkptr;
/* bonus content follows */
} drr_object;
struct drr_freeobjects {
@@ -222,13 +240,17 @@ typedef struct dmu_replay_record {
uint64_t drr_logical_size;
uint64_t drr_toguid;
uint8_t drr_checksumtype;
- uint8_t drr_checksumflags;
+ uint8_t drr_flags;
uint8_t drr_compressiontype;
uint8_t drr_pad2[5];
/* deduplication key */
ddt_key_t drr_key;
/* only nonzero if drr_compressiontype is not 0 */
uint64_t drr_compressed_size;
+ /* only nonzero if DRR_RAW_ENCRYPTED flag is set */
+ uint8_t drr_salt[ZIO_DATA_SALT_LEN];
+ uint8_t drr_iv[ZIO_DATA_IV_LEN];
+ uint8_t drr_mac[ZIO_DATA_MAC_LEN];
/* content follows */
} drr_write;
struct drr_free {
@@ -249,7 +271,7 @@ typedef struct dmu_replay_record {
uint64_t drr_refoffset;
/* properties of the data */
uint8_t drr_checksumtype;
- uint8_t drr_checksumflags;
+ uint8_t drr_flags;
uint8_t drr_pad2[6];
ddt_key_t drr_key; /* deduplication key */
} drr_write_byref;
@@ -257,7 +279,15 @@ typedef struct dmu_replay_record {
uint64_t drr_object;
uint64_t drr_length;
uint64_t drr_toguid;
- uint64_t drr_pad[4]; /* needed for crypto */
+ uint8_t drr_flags;
+ uint8_t drr_compressiontype;
+ uint8_t drr_pad[6];
+ /* only nonzero if DRR_RAW_ENCRYPTED flag is set */
+ uint64_t drr_compressed_size;
+ uint8_t drr_salt[ZIO_DATA_SALT_LEN];
+ uint8_t drr_iv[ZIO_DATA_IV_LEN];
+ uint8_t drr_mac[ZIO_DATA_MAC_LEN];
+ dmu_object_type_t drr_type;
/* spill data follows */
} drr_spill;
struct drr_write_embedded {
@@ -273,6 +303,16 @@ typedef struct dmu_replay_record {
uint32_t drr_psize; /* compr. (real) size of payload */
/* (possibly compressed) content follows */
} drr_write_embedded;
+ struct drr_object_range {
+ uint64_t drr_firstobj;
+ uint64_t drr_numslots;
+ uint64_t drr_toguid;
+ uint8_t drr_salt[ZIO_DATA_SALT_LEN];
+ uint8_t drr_iv[ZIO_DATA_IV_LEN];
+ uint8_t drr_mac[ZIO_DATA_MAC_LEN];
+ uint8_t drr_flags;
+ uint8_t drr_pad[3];
+ } drr_object_range;
/*
* Nore: drr_checksum is overlaid with all record types