path: root/sbin/fsirand/fsirand.c
diff options
authorKirk McKusick <mckusick@FreeBSD.org>2018-12-11 22:14:37 +0000
committerKirk McKusick <mckusick@FreeBSD.org>2018-12-11 22:14:37 +0000
commit8f829a5cf0fa341a95fd4bed7091d6c44129d68f (patch)
tree2cb40f5c8c0521451556577ffdfcd8b8aeb90861 /sbin/fsirand/fsirand.c
parentd3cc40300eaa672ce8f7d1782454267d3ea15dfb (diff)
Continuing efforts to provide hardening of FFS. This change adds a
check hash to the filesystem inodes. Access attempts to files associated with an inode with an invalid check hash will fail with EINVAL (Invalid argument). Access is reestablished after an fsck is run to find and validate the inodes with invalid check-hashes. This check avoids a class of filesystem panics related to corrupted inodes. The hash is done using crc32c. Note this check-hash is for the inode itself and not any of its indirect blocks. Check-hash validation may be extended to also cover indirect block pointers, but that will be a separate (and more costly) feature. Check hashes are added only to UFS2 and not to UFS1 as UFS1 is primarily used in embedded systems with small memories and low-powered processors which need as light-weight a filesystem as possible. Reviewed by: kib Tested by: Peter Holm Sponsored by: Netflix
Notes: svn path=/head/; revision=341836
Diffstat (limited to 'sbin/fsirand/fsirand.c')
1 files changed, 1 insertions, 0 deletions
diff --git a/sbin/fsirand/fsirand.c b/sbin/fsirand/fsirand.c
index 8675f7c3fd33..f24d34705b72 100644
--- a/sbin/fsirand/fsirand.c
+++ b/sbin/fsirand/fsirand.c
@@ -202,6 +202,7 @@ fsirand(char *device)
} else {
dp2->di_gen = arc4random();
+ ffs_update_dinode_ckhash(sblock, dp2);