Page MenuHomeFreeBSD

uipc_bindat(): Explicitly specify exclusive locking for the new vnode
ClosedPublic

Authored by jah on Feb 23 2024, 5:55 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, May 13, 11:11 PM
Unknown Object (File)
Mon, May 13, 7:56 PM
Unknown Object (File)
Mon, May 13, 2:55 PM
Unknown Object (File)
Mon, May 13, 1:32 PM
Unknown Object (File)
Mon, May 13, 1:06 PM
Unknown Object (File)
Fri, May 10, 5:28 PM
Unknown Object (File)
Apr 26 2024, 3:39 AM
Unknown Object (File)
Apr 22 2024, 11:10 AM
Subscribers

Details

Summary

When calling VOP_CREATE(), uipc_bindat() reuses the componentname
object from the preceding lookup operation, which is likely to specify
LK_SHARED. Furthermore, the VOP_CREATE() interface technically only
requires the newly-created vnode to be returned with a shared lock.
However, the socket layer requires the new vnode to be locked exclusive
and asserts to that effect.

In most cases, this is not a practical concern because most if not
all base-layer filesystems (certainly FFS, ZFS, and msdosfs at least)
always return the vnode locked exclusive regardless of the lock flags.
However, it is an issue for unionfs which uses cn_lkflags to determine
how the new unionfs wrapper vnode should be locked. While it would
be easy enough to work around this issue within unionfs itself, it
seems better for the socket layer to be explicit about its locking
requirements when issuing VOP_CREATE().

Diff Detail

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

Event Timeline

jah requested review of this revision.Feb 23 2024, 5:55 PM

This is needed for upcoming work to adopt VOP_UNP_* in unionfs.

sys/kern/uipc_usrreq.c
606

Fine. I just would prefer to use ~LK_SHARED instead. IIRC, cn_lkflags is not supposed to contain anything else than LK_SHARED or LK_EXCLUSIVE (we should probably assert that at several other places).

This revision is now accepted and ready to land.Feb 24 2024, 12:02 AM