Page MenuHomeFreeBSD

unix: pin the pathname peer by reference across the connect
Needs ReviewPublic

Authored by inquire_JohnEricson.me on Sat, Jul 25, 8:22 PM.
Tags
None
Referenced Files
F164769376: D58460.diff
Mon, Aug 3, 9:00 PM
F164764711: D58460.diff
Mon, Aug 3, 7:47 PM
F164763507: D58460.diff
Mon, Aug 3, 7:26 PM
F164762216: D58460.diff
Mon, Aug 3, 7:03 PM
Unknown Object (File)
Sun, Aug 2, 10:58 PM
Unknown Object (File)
Sat, Aug 1, 8:41 AM
Unknown Object (File)
Sat, Aug 1, 6:14 AM
Unknown Object (File)
Sat, Aug 1, 12:49 AM
Subscribers

Details

Reviewers
markj
kib
Summary

In the pathname path of unp_connectat(), take a reference on the peer
socket under the per-vnode unp_vp_mtxpool lock, drop that lock, and
vput() the vnode *before* calling unp_connect_peer(), rather than
holding the vnode lock across the connect.

unp_connect_peer() already accepts "a reference on the peer socket" as
a stability guarantee (it is exactly what the descriptor path relies on),
so this is behaviour-preserving. The payoff is that no vnode lock is held
across the connect, which removes the delicate `MPASS(!(return_locked &&
connreq))` "vput() must not sleep while the peer is locked" invariant on
the datagram fast path.

That reference then has to be released, and for the reasons described in
the code, this can only safely happen *after* the PCB is unlocked. The
boolean flag is replaced with a nullable out pointer to return the
reference to the caller so that it can carry out this responsibility.

No functional change intended.

Signed-off-by: John Ericson <John.Ericson@Obsidian.Systems>
Assisted-by: Claude Code (Claude Opus 4.8 and Fable 5)

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
No Test Coverage
Build Status
Buildable 75133
Build 72016: arc lint + arc unit