summaryrefslogtreecommitdiffstats
path: root/module/zfs/zap.c
diff options
context:
space:
mode:
authorChunwei Chen <[email protected]>2016-03-25 15:21:56 -0400
committerBrian Behlendorf <[email protected]>2016-05-10 10:38:21 -0700
commit32c8c946ea3228de86946fdd637c85eeeff1726a (patch)
treed761c4db5c8d034c3a25f5c2c7e6b4a104128317 /module/zfs/zap.c
parentb3744ae611a1920aa37b44aa3b37f02c7f23a5ba (diff)
OpenZFS 6842 - Fix empty xattr dir causing lockup
Reviewed by: Brian Behlendorf <[email protected]> Reviewed by: Dan McDonald <[email protected]> Reviewed by: Matthew Ahrens <[email protected]> Approved by: Robert Mustacchi <[email protected]> Ported-by: Denys Rtveliashvili <[email protected]> Signed-off-by: Brian Behlendorf <[email protected]> An initial version of this patch was applied in commit 29572cc and subsequently refined upstream. Since the implementations do not conflict with each other both are left applied for now. OpenZFS-issue: https://www.illumos.org/issues/6842 OpenZFS-commit: https://github.com/openzfs/openzfs/commit/02525cd Closes #4615
Diffstat (limited to 'module/zfs/zap.c')
-rw-r--r--module/zfs/zap.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/module/zfs/zap.c b/module/zfs/zap.c
index 9d06cce74..454b4be62 100644
--- a/module/zfs/zap.c
+++ b/module/zfs/zap.c
@@ -585,7 +585,13 @@ zap_deref_leaf(zap_t *zap, uint64_t h, dmu_tx_t *tx, krw_t lt, zap_leaf_t **lp)
ASSERT(zap->zap_dbuf == NULL ||
zap_f_phys(zap) == zap->zap_dbuf->db_data);
- ASSERT3U(zap_f_phys(zap)->zap_magic, ==, ZAP_MAGIC);
+
+ /* Reality check for corrupt zap objects (leaf or header). */
+ if ((zap_f_phys(zap)->zap_block_type != ZBT_LEAF &&
+ zap_f_phys(zap)->zap_block_type != ZBT_HEADER) ||
+ zap_f_phys(zap)->zap_magic != ZAP_MAGIC) {
+ return (SET_ERROR(EIO));
+ }
idx = ZAP_HASH_IDX(h, zap_f_phys(zap)->zap_ptrtbl.zt_shift);
err = zap_idx_to_blk(zap, idx, &blk);
if (err != 0)