git: 17a82e6af8e2 - main - Fix vnode locking bug in fuse_vnop_copy_file_range

Alan Somers asomers at FreeBSD.org
Sun Jan 3 18:19:50 UTC 2021


The branch main has been updated by asomers:

URL: https://cgit.FreeBSD.org/src/commit/?id=17a82e6af8e2bde543c9c2fbe3ce296d5b24ddc9

commit 17a82e6af8e2bde543c9c2fbe3ce296d5b24ddc9
Author:     Alan Somers <asomers at FreeBSD.org>
AuthorDate: 2021-01-01 20:49:30 +0000
Commit:     Alan Somers <asomers at FreeBSD.org>
CommitDate: 2021-01-03 18:16:20 +0000

    Fix vnode locking bug in fuse_vnop_copy_file_range
    
    MFC-With:       92bbfe1f0d1f1c4436d1f064a16e5aaf682526ba
    Reviewed by:    cem
    Differential Revision:  https://reviews.freebsd.org/D27938
---
 sys/fs/fuse/fuse_vnops.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/sys/fs/fuse/fuse_vnops.c b/sys/fs/fuse/fuse_vnops.c
index f26f96b8be99..5bbde1e278c9 100644
--- a/sys/fs/fuse/fuse_vnops.c
+++ b/sys/fs/fuse/fuse_vnops.c
@@ -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;


More information about the dev-commits-src-all mailing list