Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 28 Apr 2022 21:19:47 GMT
From:      Alan Somers <asomers@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 45825a12f985 - main - fusefs: fix FUSE_CREATE with file handles and fuse protocol < 7.9
Message-ID:  <202204282119.23SLJlF0041476@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by asomers:

URL: https://cgit.FreeBSD.org/src/commit/?id=45825a12f9851213e627cf41398706bacb793f83

commit 45825a12f9851213e627cf41398706bacb793f83
Author:     Alan Somers <asomers@FreeBSD.org>
AuthorDate: 2022-04-28 21:13:09 +0000
Commit:     Alan Somers <asomers@FreeBSD.org>
CommitDate: 2022-04-28 21:13:09 +0000

    fusefs: fix FUSE_CREATE with file handles and fuse protocol < 7.9
    
    Prior to fuse protocol version 7.9, the fuse_entry_out structure had a
    smaller size.  But fuse_vnop_create did not take that into account when
    working with servers that use older protocols.  The bug does not matter
    for servers which don't use file handles or open flags (the only fields
    affected).
    
    PR:             263625
    Submitted by:   Ali Abdallah <ali.abdallah@suse.com>
    MFC after:      2 weeks
---
 sys/fs/fuse/fuse_vnops.c      |  6 +++++-
 tests/sys/fs/fusefs/create.cc | 13 ++++++++-----
 2 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/sys/fs/fuse/fuse_vnops.c b/sys/fs/fuse/fuse_vnops.c
index 4374c854a5be..9ffc8f32c048 100644
--- a/sys/fs/fuse/fuse_vnops.c
+++ b/sys/fs/fuse/fuse_vnops.c
@@ -1042,7 +1042,11 @@ fuse_vnop_create(struct vop_create_args *ap)
 	}
 
 	if (op == FUSE_CREATE) {
-		foo = (struct fuse_open_out*)(feo + 1);
+		if (fuse_libabi_geq(data, 7, 9))
+			foo = (struct fuse_open_out*)(feo + 1);
+		else
+			foo = (struct fuse_open_out*)((char*)feo +
+				FUSE_COMPAT_ENTRY_OUT_SIZE);
 	} else {
 		/* Issue a separate FUSE_OPEN */
 		struct fuse_open_in *foi;
diff --git a/tests/sys/fs/fusefs/create.cc b/tests/sys/fs/fusefs/create.cc
index 0797a3ff9e34..df3225ed1837 100644
--- a/tests/sys/fs/fusefs/create.cc
+++ b/tests/sys/fs/fusefs/create.cc
@@ -415,15 +415,18 @@ TEST_F(Create_7_8, ok)
 	expect_create(RELPATH, mode,
 		ReturnImmediate([=](auto in __unused, auto& out) {
 		SET_OUT_HEADER_LEN(out, create_7_8);
-		out.body.create.entry.attr.mode = mode;
-		out.body.create.entry.nodeid = ino;
-		out.body.create.entry.entry_valid = UINT64_MAX;
-		out.body.create.entry.attr_valid = UINT64_MAX;
+		out.body.create_7_8.entry.attr.mode = mode;
+		out.body.create_7_8.entry.nodeid = ino;
+		out.body.create_7_8.entry.entry_valid = UINT64_MAX;
+		out.body.create_7_8.entry.attr_valid = UINT64_MAX;
+		out.body.create_7_8.open.fh = FH;
 	}));
+	expect_flush(ino, 1, ReturnErrno(0));
+	expect_release(ino, FH);
 
 	fd = open(FULLPATH, O_CREAT | O_EXCL, mode);
 	ASSERT_LE(0, fd) << strerror(errno);
-	leak(fd);
+	close(fd);
 }
 
 TEST_F(Create_7_11, ok)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202204282119.23SLJlF0041476>