HomeFreeBSD

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

Description

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

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().

Reviewed by: kib, olce
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D44047

Details

Provenance
jahAuthored on Feb 3 2024, 5:07 PM
Reviewer
kib
Differential Revision
D44047: uipc_bindat(): Explicitly specify exclusive locking for the new vnode
Parents
rGfa26f46dc29f: vn_lock_pair(): allow lkflags1/lkflags2 to be 0 if vp1/vp2 is NULL
Branches
Unknown
Tags
Unknown