summaryrefslogtreecommitdiff
path: root/usr/src
AgeCommit message (Collapse)AuthorFilesLines
2019-03-19Allow child datasets to be created w/o encryptionzfs-crypto-demoAlex Wilson10-15/+27
2019-03-14Cleanup zio_crypt.cJason King1-7/+3
2019-03-13Missing zfsonlinux/zfs#6845 piecesJason King2-6/+14
2019-03-06Fix missing refcount changesJason King6-48/+44
2019-03-06Review fixesJorgen Lundman3-14/+3
2019-03-06Drop zfs_create_014_posJorgen Lundman1-2/+1
2019-03-06Mixed raw receives updateTom Caputi4-27/+36
Signed-off-by: Tom Caputi <tcaputi@datto.com>
2019-03-06Minor correctionJorgen Lundman1-1/+1
2019-03-06Wrong DNODE_MIN_SIZEJorgen Lundman1-1/+1
2019-03-06Fixes for make checkJorgen Lundman2-19/+26
2019-03-06Port pool errata feature from ZOLJorgen Lundman12-32/+177
We need to detect and pass along at least 2 erratas with crypto so it seemed best to port the errata framework entirely.
2019-03-06WIP: Detect and prevent mixed raw and non-raw sendsTom Caputi19-38/+296
Currently, there is an issue in the raw receive code where raw receives are allowed to happen on top of previously non-raw received datasets. This is a problem because the source-side dataset doesn't know about how the blocks on the destination were encrypted. As a result, any MAC in the objset's checksum-of-MACs tree that is a parent of both blocks encrypted on the source and blocks encrypted by the destination will be incorrect. This will result in authentication errors when we decrypt the dataset. This patch fixes this issue by adding a new check to the raw receive code. The code now maintains an "IVset guid", which acts as an identifier for the set of IVs used to encrypt a given snapshot. When a snapshot is raw received, the destination snapshot will take this value from the DRR_BEGIN payload. Non-raw receives and normal "zfs snap" operations will cause ZFS to generate a new IVset guid. When a raw incremental stream is received, ZFS will check that the "from" IVset guid in the stream matches that of the "from" destination snapshot. If they do not match, the code will error out the receive, preventing the problem. This patch requires an on-disk format change to add the IVset guids to snapshots and bookmarks. As a result, this patch has errata handling and a tunable to help affected users resolve the issue with as little interruption as possible. Signed-off-by: Tom Caputi <tcaputi@datto.com>
2019-03-06WIP: Add bookmark v2 on-disk featureTom Caputi5-3/+59
This patch adds the bookmark v2 feature to the on-disk format. This feature will be needed for the upcoming redacted sends and for an upcoming fix that for raw receives. The feature is not currently used by any code and thus thich change is a no-op, aside from the fact that the user can now enable the feature. Signed-off-by: Tom Caputi <tcaputi@datto.com>
2019-03-06Stop 0-byte KM_SLEEP allocation in dmu_send.cJason King1-1/+4
2019-03-06rename fixes #2Jorgen Lundman1-5/+5
2019-03-06lzc_rename merge errorJorgen Lundman1-2/+2
2019-03-06Populate salt, iv, and mac for DRR_OBJECT_RANGE + indentJason King1-20/+30
2019-03-06Fix zfs(1m) mandoc(1) errorsJason King1-25/+32
2019-03-06variables assigned but not usedJason King1-5/+0
2019-03-06Remove superfluous arc_space callsJorgen Lundman1-3/+0
2019-03-06lintingJorgen Lundman3-3/+7
Interestingly, illumos does not have ASSERTV
2019-03-06Correct refcount_add_manyJorgen Lundman1-1/+1
Gremlins changed it back
2019-03-06Add zfs_refcount_transfer_ownership_many()Brian Behlendorf3-3/+22
When debugging is enabled and a zfs_refcount_t contains multiple holders using the same key, but different ref_counts, the wrong reference_t may be transferred. Add a zfs_refcount_transfer_ownership_many() function, like the existing zfs_refcount_*_many() functions, to match and transfer the correct refcount_t; This issue may occur when using encryption with refcount debugging enabled. An arc_buf_hdr_t can have references for both the hdr->b_l1hdr.b_pabd and hdr->b_crypt_hdr.b_rabd both of which use the hdr as the reference holder. When unsharing the buffer the p_abd should be transferred. This issue does not impact production builds because refcount holders are not tracked. Reviewed-by: Matthew Ahrens <mahrens@delphix.com> Signed-off-by: Tom Caputi <tcaputi@datto.com> Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
2019-03-06Refcounted DSL Crypto Key MappingsTom Caputi9-108/+194
Since native ZFS encryption was merged, we have been fighting against a series of bugs that come down to the same problem: Key mappings (which must be present during all I/O operations) are created and destroyed based on dataset ownership, but I/Os can have traditionally been allowed to "leak" into the next txg after the dataset is disowned. In the past we have attempted to solve this problem by trying to ensure that datasets are disowned ater all I/O is finished by calling txg_wait_synced(), but we have repeatedly found edge cases that need to be squashed and code paths that might incur a high number of txg syncs. This patch attempts to resolve this issue differently, by adding a reference to the key mapping for each txg it is dirtied in. By doing so, we can remove many of the unnecessary calls to txg_wait_synced() we have added in the past and ensure we don't need to deal with this problem in the future. Reviewed-by: Jorgen Lundman <lundman@lundman.net> Reviewed by: Matthew Ahrens <mahrens@delphix.com> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Tom Caputi <tcaputi@datto.com>
2019-03-068727 Native data and metadata encryption for zfsTom Caputi178-1470/+18435
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 <mahrens@delphix.com> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Jorgen Lundman <lundman@lundman.net> Signed-off-by: Tom Caputi <tcaputi@datto.com> Send / Recv Fixes following b52563 This patch fixes several issues discovered after the encryption patch was merged: Fixed a bug where encrypted datasets could attempt to receive embedded data records. Fixed a bug where dirty records created by the recv code wasn't properly setting the dr_raw flag. Fixed a typo where a dmu_tx_commit() was changed to dmu_tx_abort() Fixed a few error handling bugs unrelated to the encryption patch in dmu_recv_stream() Signed-off-by: Tom Caputi <tcaputi@datto.com> Encryption patch follow-up * HKDF implementation moved to its own file and tests added to ensure correctness. * Ztest can now create and test encrypted datasets. This is currently disabled until issue ZOL #6526 is resolved, but otherwise functions as advertised. * Several small bug fixes discovered after enabling ztest to run on encrypted datasets. * Fixed coverity defects added by the encryption patch. * Updated man pages for encrypted send / receive behavior. * Fixed a bug where encrypted datasets could receive DRR_WRITE_EMBEDDED records. * Minor code cleanups / consolidation. Disable crypto tests in ztest * Includes fix in dmu_free_long_object_impl Unless permission is given to compile the crypto framework in userland the crypto tests in ztest are disabled on IllumOS. Fix encryption root hierarchy issue After doing a recursive raw receive, zfs userspace performs a final pass to adjust the encryption root hierarchy as needed. Unfortunately, the FORCE_INHERIT ioctl had a bug which caused the encryption root to always be assigned to the direct parent instead of the inheriting parent. This patch simply fixes this issue Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Alek Pinchuk <apinchuk@datto.com> Signed-off-by: Tom Caputi <tcaputi@datto.com> Closes ZOL # 6847 Closes ZOL # 6848 Encryption Stability and On-Disk Format Fixes The on-disk format for encrypted datasets protects not only the encrypted and authenticated blocks themselves, but also the order and interpretation of these blocks. In order to make this work while maintaining the ability to do raw sends, the indirect bps maintain a secure checksum of all the MACs in the block below it along with a few other fields that determine how the data is interpreted. Unfortunately, the current on-disk format erroneously includes some fields which are not portable and thus cannot support raw sends. It is not possible to easily work around this issue due to a separate and much smaller bug which causes indirect blocks for encrypted dnodes to not be compressed, which conflicts with the previous bug. In addition, the current code generates incompatible on-disk formats on big endian and little endian systems due to an issue with how block pointers are authenticated. Finally, raw send streams do not currently include dn_maxblkid when sending both the metadnode and normal dnodes which are needed in order to ensure that we are correctly maintaining the portable objset MAC. This patch zero's out the offending fields when computing the bp MAC and ensures that these MACs are always calculated in little endian order (regardless of the host system's byte order). This patch also registers an errata for the old on-disk format, which we detect by adding a "version" field to newly created DSL Crypto Keys. We allow datasets without a version (version 0) to only be mounted for read so that they can easily be migrated. We also now include dn_maxblkid in raw send streams to ensure the MAC can be maintained correctly. Fixes ZOL # 6845 Signed-off-by: Tom Caputi <tcaputi@datto.com> Fix for # 6916 When performing zil_claim() at pool import time, it is important that encrypted datasets set os_next_write_raw before writing to the zil_header_t. This prevents the code from attempting to re-authenticate the objset_phys_t when it writes it out, which is unnecessary because the zil_header_t is not protected by either objset MAC and impossible since the keys aren't loaded yet. Unfortunately, one of the code paths did not set this flag, which causes failed ASSERTs during 'zpool import -F'. This patch corrects this issue. Signed-off-by: Tom Caputi <tcaputi@datto.com> Only restore the readonly bit when it was readonly and compile fixes to be squashed out. Change os->os_next_write_raw to work per txg Currently, os_next_write_raw is a single boolean used for determining whether or not the next call to dmu_objset_sync() should write out the objset_phys_t as a raw buffer. Since the boolean is not associated with a txg, the work simply happens during the next txg, which is not necessarily the correct one. In the current implementation this issue was misdiagnosed, resulting in a small hack in dmu_objset_sync() which seemed to resolve the problem. This patch changes os_next_write_raw to be an array of booleans, one for each txg in TXG_OFF and removes the hack. Signed-off-by: Tom Caputi <tcaputi@datto.com> Raw sends must be able to decrease nlevels Currently, when a raw zfs send file includes a DRR_OBJECT record that would decrease the number of levels of an existing object, the object is reallocated with dmu_object_reclaim() which creates the new dnode using the old object's nlevels. For non-raw sends this doesn't really matter, but raw sends require that nlevels on the receive side match that of the send side so that the checksum-of-MAC tree can be properly maintained. This patch corrects the issue by freeing the object completely before allocating it again in this case. This patch also corrects several issues with dnode_hold_impl() and related functions that prevented dnodes (particularly multi-slot dnodes) from being reallocated properly due to the fact that existing dnodes were not being fully cleaned up when they were freed. Signed-off-by: Tom Caputi <tcaputi@datto.com> Handle compressed buffers in __dbuf_hold_impl() In __dbuf_hold_impl(), if a buffer is currently syncing and is still referenced from db_data, a copy is made in case it is dirtied again in the txg. Previously, the buffer for the copy was simply allocated with arc_alloc_buf() which doesn't handle compressed or encrypted buffers (which are a special case of a compressed buffer). The result was typically an invalid memory access because the newly-allocated buffer was of the uncompressed size. This commit fixes the problem by handling the 2 compressed cases, encrypted and unencrypted, respectively, with arc_alloc_raw_buf() and arc_alloc_compressed_buf(). Although using the proper allocation functions fixes the invalid memory access by allocating a buffer of the compressed size, another unrelated issue made it impossible to properly detect compressed buffers in the first place. The header's compression flag was set to ZIO_COMPRESS_OFF in arc_write() when it was possible that an attached buffer was actually compressed. This commit adds logic to only set ZIO_COMPRESS_OFF in the non-ZIO_RAW case which wil handle both cases of compressed buffers (encrypted or unencrypted). Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Tim Chase <tim@chase2k.com> Raw DRR_OBJECT records must write raw data b1d21733 made it possible for empty metadnode blocks to be compressed to a hole, fixing a bug that would cause invalid metadnode MACs when a send stream attempted to free objects and allowing the blocks to be reclaimed when they were no longer needed. However, this patch also introduced a race condition; if a txg sync occurred after a DRR_OBJECT_RANGE record was received but before any objects were added, the metadnode block would be compressed to a hole and lose all of its encryption parameters. This would cause subsequent DRR_OBJECT records to fail when they attempted to write their data into an unencrypted block. This patch defers the DRR_OBJECT_RANGE handling to receive_object() so that the encryption parameters are set with each object that is written into that block. Reviewed-by: Kash Pande <kash@tripleback.net> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Tom Caputi <tcaputi@datto.com> Fix bounds check in zio_crypt_do_objset_hmacs The current bounds check in zio_crypt_do_objset_hmacs() does not properly handle the possible sizes of the objset_phys_t and can therefore read outside the buffer's memory. If that memory happened to match what the check was actually looking for, the objset would fail to be owned, complaining that the MAC was invalid. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Tom Caputi <tcaputi@datto.com> Raw receive should change key atomically Currently, raw zfs sends transfer the encrypted master keys and objset_phys_t encryption parameters in the DRR_BEGIN payload of each send file. Both of these are processed as soon as they are read in dmu_recv_stream(), meaning that the new keys are set before the new snapshot is received. In addition to the fact that this changes the user's keys for the dataset earlier than they might expect, the keys were never reset to what they originally were in the event that the receive failed. This patch splits the processing into objset handling and key handling, the later of which is moved to dmu_recv_end() so that they key change can be done atomically. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Tom Caputi <tcaputi@datto.com> Raw receives must compress metadnode blocks Currently, the DMU relies on ZIO layer compression to free LO dnode blocks that no longer have objects in them. However, raw receives disable all compression, meaning that these blocks can never be freed. In addition to the obvious space concerns, this could also cause incremental raw receives to fail to mount since the MAC of a hole is different from that of a completely zeroed block. This patch corrects this issue by adding a special case in zio_write_compress() which will attempt to compress these blocks to a hole even if ZIO_FLAG_RAW_ENCRYPT is set. This patch also removes the zfs_mdcomp_disable tunable, since tuning it could cause these same issues. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Tom Caputi <tcaputi@datto.com> Add omitted set for os->os_next_write_raw This one line patch adds adds a set to os->os_next_write_raw that was omitted when the code was updated in 1b66810. Without it, the code (in some instances) could attempt to write raw encrypted data as regular unencrypted data without the keys being loaded, triggering an ASSERT in zio_encrypt(). Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Tom Caputi <tcaputi@datto.com> Prevent raw zfs recv -F if dataset is unencrypted The current design of ZFS encryption only allows a dataset to have one DSL Crypto Key at a time. As a result, it is important that the zfs receive code ensures that only one key can be in use at a time for a given DSL Directory. zfs receive -F complicates this, since the new dataset is received as a clone of the existing one so that an atomic switch can be done at the end. To prevent confusion about which dataset is actually encrypted a check was added to ensure that encrypted datasets cannot use zfs recv -F to completely replace existing datasets. Unfortunately, the check did not take into account unencrypted datasets being overriden by encrypted ones as a case. Along the same lines, the code also failed to ensure that raw recieves could not be done on top of existing unencrypted datasets, which causes amny problems since the new stream cannot be decrypted. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Tom Caputi <tcaputi@datto.com> fix zero-length encryption dont swallow error! Encrypted dnode blocks should be prefetched raw Encrypted dnode blocks are always initially read as raw data and converted to decrypted data when an encrypted bonus buffer is needed. This allows the DMU to be used for things like fetching the DMU master node without requiring keys to be loaded. However, dbuf_issue_final_prefetch() does not currently read the data as raw. The end result of this is that prefetched dnode blocks are read twice from disk: once decrypted and then again as raw data. This patch corrects the issue by adding the flag when appropriate. Reviewed by: Matt Ahrens <matt@delphix.com> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Tom Caputi <tcaputi@datto.com> Decryption error handling improvements Currently, the decryption and block authentication code in the ZIO / ARC layers is a bit inconsistent with regards to the ereports that are produces and the error codes that are passed to calling functions. This patch ensures that all of these errors (which begin as ECKSUM) are converted to EIO before they leave the ZIO or ARC layer and that ereports are correctly generated on each decryption / authentication failure. In addition, this patch fixes a bug in zio_decrypt() where ECKSUM never gets written to zio->io_error. Reviewed by: Matt Ahrens <matt@delphix.com> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Tom Caputi <tcaputi@datto.com> Remove ASSERT() in l2arc_apply_transforms() The ASSERT was erroneously copied from the next section of code. The buffer's size should be expanded from "psize" to "asize" if necessary. Reviewed-by: Tom Caputi <tcaputi@datto.com> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Tim Chase <tim@chase2k.com> fail fraction fixes for SNPRINTF_BLKPTR with encrypted BP's mdb doesn't have dmu_ot[], so we need a different mechanism for its SNPRINTF_BLKPTR() to determine if the BP is encrypted vs authenticated. Additionally, since it already relies on BP_IS_ENCRYPTED (etc), SNPRINTF_BLKPTR might as well figure out the "crypt_type" on its own, rather than making the caller do so. remove assert for testing Make encrypted "zfs mount -a" failures consistent Currently, "zfs mount -a" will print a warning and fail to mount any encrypted datasets that do not have a key loaded. This patch makes the behavior of this failure consistent with other failure modes ("zfs mount -a" will silently continue, explict "zfs mount" will print a message and return an error code. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Tom Caputi <tcaputi@datto.com> Correct manpage for --raw Move enum zio_encrypt into sys/fs/zfs.h assertion failure in arc_release() during encrypted receive receive_spill does not byte swap spill contents In zfs receive, the function receive_spill should account for spill block endian conversion as a defensive measure. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Tom Caputi <tcaputi@datto.com> Signed-off-by: Paul Zuchowski <pzuchowski@datto.com> add codes to truss Correct swapped keylocation error messages This patch corrects a small issue where two error messages in the code that checks for invalid keylocations were swapped. Reviewed by: Matt Ahrens <mahrens@delphix.com> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Giuseppe Di Natale <dinatale2@llnl.gov> Signed-off-by: Tom Caputi <tcaputi@datto.com> Fix issues with raw sends of spill blocks This patch fixes 2 issues in how spill blocks are processed during raw sends. The first problem is that compressed spill blocks were using the logical length rather than the physical length to determine how much data to dump into the send stream. The second issue is a typo that caused the spill record's object number to be used where the objset's ID number was required. Both issues have been corrected, and the payload_size is now printed in zstreamdump for future debugging. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Tom Caputi <tcaputi@datto.com> Fix race in dnode_check_slots_free() Currently, dnode_check_slots_free() works by checking dn->dn_type in the dnode to determine if the dnode is reclaimable. However, there is a small window of time between dnode_free_sync() in the first call to dsl_dataset_sync() and when the useraccounting code is run when the type is set DMU_OT_NONE, but the dnode is not yet evictable, leading to crashes. This patch adds the ability for dnodes to track which txg they were last dirtied in and adds a check for this before performing the reclaim. This patch also corrects several instances when dn_dirty_link was treated as a list_node_t when it is technically a multilist_node_t. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Tom Caputi <tcaputi@datto.com> Fix issues found with zfs diff Two deadlocks / ASSERT failures were introduced in a2c2ed1b which would occur whenever arc_buf_fill() failed to decrypt a block of data. This occurred because the call to arc_buf_destroy() which was responsible for cleaning up the newly created buffer would attempt to take out the hdr lock that it was already holding. This was resolved by calling the underlying functions directly without retaking the lock. In addition, the dmu_diff() code did not properly ensure that keys were loaded and mapped before begining dataset traversal. It turns out that this code does not need to look at any encrypted values, so the code was altered to perform raw IO only. Reviewed by: Matthew Ahrens <mahrens@delphix.com> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Tom Caputi <tcaputi@datto.com> DMU objset should not be encrypted Correct merge collision in dmu_ot table. Correct minor differences in arc.c Add support for decryption faults in zinject This patch adds the ability for zinject to trigger decryption and authentication faults in the ZIO and ARC layers. This functionality is exposed via the new "decrypt" error type, which may be provided for "data" object types. This patch also refactors some of the core encryption / decryption functions so that they have consistent prototypes, handle errors consistently, and do not have unused arguments. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Tom Caputi <tcaputi@datto.com> Raw receive functions must not decrypt data This patch fixes a small bug found where receive_spill() sometimes attempted to decrypt spill blocks when doing a raw receive. In addition, this patch fixes another small issue in arc_buf_fill()'s error handling where a decryption failure (which could be caused by the first bug) would attempt to set the arc header's IO_ERROR flag without holding the header's lock. Signed-off-by: Tom Caputi <tcaputi@datto.com> Update the correct abd in l2arc_read_done() This patch fixes an issue where l2arc_read_done() would always write data to b_pabd, even if raw encrypted data was requested. This only occured in cases where the L2ARC device had a different ashift than the main pool. Signed-off-by: Tom Caputi <tcaputi@datto.com> [PATCH] Make zvol update volsize operation synchronous. There is a race condition when new transaction group is added to dp->dp_dirty_datasets list by the zap_update in the zvol_update_volsize. Meanwhile, before these dirty data are synchronized, the receive process can cause that dmu_recv_end_sync is executed. Then finally dirty data are going to be synchronized but the synchronization ends with the NULL pointer dereference error. Signed-off-by: ab-oe <arkadiusz.bubala@open-e.com> Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> [PATCH] Raw receive fix and encrypted objset security fix This patch fixes two problems with the encryption code. First, the current code does not correctly prohibit the DMU from updating dn_maxblkid during object truncation within a raw receive. This usually only causes issues when the truncating DRR_FREE record is aggregated with DRR_FREE records later in the receive, so it is relatively hard to hit. Second, this patch fixes a security issue where reading blocks within an encrypted object did not guarantee that the dnode block itself had ever been verified against its MAC. Usually the verification happened anyway when the bonus buffer was read, but some use cases (notably zvols) might never perform the check. Signed-off-by: Tom Caputi <tcaputi@datto.com> Raw receive fix and encrypted objset security fix This patch fixes two problems with the encryption code. First, the current code does not correctly prohibit the DMU from updating dn_maxblkid during object truncation within a raw receive. This usually only causes issues when the truncating DRR_FREE record is aggregated with DRR_FREE records later in the receive, so it is relatively hard to hit. Second, this patch fixes a security issue where reading blocks within an encrypted object did not guarantee that the dnode block itself had ever been verified against its MAC. Usually the verification happened anyway when the bonus buffer was read, but some use cases (notably zvols) might never perform the check. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed by: Matthew Ahrens <mahrens@delphix.com> Signed-off-by: Tom Caputi <tcaputi@datto.com> Add ASSERT to debug encryption key mapping issues This patch simply adds an ASSERT that confirms that the last decrypting reference on a dataset waits until the dataset is no longer dirty. This should help to debug issues where the ZIO layer cannot find encryption keys after a dataset has been disowned. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Tom Caputi <tcaputi@datto.com> Fix coverity defects: CID 176037 CID 176037: Uninitialized scalar variable This patch fixes an uninitialized variable defect caught by coverity and introduced in 69830602 Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Tom Caputi <tcaputi@datto.com> ZFS send fails to dump objects larger than 128PiB When dumping objects larger than 128PiB it's possible for do_dump() to miscalculate the FREE_RECORD offset due to an integer overflow condition: this prevents the receiving end from correctly restoring the dumped object. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com> Signed-off-by: loli10K <ezomori.nozomu@gmail.com> Fix hash_lock / keystore.sk_dk_lock lock inversion The keystore.sk_dk_lock should not be held while performing I/O. Drop the lock when reading from disk and update the code so they the first successful caller adds the key. Improve error handling in spa_keystore_create_mapping_impl(). Reviewed by: Thomas Caputi <tcaputi@datto.com> Reviewed-by: RageLtMan <rageltman@sempervictus> Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Separate the error code for already unloaded key Connected to the future commit: Adopt pyzfs from ClusterHQ from ZOL (85ce3f4fd1). Refactor arc_hdr_realloc_crypt() The arc_hdr_realloc_crypt() function is responsible for converting a "full" arc header to an extended "crypt" header and visa versa. This code was originally written with a bcopy() so that any new members added to arc headers would automatically be included without requiring a code change. However, in practice this (along with small differences in kmem_cache implementations between various platforms) has caused a number of hard-to-find problems in ports to other operating systems. This patch solves this problem by making all member copies explicit and adding ASSERTs for fields that cannot be set during the transfer. It also manually resets the old header after the reallocation is finished so it can be properly reallocated and reused. Signed-off-by: Tom Caputi <tcaputi@datto.com> Do not call dmu_objset_disown twice In the error case. Mimic master branch style. fix error handling in arc_read spill blocks are metadata zfs_receive_one needs to restore keylocation prop
2019-03-05OS-7634 enable zfs-test cliroot zpool_get_002_posJerry Jelinek1-1/+1
Reviewed by: Kody Kantor <kody.kantor@joyent.com> Approved by: Kody Kantor <kody.kantor@joyent.com>
2019-03-05 [illumos-gate merge]Jerry Jelinek10-530/+557
commit 4976ccaaebae1e8ba213109839bf1b777ca7ac4f 10465 loader: uboot cstyle cleanup commit 322b93b95c6010b892ad50c1747f354287692d70 10463 loader: interp_forth.c cstyle cleanup commit 86759c82cd4edf74a2d68314e94f68491103bd09 10461 loader: multiboot2.c cstyle cleanup commit f058bc028c85a5b43c00e710a62da1a9679bdd17 10457 libstand: bzipfs.c cstyle cleanup commit eba02b15d6b41ee3c53be5e158f549044c0d0d4f 10496 uts: NULL pointer error in ip_ndp.c commit 88834f1b9a3f099fd1de381f0b32c6813f620123 10478 setup and cleanup for pool checkpoint tests doesn't run commit dcdeca0a948b9d3139743db085d193c9db8ff2a3 10479 7290 broke slog_014_pos.ksh commit 332b63531e8c203d2f4308b5979fae65f72169d6 10475 fix zfs-test cli_root/zpool_get zpool_get_002_pos test case
2019-03-0510465 loader: uboot cstyle cleanupToomas Soome2-12/+12
Reviewed by: Andy Fiddaman <andy@omniosce.org> Reviewed by: C Fraire <cfraire@me.com> Reviewed by: Gergő Doma <domag02@gmail.com> Approved by: Dan McDonald <danmcd@joyent.com>
2019-03-0510463 loader: interp_forth.c cstyle cleanupToomas Soome1-194/+201
Reviewed by: Andy Fiddaman <andy@omniosce.org> Reviewed by: C Fraire <cfraire@me.com> Reviewed by: Gergő Doma <domag02@gmail.com> Approved by: Dan McDonald <danmcd@joyent.com>
2019-03-0510461 loader: multiboot2.c cstyle cleanupToomas Soome1-53/+52
Reviewed by: Andy Fiddaman <andy@omniosce.org> Reviewed by: C Fraire <cfraire@me.com> Reviewed by: Gergő Doma <domag02@gmail.com> Approved by: Dan McDonald <danmcd@joyent.com>
2019-03-0510457 libstand: bzipfs.c cstyle cleanupToomas Soome1-265/+282
Reviewed by: Andy Fiddaman <andy@omniosce.org> Reviewed by: C Fraire <cfraire@me.com> Reviewed by: Gergő Doma <domag02@gmail.com> Approved by: Dan McDonald <danmcd@joyent.com>
2019-03-0510496 uts: NULL pointer error in ip_ndp.cToomas Soome1-1/+1
Reviewed by: Gergő Doma <domag02@gmail.com> Reviewed by: C Fraire <cfraire@me.com> Approved by: Dan McDonald <danmcd@joyent.com>
2019-03-0410478 setup and cleanup for pool checkpoint tests doesn't runAndrew Stormont2-4/+2
Reviewed by: Serapheim Dimitropoulos <serapheim.dimitro@delphix.com> Reviewed by: John Kennedy <john.kennedy@delphix.com> Approved by: Dan McDonald <danmcd@joyent.com>
2019-03-0410479 7290 broke slog_014_pos.kshAndrew Stormont1-1/+2
Reviewed by: Matt Ahrens <matt@delphix.com> Reviewed by: John Kennedy <john.kennedy@delphix.com> Approved by: Dan McDonald <danmcd@joyent.com>
2019-03-0410475 fix zfs-test cli_root/zpool_get zpool_get_002_pos test caseJerry Jelinek1-1/+6
Reviewed by: Igor Kozhukhov <igor@dilos.org> Reviewed by: John Kennedy <john.kennedy@delphix.com> Approved by: Dan McDonald <danmcd@joyent.com>
2019-03-04OS-7630 elfexec() should keep to unsigned types when processing PT_DYNAMICCody Peter Mello1-15/+21
Reviewed by: Richard Lowe <richlowe@richlowe.net> Reviewed by: Patrick Mooney <patrick.mooney@joyent.com> Approved by: Dan McDonald <danmcd@joyent.com>
2019-03-04 [illumos-gate merge]Jerry Jelinek29-185/+424
commit 946342a260bbae359b48bf142ec1fe40792ee862 10452 ZoL: merge in large dnode feature fixes commit 1c802681fb0b5558958cd6f33bf56789a1b0ef29 10474 OS uuid string should not refer to Solaris. commit 42c5ef032d8316897a2ba9f9ebf4b9c2654ec345 10472 Limit number of multicast NCEs commit 573f5931ffa70de78fc2317b82e36d6344cf6c3c 10459 libstand: stand.h cstyle cleanup commit 3ae1c8196586c672e19cabdeaf43e82e5b5dc7f5 10464 loader: biosdisk.c cstyle cleanup commit f6760972b5c27d37b896ac15627645717ee70ddf 10460 loader: tem.c cstyle cleanup commit 3733333274b54097fa204d12dc30b5b6066d05bb 10458 libstand: assert.c cstyle cleanup commit a40552eda738f8ee0c3efd672257d52bfb3e8893 10456 libstand: arp.c cstyle cleanup commit 736e6700391d17ab1494985a80076fc185722699 10473 zfs(1M) missing cross-reference to zfs-program(1M) commit 92c1a61163ff6a0655b27bd429856e171e7ce5f5 10468 __ctype_mask[EOF] has been working by accident 10469 GCC's -faggressive-loop-optimizations is too aggressive 10470 array over-read in has_saved_fp()
2019-03-0310452 ZoL: merge in large dnode feature fixesFabian Grünbichler15-10/+249
Portions contributed by: Ned Bass <bass6@llnl.gov> Portions contributed by: Tom Caputi <tcaputi@datto.com> Reviewed by: Giuseppe Di Natale <guss80@gmail.com> Reviewed by: Alek Pinchuk <apinchuk@datto.com> Reviewed by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed by: Paul Dagnelie <pcd@delphix.com> Reviewed by: George Melikov <mail@gmelikov.ru> Reviewed by: Giuseppe Di Natale <dinatale2@llnl.gov> Reviewed by: Toomas Soome <toomas@me.com> Reviewed by: Andy Fiddaman <andy@omniosce.org> Reviewed by: Gergő Mihály Doma <domag02@gmail.com> Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com> Approved by: Joshua M. Clulow <josh@sysmgr.org>
2019-03-0310474 OS uuid string should not refer to Solaris.Luca Minoja1-1/+1
Reviewed by: Toomas Soome <tsoome@me.com> Reviewed by: Andy Stormont <astormont@racktopsystems.com> Reviewed by: Peter Tribble <peter.tribble@gmail.com> Reviewed by: Andy Fiddaman <andy@omniosce.org> Approved by: Dan McDonald <danmcd@joyent.com>
2019-03-0210472 Limit number of multicast NCEsDan McDonald8-30/+313
Reviewed by: Cody Peter Mello <melloc@writev.io> Reviewed by: Jason King <jason.king@joyent.com> Reviewed by: Robert Mustacchi <rm@joyent.com> Reviewed by: Richard Lowe <richlowe@richlowe.net> Approved by: Joshua M. Clulow <josh@sysmgr.org>
2019-03-0110459 libstand: stand.h cstyle cleanupToomas Soome1-95/+101
Reviewed by: Andy Fiddaman <andy@omniosce.org> Reviewed by: Gergő Doma <domag02@gmail.com> Approved by: Dan McDonald <danmcd@joyent.com>
2019-03-0110464 loader: biosdisk.c cstyle cleanupToomas Soome1-23/+23
Reviewed by: Rob Johnston <rob.johnston@joyent.com> Reviewed by: Andy Fiddaman <andy@omniosce.org> Approved by: Dan McDonald <danmcd@joyent.com>
2019-03-0110460 loader: tem.c cstyle cleanupToomas Soome1-5/+7
Reviewed by: Gergő Doma <domag02@gmail.com> Reviewed by: Andy Fiddaman <andy@omniosce.org> Approved by: Dan McDonald <danmcd@joyent.com>
2019-03-0110458 libstand: assert.c cstyle cleanupToomas Soome1-2/+1
Reviewed by: Andy Fiddaman <andy@omniosce.org> Reviewed by: Gergő Doma <domag02@gmail.com> Approved by: Dan McDonald <danmcd@joyent.com>
2019-03-0110456 libstand: arp.c cstyle cleanupToomas Soome1-36/+31
Reviewed by: C Fraire <cfraire@me.com> Reviewed by: Andy Fiddaman <andy@omniosce.org> Reviewed by: Gergő Doma <domag02@gmail.com> Approved by: Dan McDonald <danmcd@joyent.com>
2019-03-0110473 zfs(1M) missing cross-reference to zfs-program(1M)Jason King1-3/+4
Reviewed by: Toomas Soome <tsoome@me.com> Reviewed by: Andy Fiddaman <andy@omniosce.org> Reviewed by: Peter Tribble <peter.tribble@gmail.com> Reviewed by: Gergő Mihály Doma <domag02@gmail.com> Approved by: Dan McDonald <danmcd@joyent.com>
2019-03-01OS-7564 panic in mac_hw_emul()Ryan Zezeski1-1/+11
Reviewed by: Robert Mustacchi <rm@joyent.com> Approved by: Jason King <jason.king@joyent.com>
2019-03-01 [illumos-gate merge]Jerry Jelinek3-17/+59
commit 6d3b6de806befb1050c80e5d4be2214ee68fb2b7 10462 nightly errors - libmakestate.so.1: open failed commit 18ce2efc2fad1ecfa25d6faac23d49fb479d2f00 10386 pbchk should catch capitalised "illumos" 10387 pbchk should check commit message spelling
2019-03-0110468 __ctype_mask[EOF] has been working by accidentBryan Cantrill5-24/+42
10469 GCC's -faggressive-loop-optimizations is too aggressive 10470 array over-read in has_saved_fp() Reviewed by: Robert Mustacchi <rm@joyent.com> Reviewed by: John Levon <john.levon@joyent.com> Reviewed by: Toomas Soome <tsoome@me.com> Reviewed by: Igor Kozhukhov <igor@dilos.org> Reviewed by: Andy Fiddaman <andy@omniosce.org> Reviewed by: Gergő Doma <domag02@gmail.com> Reviewed by: Gary Mills <gary_mills@fastmail.fm> Approved by: Richard Lowe <richlowe@richlowe.net>
2019-03-0110462 nightly errors - libmakestate.so.1: open failedAndy Fiddaman1-1/+12
Reviewed by: Gergő Mihály Doma <domag02@gmail.com> Reviewed by: Jason King <jason.king@joyent.com> Reviewed by: Toomas Soome <tsoome@me.com> Approved by: Dan McDonald <danmcd@joyent.com>