HomeFreeBSD

nullfs: Fix handling of doomed vnodes in nullfs_unlink_lowervp()

Description

nullfs: Fix handling of doomed vnodes in nullfs_unlink_lowervp()

nullfs_unlink_lowervp() is called with the lower vnode locked, so the
nullfs vnode is locked too. The following can occur:

  1. the vunref() call decrements the usecount 2->1,
  2. a different thread calls vrele() on the vnode, decrements the usecount 0->1, then blocks on the vnode lock,
  3. the first thread tests vp->v_usecount == 0 and observes that it is true,
  4. the first thread incorrectly unlocks the lower vnode.

Fix this by testing VN_IS_DOOMED directly. Since
nullfs_unlink_lowervp() holds the vnode lock, the value of the
VIRF_DOOMED flag is stable.

Thanks to leres@ for patiently helping to track this down.

PR: 288345
MFC after: 1 week
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D55446

Details

Provenance
markjAuthored on Feb 25 2026, 3:31 PM
Reviewer
kib
Differential Revision
D55446: nullfs: Fix handling of doomed vnodes in nullfs_unlink_lowervp()
Parents
rGf3364d3c8c87: tcp: improve handling of segments in TIME WAIT
Branches
Unknown
Tags
Unknown