freebsd-dev/sys/ufs/ffs
Konstantin Belousov c0d2077f41 Add a framework that tracks exclusive vnode lock generation count for UFS.
This count is memoized together with the lookup metadata in directory
inode, and we assert that accesses to lookup metadata are done under
the same lock generation as they were stored.  Enabled under DIAGNOSTICS.

UFS saves additional data for parent dirent when doing lookup
(i_offset, i_count, i_endoff), and this data is used later by VOPs
operating on dirents.  If parent vnode exclusive lock is dropped and
re-acquired between lookup and the VOP call, we corrupt directories.

Framework asserts that corruption cannot occur that way, by tracking
vnode lock generation counter.  Updates to inode dirent members also
save the counter, while users compare current and saved counters
values.

Also, fix a case in ufs_lookup_ino() where i_offset and i_count could
be updated under shared lock.  It is not a bug on its own since dvp
i_offset results from such lookup cannot be used, but it causes false
positive in the checker.

In collaboration with:	pho
Reviewed by:	mckusick (previous version), markj
Tested by:	markj (syzkaller), pho
Sponsored by:	The FreeBSD Foundation
Differential revision:	https://reviews.freebsd.org/D26136
2020-11-14 05:17:04 +00:00
..
ffs_alloc.c Add a framework that tracks exclusive vnode lock generation count for UFS. 2020-11-14 05:10:39 +00:00
ffs_balloc.c ufs: clean up empty lines in .c and .h files 2020-09-01 21:23:00 +00:00
ffs_extern.h ufs: clean up empty lines in .c and .h files 2020-09-01 21:23:00 +00:00
ffs_inode.c Add a framework that tracks exclusive vnode lock generation count for UFS. 2020-11-14 05:17:04 +00:00
ffs_rawread.c vmapbuf: don't smuggle address or length in buf 2020-10-21 16:00:15 +00:00
ffs_snapshot.c Move the pointers stored in the superblock into a separate 2020-06-19 01:02:53 +00:00
ffs_softdep.c Add a framework that tracks exclusive vnode lock generation count for UFS. 2020-11-14 05:10:39 +00:00
ffs_subr.c Various new check-hash checks have been added to the UFS filesystem 2020-10-25 00:43:48 +00:00
ffs_suspend.c Drop "All rights reserved" from all my stuff. This includes 2020-10-28 13:46:11 +00:00
ffs_tables.c sys: further adoption of SPDX licensing ID tags. 2017-11-20 19:43:44 +00:00
ffs_vfsops.c Add a framework that tracks exclusive vnode lock generation count for UFS. 2020-11-14 05:10:39 +00:00
ffs_vnops.c Add a framework that tracks exclusive vnode lock generation count for UFS. 2020-11-14 05:10:39 +00:00
fs.h Various new check-hash checks have been added to the UFS filesystem 2020-10-25 00:43:48 +00:00
softdep.h This commit enables a UFS filesystem to do a forcible unmount when 2020-05-25 23:47:31 +00:00