HomeFreeBSD

unionfs: Ensure SAVENAME is set for unionfs vnode operations

Description

unionfs: Ensure SAVENAME is set for unionfs vnode operations

"rm-style" system calls such as kern_frmdirat() and kern_funlinkat()
don't supply SAVENAME to preserve the pathname buffer for subsequent
vnode ops. For unionfs this poses an issue because the pathname may
be needed for a relookup operation in unionfs_remove()/unionfs_rmdir().
Currently unionfs doesn't check for this case, leading to a panic on
DIAGNOSTIC kernels and use-after-free of cn_nameptr otherwise.

The unionfs node's stored buffer would suffice as a replacement for
cnp->cn_nameptr in some (but not all) cases, but it's cleaner to just
ensure that unionfs vnode ops always have a valid cn_nameptr by setting
SAVENAME in unionfs_lookup().

While here, do some light cleanup in unionfs_lookup() and assert that
HASBUF is always present in the relevant relookup calls.

Reported by: pho
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D32148

Details

Provenance
jahAuthored on Sun, Sep 26, 2:56 AM
Reviewer
markj
Differential Revision
D32148: unionfs: Ensure SAVENAME is set for unionfs vnode operations
Parents
R10:04c91ac48ad1: selsocket: handle sopoll() errors correctly
Branches
Unknown
Tags
Unknown