Page MenuHomeFreeBSD

nullfs: Fix handling of doomed vnodes in nullfs_unlink_lowervp()
ClosedPublic

Authored by markj on Sun, Feb 22, 7:07 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Mar 1, 4:16 PM
Unknown Object (File)
Wed, Feb 25, 11:51 PM
Unknown Object (File)
Wed, Feb 25, 8:18 PM
Unknown Object (File)
Wed, Feb 25, 7:45 PM
Unknown Object (File)
Wed, Feb 25, 6:31 PM
Unknown Object (File)
Wed, Feb 25, 3:30 PM
Unknown Object (File)
Wed, Feb 25, 3:25 PM
Unknown Object (File)
Wed, Feb 25, 3:18 PM
Subscribers

Details

Summary

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,
  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.

PR: 288345

Diff Detail

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

Event Timeline

markj requested review of this revision.Sun, Feb 22, 7:07 PM
sys/fs/nullfs/null_vfsops.c
465–466

This comment as is no longer holds.

478–479

This assert is tautological now.

markj marked 2 inline comments as done.

Handle feedback

kib added inline comments.
sys/fs/nullfs/null_vfsops.c
468

I think it is enough to say 'If the vnode is doomed, its lock was split from the lower vnode lock.'

This revision is now accepted and ready to land.Sun, Feb 22, 7:35 PM

Make the comment more terse

This revision now requires review to proceed.Sun, Feb 22, 7:37 PM
This revision is now accepted and ready to land.Sun, Feb 22, 7:39 PM