Page MenuHomeFreeBSD

vfs: avoid exposing partially constructed vnodes
ClosedPublic

Authored by chs on Sep 1 2020, 11:11 PM.

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
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; 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.