summaryrefslogtreecommitdiffstats
path: root/module/zfs/sa.c
diff options
context:
space:
mode:
authorNathaniel Clark <[email protected]>2018-06-07 12:51:56 -0400
committerBrian Behlendorf <[email protected]>2018-06-07 09:51:56 -0700
commitfba33c3819761487a75c8f1307482959105a6269 (patch)
treeca99a530f5b96e28d1ba60ab55c58f7c414816b0 /module/zfs/sa.c
parent7106b23640e8fba33df09b160f366918dcb79021 (diff)
Don't panic on bad SA_MAGIC in sa_build_index
If sa_build_index() encounters a corrupt buffer, don't panic. Add info to zfs ring buffer and return EIO. This allows for a cleaner error recovery path. Reviewed-by: Brian Behlendorf <[email protected]> Reviewed by: Matthew Ahrens <[email protected]> Signed-off-by: Nathaniel Clark <[email protected]> Issue #6500 Closes #7487
Diffstat (limited to 'module/zfs/sa.c')
-rw-r--r--module/zfs/sa.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/module/zfs/sa.c b/module/zfs/sa.c
index 75f7f8d96..0ca33e80d 100644
--- a/module/zfs/sa.c
+++ b/module/zfs/sa.c
@@ -1284,7 +1284,13 @@ sa_build_index(sa_handle_t *hdl, sa_buf_type_t buftype)
/* only check if not old znode */
if (IS_SA_BONUSTYPE(bonustype) && sa_hdr_phys->sa_magic != SA_MAGIC &&
sa_hdr_phys->sa_magic != 0) {
- VERIFY(BSWAP_32(sa_hdr_phys->sa_magic) == SA_MAGIC);
+ if (BSWAP_32(sa_hdr_phys->sa_magic) != SA_MAGIC) {
+ mutex_exit(&sa->sa_lock);
+ zfs_dbgmsg("Buffer Header: %x != SA_MAGIC:%x "
+ "object=%#llx\n", sa_hdr_phys->sa_magic, SA_MAGIC,
+ db->db.db_object);
+ return (SET_ERROR(EIO));
+ }
sa_byteswap(hdl, buftype);
}