Linux filesystem development
 help / color / mirror / Atom feed
From: Amir Goldstein <amir73il@gmail.com>
To: Miklos Szeredi <miklos@szeredi.hu>
Cc: Christian Brauner <brauner@kernel.org>,
	fuse-devel@lists.linux.dev, linux-fsdevel@vger.kernel.org,
	Lorenzo Stoakes <ljs@kernel.org>,
	David Hildenbrand <david@kernel.org>,
	Dominik Maier <dmnk@google.com>
Subject: [PATCH] fuse: refuse kernel-internal files as passthrough backing files
Date: Thu,  3 Dec 2026 18:55:00 +0100	[thread overview]
Message-ID: <20261203175501.288404-1-amir73il@gmail.com> (raw)

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 <dmnk@google.com>
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 <amir73il@gmail.com>
---

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 */

             reply	other threads:[~2026-12-03 17:55 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03 17:55 Amir Goldstein [this message]
2026-12-03 17:59 ` [PATCH] fuse: refuse kernel-internal files as passthrough backing files Lorenzo Stoakes (ARM)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261203175501.288404-1-amir73il@gmail.com \
    --to=amir73il@gmail.com \
    --cc=brauner@kernel.org \
    --cc=david@kernel.org \
    --cc=dmnk@google.com \
    --cc=fuse-devel@lists.linux.dev \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=ljs@kernel.org \
    --cc=miklos@szeredi.hu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox