Linux filesystem development
 help / color / mirror / Atom feed
* [PATCH] fuse: refuse kernel-internal files as passthrough backing files
@ 2026-12-03 17:55 Amir Goldstein
  2026-12-03 17:59 ` Lorenzo Stoakes (ARM)
  0 siblings, 1 reply; 2+ messages in thread
From: Amir Goldstein @ 2026-12-03 17:55 UTC (permalink / raw)
  To: Miklos Szeredi
  Cc: Christian Brauner, fuse-devel, linux-fsdevel, Lorenzo Stoakes,
	David Hildenbrand, Dominik Maier

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

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

* Re: [PATCH] fuse: refuse kernel-internal files as passthrough backing files
  2026-12-03 17:55 [PATCH] fuse: refuse kernel-internal files as passthrough backing files Amir Goldstein
@ 2026-12-03 17:59 ` Lorenzo Stoakes (ARM)
  0 siblings, 0 replies; 2+ messages in thread
From: Lorenzo Stoakes (ARM) @ 2026-12-03 17:59 UTC (permalink / raw)
  To: Amir Goldstein
  Cc: Miklos Szeredi, Christian Brauner, fuse-devel, linux-fsdevel,
	David Hildenbrand, Dominik Maier

On Thu, Dec 03, 2026 at 06:55:00PM +0100, Amir Goldstein wrote:
> 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>

Thanks!

Acked-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>

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

--
Cheers, Lorenzo

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

end of thread, other threads:[~2026-12-03 17:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-03 17:55 [PATCH] fuse: refuse kernel-internal files as passthrough backing files Amir Goldstein
2026-12-03 17:59 ` Lorenzo Stoakes (ARM)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox