git: 0ea5e0c7ee26 - stable/13 - fuse_vnop_copy_file_range(): add safety

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Thu, 23 Nov 2023 04:02:35 UTC
The branch stable/13 has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=0ea5e0c7ee262f0d1178b6ca4871ab353e3aa0e3

commit 0ea5e0c7ee262f0d1178b6ca4871ab353e3aa0e3
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2023-11-14 22:49:35 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2023-11-23 04:02:00 +0000

    fuse_vnop_copy_file_range(): add safety
    
    (cherry picked from commit 4c6cded2166111079c6b5e8b2353171dcc7ed0c4)
---
 sys/fs/fuse/fuse_vnops.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sys/fs/fuse/fuse_vnops.c b/sys/fs/fuse/fuse_vnops.c
index 0b683a7c63bd..6871461d26f1 100644
--- a/sys/fs/fuse/fuse_vnops.c
+++ b/sys/fs/fuse/fuse_vnops.c
@@ -862,7 +862,7 @@ fuse_vnop_copy_file_range(struct vop_copy_file_range_args *ap)
 	pid_t pid;
 	int err;
 
-	if (mp != vnode_mount(outvp))
+	if (mp == NULL || mp != vnode_mount(outvp))
 		goto fallback;
 
 	if (incred->cr_uid != outcred->cr_uid)
@@ -871,6 +871,7 @@ fuse_vnop_copy_file_range(struct vop_copy_file_range_args *ap)
 	if (incred->cr_groups[0] != outcred->cr_groups[0])
 		goto fallback;
 
+	/* Caller busied mp, mnt_data can be safely accessed. */
 	if (fsess_not_impl(mp, FUSE_COPY_FILE_RANGE))
 		goto fallback;