HomeFreeBSD

unionfs: fix potential deadlock in VOP_RMDIR

Description

unionfs: fix potential deadlock in VOP_RMDIR

VOP_RMDIR() is called with both parent and child directory vnodes
locked. The relookup operation performed by the unionfs implementation
may relock both vnodes. Accordingly, unionfs_relookup() drops the
parent vnode lock, but the child vnode lock is never dropped.
Although relookup() will very likely try to relock the child vnode
which is already locked, in most cases this doesn't produce a deadlock
because unionfs_lock() forces LK_CANRECURSE (!). However, relocking
of the parent vnode while the child vnode remains locked effectively
reverses the expected parent->child lock order, which can produce
a deadlock e.g. in the presence of a concurrent unionfs_lookup()
operation. Address the issue by dropping the child lock around
the unionfs_relookup() call in unionfs_rmdir().

Reported by: pho
Reviewed by: kib, markj
Differential Revision: https://reviews.freebsd.org/D32986

Details

Provenance
jahAuthored on Nov 14 2021, 7:28 AM
Reviewer
kib
Differential Revision
D32986: unionfs: fix potential deadlock in VOP_RMDIR
Parents
rG8660813153d0: start_init: use 'p'
Branches
Unknown
Tags
Unknown