]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
ufs rename: ensure that the result of ufs_checkpath() is stable
authorKonstantin Belousov <kib@FreeBSD.org>
Fri, 6 Aug 2021 01:03:19 +0000 (04:03 +0300)
committerKonstantin Belousov <kib@FreeBSD.org>
Fri, 13 Aug 2021 14:52:26 +0000 (17:52 +0300)
commit8df4bc48c89a1302078282f22139a8368dc06971
tree44a4e1505cb2f8564987edb8da44cc76dbe8b670
parent2e2212b4f55f307ed814cbe1ea633c32faea4a9c
ufs rename: ensure that the result of ufs_checkpath() is stable

ufs_rename() calls ufs_checkpath() to ensure that the target directory
is not a child of the source.  If not, rename would create a loop.
For instance:
source->X1->X2->target
and if source moved under target, we get corrupted filesystem.
Suppose that we initially have
source->X1 .... and X2->target
where X1 is not on path from root to X2.  Then ufs_checkpath() accepts
the inodes, but there is nothing preventing parallel rename of X2 to become
under X1, after checkpath finished.

Ensure stability of ufs_checkpath() result by taking a per-mount sx in
ufs_rename right before ufs_checkpath() and till the end.

Reviewed by: chs, mckusick
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
sys/ufs/ffs/ffs_vfsops.c
sys/ufs/ufs/ufs_lookup.c
sys/ufs/ufs/ufs_vnops.c
sys/ufs/ufs/ufsmount.h