From bfbf739aad507d8e1f4f78a8cb4760c2731a043b Mon Sep 17 00:00:00 2001 From: mckusick Date: Sat, 15 Dec 2018 18:49:30 +0000 Subject: [PATCH] Ensure that the inode check-hash is not left zeroed out in the case where the check-hash fails. Prior to the fix in -r342133 the inode with the zeroed out check-hash was written back to disk causing further confusion. Reported by: Gary Jennejohn (gj) Sponsored by: Netflix --- sys/ufs/ffs/ffs_subr.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/sys/ufs/ffs/ffs_subr.c b/sys/ufs/ffs/ffs_subr.c index 89efe2df434..b284cbf41f6 100644 --- a/sys/ufs/ffs/ffs_subr.c +++ b/sys/ufs/ffs/ffs_subr.c @@ -161,7 +161,7 @@ ffs_load_inode(struct buf *bp, struct inode *ip, struct fs *fs, ino_t ino) int ffs_verify_dinode_ckhash(struct fs *fs, struct ufs2_dinode *dip) { - uint32_t save_ckhash; + uint32_t ckhash, save_ckhash; /* * Return success if unallocated or we are not doing inode check-hash. @@ -174,10 +174,11 @@ ffs_verify_dinode_ckhash(struct fs *fs, struct ufs2_dinode *dip) */ save_ckhash = dip->di_ckhash; dip->di_ckhash = 0; - if (save_ckhash != calculate_crc32c(~0L, (void *)dip, sizeof(*dip))) - return (EINVAL); + ckhash = calculate_crc32c(~0L, (void *)dip, sizeof(*dip)); dip->di_ckhash = save_ckhash; - return (0); + if (save_ckhash == ckhash) + return (0); + return (EINVAL); } /* -- 2.45.0