Page MenuHomeFreeBSD

autofs_lookup(): busy the mount point around autofs_trigger()
ClosedPublic

Authored by kib on Aug 3 2026, 5:45 PM.
Tags
None
Referenced Files
F170096936: D58626.diff
Thu, Sep 3, 12:18 PM
Unknown Object (File)
Wed, Sep 2, 10:10 AM
Unknown Object (File)
Wed, Sep 2, 1:55 AM
Unknown Object (File)
Sun, Aug 30, 5:01 AM
Unknown Object (File)
Sat, Aug 29, 8:08 PM
Unknown Object (File)
Sat, Aug 29, 3:03 PM
Unknown Object (File)
Thu, Aug 27, 11:02 PM
Unknown Object (File)
Thu, Aug 27, 11:00 PM
Subscribers

Details

Summary
Since autofs_lookup() calls into autofs_trigger_vn() to perform
automounting, and autofs_trigger_vn() unlocks the vnode, it is possible
for the unmount to start meantime.  Then autofs_trigger() accesses freed
memory.

At this point, busy can be only done unblocking, and the transient
failure must abort the trigger operation.  This would cause spurious
automounter errors, but at least should prevent accesses to the freed
memory.

PR:     294361
Tested by: rew

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

kib requested review of this revision.Aug 3 2026, 5:45 PM
kib retitled this revision from autofs: busy the mount point around autofs_trigger() to autofs_lookup(): busy the mount point around autofs_trigger().Aug 3 2026, 5:56 PM
sys/fs/autofs/autofs_vnops.c
144–149

Does this comment describe a desired (but not correct) behaviour of the old code (and if so is it more wrong now)?

kib marked an inline comment as done.Aug 3 2026, 7:38 PM
kib added inline comments.
sys/fs/autofs/autofs_vnops.c
144–149

Yes, it does describes the intent. Old code was unsufficient because vref-ed vnode does not prevent forced unmount.

I updated the comment.

kib marked an inline comment as done.

List the busy action in the comment about unlocking.

kib added reviewers: rew, jah, markj.
rew added inline comments.
sys/fs/autofs/autofs_vnops.c
146
169

I have a related question that is not specific to this review..

what do you think about the idea of not referencing the autofs node while the vnode is unlocked? I ask because I've got a couple patches that work towards that idea but I have not finished it.

this is an area of code that will need to be addressed to handle autofs node removal

This revision is now accepted and ready to land.Aug 3 2026, 11:29 PM
kib marked 2 inline comments as done.Aug 4 2026, 6:26 AM
kib added inline comments.
sys/fs/autofs/autofs_vnops.c
169

What do you mean by 'referencing the node'? Do you mean vref-ing the vnode instead? I think this is trivially fine, since vp must be referenced by vfs_lookup() when calling into VOP_LOOKUP().

This revision was automatically updated to reflect the committed changes.
kib marked an inline comment as done.