The fuse server can register a regular file on a filesystem that only the kernel mounts, such as a memfd, as a backing file. Such files were never meant to be passthrough backing files, and some come with semantics of their own, such as memfd seals, which passthrough does not respect. Refuse files on filesystems mounted with SB_KERNMOUNT, as is done for files on pseudo filesystems. A fuse server that wants to keep the data of its backing files in memory can create them with O_TMPFILE on a tmpfs that it mounts. Such files cannot be sealed. Reported-by: Dominik Maier Closes: https://lore.kernel.org/linux-fsdevel/20261203020416.3569911-1-dmnk@google.com/ Fixes: 44350256ab94 ("fuse: implement ioctls to manage backing files") Cc: stable@vger.kernel.org Signed-off-by: Amir Goldstein --- Miklos, FYI, Christian has already queued a similar patch for banning pseudo fs passthrough files [1]. Note that I intentionally placed the gate outside the S_IFMT switch to future-proof non-regular passthrough file types. Thanks, Amir. [1] https://lore.kernel.org/linux-fsdevel/20261110-work-loop-pseudo-v1-38-4c998976c6c7@kernel.org/ fs/fuse/backing.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/fuse/backing.c b/fs/fuse/backing.c index 4e4fb810ddaa8..287a4b6e18526 100644 --- a/fs/fuse/backing.c +++ b/fs/fuse/backing.c @@ -138,6 +138,9 @@ static int fuse_backing_open_file(struct fuse_conn *fc, struct fuse_backing *fb, struct dax_device *daxdev; int err; + if (inode->i_sb->s_flags & SB_KERNMOUNT) + return -EINVAL; + switch (inode->i_mode & S_IFMT) { case S_IFREG: /* TODO: relax CAP_SYS_ADMIN once backing files are visible to lsof */