HomeFreeBSD

unionfs: detect common deadlock-producing mount misconfigurations

Description

unionfs: detect common deadlock-producing mount misconfigurations

When creating a unionfs mount, it's fairly easy to shoot oneself
in the foot by specifying upper and lower file hierarchies that
resolve back to the same vnodes. This is fairly easy to do if
the sameness is not obvious due to aliasing through nullfs or other
unionfs mounts (as in the associated PR), and will produce either
deadlock or failed locking assertions on any attempt to use the
resulting unionfs mount.

Leverage VOP_GETLOWVNODE() to detect the most common cases of
foot-shooting at mount time and fail the mount with EDEADLK.
This is not meant to be an exhaustive check for all possible
deadlock-producing scenarios, but it is an extremely cheap and
simple approach that, unlike previous proposed fixes, also works
in the presence of nullfs aliases.

PR: 172334
Reported by: ngie, Karlo Miličević <karlo98.m@gmail.com>
Reviewed by: kib, olce
Tested by: pho
Differential Revision: https://reviews.freebsd.org/D53988

(cherry picked from commit 0247b4018de2c341ac59a585362c10044cea86ad)

Details

Provenance
jahAuthored on Nov 29 2025, 7:53 AM
Reviewer
kib
Differential Revision
D53988: unionfs: Implement VOP_GETLOWVNODE and employ it for basicmount-time deadlock detection
Parents
rG177e0097b93f: unionfs: Implement VOP_GETLOWVNODE
Branches
Unknown
Tags
Unknown