linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 0/2] RFC: Extend fuse-passthrough to directories
@ 2025-06-17 22:14 Paul Lawrence
  2025-06-17 22:14 ` [PATCH v1 1/2] fuse: Add backing file option to lookup Paul Lawrence
                   ` (2 more replies)
  0 siblings, 3 replies; 19+ messages in thread
From: Paul Lawrence @ 2025-06-17 22:14 UTC (permalink / raw)
  To: Miklos Szeredi; +Cc: linux-kernel, linux-fsdevel, Paul Lawrence

This is the first part of a much larger patch set that would allow a directory
to be marked ‘passthrough’. At a high level, the fuse daemon can return an
optional extra argument to FUSE_LOOKUP that contains an fd. Extra fields are
added to the fuse_dentry, fuse_inode and fuse_file structs to have a backing
path, inode and file respectively. When fuse is performing an operation, it will
check for the existence of a backing object and if it exists forward the
operation to the backing object.

These two patches add the core infrastructure, handling of the extra argument
response to lookup, and forwarding open, flush and close to the backing file.
This is sufficient to validate the concept.

The questions I have:

* Is this something that interests the fuse maintainers and community?
* Is this approach the correct one?
* (if we agree yes to 1 & 2) Detailed analysis of the patches for errors.

A few observations:

I have matched backing objects to their fuse objects. Currently fuse passthrough
puts a backing file into the fuse inode. I’m not quite sure why this was done -
it seems to have been a very late change in the passthrough patch sets which
happened without comment. It does not really make sense for full directory
passthrough since unopened inodes still need to have backing inodes. The one
advantage I can see is that it reduces the number of opens/closes of the backing
file. However, this may also be a disadvantage - it moves closes, in particular,
to an arbitrary point when the inode is flushed from cache.

Backing operations need to happen in the context of the daemon, not the caller.
(I am a firm believer of this principle.) This is not yet implemented, and is
not (currently, and unfortunately) the way Android uses passthough. It is not
hard to do, and if these patches are otherwise acceptable, will be added.

There was a long discussion about the security issues of using an fd returned
from the fuse daemon in the context of fuse passthrough, and the end solution
was to use an ioctl to set the backing file. I have used the previously-rejected
approach of passing the fd in a struct in the fuse_daemon response. My defense
of this approach is

* The fd is simply used to pull out the path and inode
* All operations are revalidated
* Thus there is no risk even if a privileged process with a protected fd is
tricked into passing that fd back in this structure.

I’m sure we will discuss this at length if this patch set is otherwise deemed
valuable, and I am certainly not wedded to this approach.

I have written tests to validate this approach using tools/testing/selftests. I
don’t want this patch set to get derailed by a discussion of the way I wrote the
tests, so I have not included them. I am very open to any and every suggestion
as to how (and where) tests should be written for these patches.

Paul Lawrence (2):
  fuse: Add backing file option to lookup
  fuse: open/close backing file

 fs/fuse/Kconfig           |  13 +++++
 fs/fuse/Makefile          |   1 +
 fs/fuse/backing.c         |  97 ++++++++++++++++++++++++++++++++
 fs/fuse/dev.c             |  14 +++++
 fs/fuse/dir.c             | 108 +++++++++++++++++++++++++-----------
 fs/fuse/file.c            |  34 ++++++++----
 fs/fuse/fuse_i.h          |  61 +++++++++++++++++++-
 fs/fuse/inode.c           | 114 ++++++++++++++++++++++++++++++++++----
 include/uapi/linux/fuse.h |   4 ++
 9 files changed, 392 insertions(+), 54 deletions(-)
 create mode 100644 fs/fuse/backing.c

-- 
2.49.0.1112.g889b7c5bd8-goog


^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2025-08-10 15:41 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-17 22:14 [PATCH v1 0/2] RFC: Extend fuse-passthrough to directories Paul Lawrence
2025-06-17 22:14 ` [PATCH v1 1/2] fuse: Add backing file option to lookup Paul Lawrence
2025-06-18 13:46   ` kernel test robot
2025-06-17 22:14 ` [PATCH v1 2/2] fuse: open/close backing file Paul Lawrence
2025-06-18 11:01 ` [PATCH v1 0/2] RFC: Extend fuse-passthrough to directories Amir Goldstein
2025-06-19 19:50   ` Paul Lawrence
2025-06-19 20:29     ` Amir Goldstein
2025-07-14 15:20       ` Amir Goldstein
2025-07-22 21:13         ` Paul Lawrence
2025-07-23 16:53           ` Amir Goldstein
2025-07-23 18:30             ` Paul Lawrence
2025-07-24 19:51               ` Amir Goldstein
2025-08-04 17:32                 ` [PATCH 0/2] RFC: Set backing file at lookup Paul Lawrence
2025-08-04 17:32                   ` [PATCH 1/2] fuse: Allow backing file to be set at lookup (WIP) Paul Lawrence
2025-08-10 14:21                     ` Amir Goldstein
2025-08-04 17:32                   ` [PATCH 2/2] fuse: Add passthrough for mkdir and rmdir (WIP) Paul Lawrence
2025-08-10 15:40                     ` Amir Goldstein
2025-08-10 13:25                   ` [PATCH 0/2] RFC: Set backing file at lookup Amir Goldstein
2025-08-10 14:32                     ` Amir Goldstein

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).