Fix vnode locking bug in fuse_vnop_copy_file_range

MFC-With:	92bbfe1f0d
Reviewed by:	cem
Differential Revision:	https://reviews.freebsd.org/D27938
This commit is contained in:
Alan Somers 2021-01-01 13:49:30 -07:00
parent 845b273728
commit 17a82e6af8

View File

@ -664,14 +664,6 @@ fuse_vnop_copy_file_range(struct vop_copy_file_range_args *ap)
td = ap->a_fsizetd;
pid = td->td_proc->p_pid;
err = fuse_filehandle_getrw(invp, FREAD, &infufh, incred, pid);
if (err)
return (err);
err = fuse_filehandle_getrw(outvp, FWRITE, &outfufh, outcred, pid);
if (err)
return (err);
/* Lock both vnodes, avoiding risk of deadlock. */
do {
err = vn_lock(outvp, LK_EXCLUSIVE);
@ -690,6 +682,14 @@ fuse_vnop_copy_file_range(struct vop_copy_file_range_args *ap)
if (err != 0)
return (err);
err = fuse_filehandle_getrw(invp, FREAD, &infufh, incred, pid);
if (err)
goto unlock;
err = fuse_filehandle_getrw(outvp, FWRITE, &outfufh, outcred, pid);
if (err)
goto unlock;
if (ap->a_fsizetd) {
io.uio_offset = *ap->a_outoffp;
io.uio_resid = *ap->a_lenp;