Page MenuHomeFreeBSD

vfs: avoid exposing partially constructed vnodes
ClosedPublic

Authored by chs on Sep 1 2020, 11:11 PM.
Tags
None
Referenced Files
Unknown Object (File)
Dec 14 2023, 12:17 PM
Unknown Object (File)
Sep 3 2023, 6:20 AM
Unknown Object (File)
Sep 3 2023, 6:19 AM
Unknown Object (File)
Sep 3 2023, 6:13 AM
Unknown Object (File)
Aug 28 2023, 9:07 AM
Unknown Object (File)
Jul 5 2023, 9:10 AM
Unknown Object (File)
Jun 27 2023, 7:15 PM
Unknown Object (File)
Jun 27 2023, 7:13 PM
Subscribers

Details

Summary

If multiple threads race calling vfs_hash_insert() while creating vnodes
with the same identity, all of the vnodes which lose the race must be
destroyed before any other thread can see them. Previously this was
accomplished by the vput() in vfs_hash_insert() resulting in the vnode's
VOP_INACTIVE() method calling vgone() before the vnode lock was unlocked,
but recent changes to the the vnode refcount/inactive logic cause that
to not work anymore, so instead vfs_hash_insert() must call vgone() itself
before calling vput() on vnodes which lose the race.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

chs requested review of this revision.Sep 1 2020, 11:11 PM

I strongly suspect this broke few years back.

I have a WIP patch to address this in a systematic manner. In the meantime this definitely should go in.

This revision is now accepted and ready to land.Sep 1 2020, 11:16 PM
kib added inline comments.
sys/kern/vfs_hash.c
171 ↗(On Diff #76522)

Somewhat unrelated: this break look strange, it terminates internal loop but while(1) just continues. I think we should return there instead.

This revision was automatically updated to reflect the committed changes.