From: Alexander Mikhalitsyn <alex@amutable.com>
To: Christian Brauner <brauner@kernel.org>, linux-fsdevel@vger.kernel.org
Cc: Jann Horn <jannh@google.com>, Chris Mason <mason@kernel.org>,
Josef Bacik <josef@toxicpanda.com>,
Christoph Hellwig <hch@lst.de>,
linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-nvme@lists.infradead.org,
Alexander Viro <viro@zeniv.linux.org.uk>, Jan Kara <jack@suse.cz>,
linux-scsi@vger.kernel.org, target-devel@vger.kernel.org,
driver-core@lists.linux.dev, linux-mm@kvack.org,
bpf@vger.kernel.org, linux-security-module@vger.kernel.org,
selinux@vger.kernel.org, apparmor@lists.ubuntu.com,
linux-nfs@vger.kernel.org, netdev@vger.kernel.org,
fuse-devel@lists.linux.dev, linux-efi@vger.kernel.org,
xen-devel@lists.xenproject.org, ocfs2-devel@lists.linux.dev,
linux-s390@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,
linux-usb@vger.kernel.org, Amir Goldstein <amir73il@gmail.com>,
linux-erofs@lists.ozlabs.org, linux-kselftest@vger.kernel.org
Subject: Re: [PATCH RFC 04/41] fs: add SB_I_PSEUDO
Date: Fri, 13 Nov 2026 11:02:15 +0100 [thread overview]
Message-ID: <f4ce8239f22046e90cf4807853282a570c73707a.camel@amutable.com> (raw)
In-Reply-To: <20261110-work-loop-pseudo-v1-4-4c998976c6c7@kernel.org>
On Tue, 2026-11-10 at 10:14 +0100, Christian Brauner wrote:
> Currently, there's no way to tell whether the files of a filesystem
> store data or whether they are kernel interfaces. Files on pseudo
> filesystems such as procfs or sysfs generate their contents when
> they're
> read and writes to them are commands to the kernel.
>
> But a few places in the kernel take an arbitrary file and use it as
> storage: loop, zloop, the nvme target's file backend, the scsi
> target's
> fileio backend, fuse passthrough, the usb mass storage gadget and
> erofs
> file-backed mounts. At most they check the file type and whether the
> file implements ->read_iter() and ->write_iter(). That's not enough.
> kernfs provides both for every sysfs attribute for example.
>
> Add SB_I_PSEUDO so a filesystem can state that its regular files are
> kernel interfaces and must not be used as storage.
>
> Pseudo filesystems also never hold executables or device nodes. But
> currently each of them decides on its own whether to raise
> SB_I_NOEXEC
> and SB_I_NODEV. Some do, most don't. Add fc_init_pseudo() as the
> common
> initialization point for all pseudo filesystems that raises all three
> flags and switch init_pseudo() over to it. The following patches
> convert the mountable pseudo filesystems.
>
> Nothing checks SB_I_PSEUDO yet so no functional changes.
>
> Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
Reviewed-by: Alexander Mikhalitsyn <alex@amutable.com>
> ---
> fs/libfs.c | 2 +-
> include/linux/fs/super_types.h | 1 +
> include/linux/pseudo_fs.h | 11 +++++++++++
> 3 files changed, 13 insertions(+), 1 deletion(-)
>
> diff --git a/fs/libfs.c b/fs/libfs.c
> index 96a6e9b1535f..8c8789489fdf 100644
> --- a/fs/libfs.c
> +++ b/fs/libfs.c
> @@ -735,7 +735,7 @@ struct pseudo_fs_context *init_pseudo(struct
> fs_context *fc,
> fc->fs_private = ctx;
> fc->ops = &pseudo_fs_context_ops;
> fc->sb_flags |= SB_NOUSER;
> - fc->s_iflags |= SB_I_NOEXEC | SB_I_NODEV;
> + fc_init_pseudo(fc);
> fc->global = true;
> }
> return ctx;
> diff --git a/include/linux/fs/super_types.h
> b/include/linux/fs/super_types.h
> index 72f4288e16c5..472200bdf081 100644
> --- a/include/linux/fs/super_types.h
> +++ b/include/linux/fs/super_types.h
> @@ -359,5 +359,6 @@ struct super_block {
> #define SB_I_NOIDMAP 0x00002000 /* No idmapped mounts on
> this superblock */
> #define SB_I_ALLOW_HSM 0x00004000 /* Allow HSM events on this
> superblock */
> #define SB_I_NO_DATA_INTEGRITY 0x00008000 /* fs cannot guarantee
> data persistence on sync */
> +#define SB_I_PSEUDO 0x00010000 /* regular files are kernel
> interfaces, not storage */
>
> #endif /* _LINUX_FS_SUPER_TYPES_H */
> diff --git a/include/linux/pseudo_fs.h b/include/linux/pseudo_fs.h
> index a651e60d9410..0ca408aa60af 100644
> --- a/include/linux/pseudo_fs.h
> +++ b/include/linux/pseudo_fs.h
> @@ -2,6 +2,7 @@
> #define __LINUX_PSEUDO_FS__
>
> #include <linux/fs_context.h>
> +#include <linux/fs/super_types.h>
>
> struct pseudo_fs_context {
> const struct super_operations *ops;
> @@ -15,4 +16,14 @@ struct pseudo_fs_context {
> struct pseudo_fs_context *init_pseudo(struct fs_context *fc,
> unsigned long magic);
>
> +/*
> + * Common initialization for all pseudo filesystems, mountable or
> not. Their
> + * regular files are kernel interfaces. They don't store data and
> pseudo
> + * filesystems never hold executables or device nodes.
> + */
> +static inline void fc_init_pseudo(struct fs_context *fc)
> +{
> + fc->s_iflags |= SB_I_PSEUDO | SB_I_NOEXEC | SB_I_NODEV;
> +}
> +
> #endif
next prev parent reply other threads:[~2026-11-13 10:02 UTC|newest]
Thread overview: 91+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-10 9:14 [PATCH RFC 00/41] fs: don't use pseudo filesystem files as storage Christian Brauner
2026-11-10 9:14 ` [PATCH RFC 01/41] loop: refuse backing files that aren't open for reading Christian Brauner
2026-11-10 12:53 ` Jan Kara
2026-11-11 14:55 ` Christoph Hellwig
2026-11-13 9:54 ` Alexander Mikhalitsyn
2026-11-10 9:14 ` [PATCH RFC 02/41] nvmet: check that the file backend supports ->{read,write}_iter Christian Brauner
2026-11-10 12:53 ` Jan Kara
2026-11-11 14:56 ` Christoph Hellwig
2026-11-10 9:14 ` [PATCH RFC 03/41] target: fileio: check that the backing file " Christian Brauner
2026-11-10 12:54 ` Jan Kara
2026-11-11 14:56 ` Christoph Hellwig
2026-11-10 9:14 ` [PATCH RFC 04/41] fs: add SB_I_PSEUDO Christian Brauner
2026-11-10 12:55 ` Jan Kara
2026-11-11 15:04 ` Christoph Hellwig
2026-11-13 10:02 ` Alexander Mikhalitsyn [this message]
2026-11-10 9:14 ` [PATCH RFC 05/41] kernfs: use fc_init_pseudo() Christian Brauner
2026-11-10 12:56 ` Jan Kara
2026-11-11 15:04 ` Christoph Hellwig
2026-11-13 10:02 ` Alexander Mikhalitsyn
2026-11-10 9:14 ` [PATCH RFC 06/41] proc: " Christian Brauner
2026-11-10 12:56 ` Jan Kara
2026-11-11 15:04 ` Christoph Hellwig
2026-11-13 10:02 ` Alexander Mikhalitsyn
2026-11-10 9:14 ` [PATCH RFC 07/41] binfmt_misc: " Christian Brauner
2026-11-10 12:56 ` Jan Kara
2026-11-13 10:03 ` Alexander Mikhalitsyn
2026-11-10 9:14 ` [PATCH RFC 08/41] mqueue: " Christian Brauner
2026-11-11 15:05 ` Christoph Hellwig
2026-11-13 10:03 ` Alexander Mikhalitsyn
2026-11-10 9:14 ` [PATCH RFC 09/41] bpf: use fc_init_pseudo() for bpffs Christian Brauner
2026-11-11 15:05 ` Christoph Hellwig
2026-11-13 10:03 ` Alexander Mikhalitsyn
2026-11-10 9:14 ` [PATCH RFC 10/41] nullfs: use fc_init_pseudo() Christian Brauner
2026-11-10 12:57 ` Jan Kara
2026-11-11 15:05 ` Christoph Hellwig
2026-11-13 10:03 ` Alexander Mikhalitsyn
2026-11-10 9:14 ` [PATCH RFC 11/41] failfs: " Christian Brauner
2026-11-10 12:57 ` Jan Kara
2026-11-11 15:05 ` Christoph Hellwig
2026-11-10 9:14 ` [PATCH RFC 12/41] rust_binderfs: " Christian Brauner
2026-11-10 9:14 ` [PATCH RFC 13/41] devpts: " Christian Brauner
2026-11-13 10:05 ` Alexander Mikhalitsyn
2026-11-10 9:14 ` [PATCH RFC 14/41] debugfs: " Christian Brauner
2026-11-10 12:59 ` Jan Kara
2026-11-13 10:05 ` Alexander Mikhalitsyn
2026-11-10 9:14 ` [PATCH RFC 15/41] tracefs: " Christian Brauner
2026-11-13 10:05 ` Alexander Mikhalitsyn
2026-11-10 9:14 ` [PATCH RFC 16/41] configfs: " Christian Brauner
2026-11-10 12:59 ` Jan Kara
2026-11-11 9:46 ` Breno Leitao
2026-11-13 10:06 ` Alexander Mikhalitsyn
2026-11-10 9:14 ` [PATCH RFC 17/41] securityfs: " Christian Brauner
2026-11-13 10:10 ` Alexander Mikhalitsyn
2026-11-10 9:14 ` [PATCH RFC 18/41] selinux: use fc_init_pseudo() for selinuxfs Christian Brauner
2026-11-13 10:11 ` Alexander Mikhalitsyn
2026-11-10 9:14 ` [PATCH RFC 19/41] smack: use fc_init_pseudo() for smackfs Christian Brauner
2026-11-12 1:50 ` [apparmor] " Casey Schaufler
2026-11-13 10:12 ` Alexander Mikhalitsyn
2026-11-10 9:14 ` [PATCH RFC 20/41] apparmor: use fc_init_pseudo() for apparmorfs Christian Brauner
2026-11-10 9:14 ` [PATCH RFC 21/41] nfsd: use fc_init_pseudo() Christian Brauner
2026-11-10 14:55 ` Chuck Lever
2026-11-10 9:14 ` [PATCH RFC 22/41] sunrpc: use fc_init_pseudo() for rpc_pipefs Christian Brauner
2026-11-13 10:13 ` Alexander Mikhalitsyn
2026-11-10 9:14 ` [PATCH RFC 23/41] fuse: use fc_init_pseudo() for fusectl Christian Brauner
2026-11-13 10:13 ` Alexander Mikhalitsyn
2026-11-10 9:14 ` [PATCH RFC 24/41] efivarfs: use fc_init_pseudo() Christian Brauner
2026-11-10 9:14 ` [PATCH RFC 25/41] pstore: " Christian Brauner
2026-11-10 9:14 ` [PATCH RFC 26/41] xenfs: " Christian Brauner
2026-11-10 9:14 ` [PATCH RFC 27/41] openpromfs: " Christian Brauner
2026-11-10 9:14 ` [PATCH RFC 28/41] ocfs2: use fc_init_pseudo() for dlmfs Christian Brauner
2026-11-10 13:01 ` Jan Kara
2026-11-10 9:14 ` [PATCH RFC 29/41] s390/hypfs: use fc_init_pseudo() Christian Brauner
2026-11-10 9:14 ` [PATCH RFC 30/41] powerpc/spufs: " Christian Brauner
2026-11-10 9:14 ` [PATCH RFC 31/41] usb: gadget: f_fs: " Christian Brauner
2026-11-10 9:14 ` [PATCH RFC 32/41] usb: gadget: gadgetfs: " Christian Brauner
2026-11-10 9:14 ` [PATCH RFC 33/41] fs: add file_is_pseudo() Christian Brauner
2026-11-10 13:02 ` Jan Kara
2026-11-10 9:14 ` [PATCH RFC 34/41] loop: refuse files on pseudo filesystems as backing files Christian Brauner
2026-11-10 13:03 ` Jan Kara
2026-11-10 9:14 ` [PATCH RFC 35/41] zloop: refuse zone files on pseudo filesystems Christian Brauner
2026-11-10 9:14 ` [PATCH RFC 36/41] nvmet: refuse files on pseudo filesystems as namespace backing files Christian Brauner
2026-11-10 15:07 ` Bui Nguyen Nhu Quynh
2026-11-10 9:14 ` [PATCH RFC 37/41] target: fileio: refuse files on pseudo filesystems as " Christian Brauner
2026-11-10 9:33 ` sashiko-bot
2026-11-10 9:14 ` [PATCH RFC 38/41] fuse: refuse files on pseudo filesystems as passthrough " Christian Brauner
2026-11-10 10:14 ` Amir Goldstein
2026-11-11 15:12 ` Christoph Hellwig
2026-11-10 9:14 ` [PATCH RFC 39/41] usb: gadget: f_mass_storage: refuse files on pseudo filesystems Christian Brauner
2026-11-10 9:14 ` [PATCH RFC 40/41] erofs: refuse files on pseudo filesystems as backing files Christian Brauner
2026-11-10 20:45 ` Gao Xiang
2026-11-10 9:14 ` [PATCH RFC 41/41] selftests/filesystems: add backing file tests for pseudo files Christian Brauner
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=f4ce8239f22046e90cf4807853282a570c73707a.camel@amutable.com \
--to=alex@amutable.com \
--cc=amir73il@gmail.com \
--cc=apparmor@lists.ubuntu.com \
--cc=bpf@vger.kernel.org \
--cc=brauner@kernel.org \
--cc=driver-core@lists.linux.dev \
--cc=fuse-devel@lists.linux.dev \
--cc=hch@lst.de \
--cc=jack@suse.cz \
--cc=jannh@google.com \
--cc=josef@toxicpanda.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-efi@vger.kernel.org \
--cc=linux-erofs@lists.ozlabs.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-nfs@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=linux-s390@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mason@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=ocfs2-devel@lists.linux.dev \
--cc=selinux@vger.kernel.org \
--cc=target-devel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
--cc=xen-devel@lists.xenproject.org \
/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