From: Paul Moore <paul@paul-moore.com>
To: sashiko-bot@kernel.org, "Christian Brauner" <brauner@kernel.org>
Cc: linux-security-module@vger.kernel.org, selinux@vger.kernel.org,
linux-s390@vger.kernel.org, linux-usb@vger.kernel.org,
"Heiko Carstens" <hca@linux.ibm.com>,
"Vasily Gorbik" <gor@linux.ibm.com>,
"Alexander Gordeev" <agordeev@linux.ibm.com>,
"Christian Borntraeger" <borntraeger@linux.ibm.com>,
"Mark Fasheh" <mark@fasheh.com>,
"Joel Becker" <jlbec@evilplan.org>,
"Joseph Qi" <joseph.qi@linux.alibaba.com>
Subject: Re: [PATCH RFC v3 17/44] securityfs: use fc_init_pseudo()
Date: Tue, 17 Nov 2026 18:34:38 -0500 [thread overview]
Message-ID: <7dc91c090b4f8254f8b6fbe2ec36060f@paul-moore.com> (raw)
In-Reply-To: <20261116-work-loop-pseudo-v3-17-8cbbea1cf34f@kernel.org>
On Nov 16, 2026 sashiko-bot@kernel.org wrote:
>
> Initialize securityfs as a pseudo filesystem. This raises SB_I_PSEUDO
> and SB_I_NOEXEC. securityfs never holds executables.
>
> But securityfs needs device nodes. AppArmor puts a .null device node
> into securityfs. On exec it replaces file descriptors the new profile
> isn't allowed to use with that node and opens it via dentry_open() which
> doesn't care about SB_I_NODEV. Such a file descriptor can still be
> reopened through /proc/<pid>/fd/<nr> though and that's what opening
> /dev/stderr does. The node itself can also be opened by path as
> /sys/kernel/security/apparmor/.null. Both go through may_open_dev()
> which refuses device nodes with SB_I_NODEV raised. So clear SB_I_NODEV
> again in securityfs_fill_super().
>
> Reviewed-by: Alexander Mikhalitsyn <alex@amutable.com>
> Reviewed-by: Chris Down <chris@chrisdown.name>
> Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
> ---
> security/inode.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/security/inode.c b/security/inode.c
> index 0804023676741..edaebf0f1972d 100644
> --- a/security/inode.c
> +++ b/security/inode.c
> @@ -14,6 +14,7 @@
> #include <linux/kobject.h>
> #include <linux/fs.h>
> #include <linux/fs_context.h>
> +#include <linux/pseudo_fs.h>
> #include <linux/mount.h>
> #include <linux/pagemap.h>
> #include <linux/init.h>
> @@ -49,6 +50,8 @@ static int securityfs_fill_super(struct super_block *sb, struct fs_context *fc)
> return error;
>
> sb->s_op = &securityfs_super_operations;
> + /* Userspace may open AppArmor's .null device node by path. */
> + sb->s_iflags &= ~SB_I_NODEV;
AppArmor itself does a dentry_open() on its null device to effectively
block inheritence of open files if not permitted by policy. SELinux
basically does the same thing, in fact AppArmor's aa_inherit_files()
is based on SELinux's flush_unauthorized_files() according to the
comments.
Anyway, I'd suggest changing your comment to something like the
following, but it's not critical.
/* Allow for LSM specific null device nodes */
Acked-by: Paul Moore <paul@paul-moore.com>
> return 0;
> }
> @@ -64,6 +67,7 @@ static const struct fs_context_operations securityfs_context_ops = {
>
> static int securityfs_init_fs_context(struct fs_context *fc)
> {
> + fc_init_pseudo(fc);
> fc->ops = &securityfs_context_ops;
> return 0;
> }
>
> --
> 2.53.0
--
paul-moore.com
next prev parent reply other threads:[~2026-11-17 23:34 UTC|newest]
Thread overview: 110+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-16 11:04 [PATCH RFC v3 00/44] fs: don't use pseudo filesystem files as storage Christian Brauner
2026-11-16 11:04 ` [PATCH RFC v3 01/44] loop: refuse backing files that aren't open for reading Christian Brauner
2026-11-16 11:24 ` sashiko-bot
2026-11-16 11:04 ` [PATCH RFC v3 02/44] nvmet: check that the file backend supports ->{read,write}_iter Christian Brauner
2026-11-16 11:15 ` sashiko-bot
2026-11-17 8:25 ` Alexander Mikhalitsyn
2026-11-16 11:04 ` [PATCH RFC v3 03/44] target: fileio: check that the backing file " Christian Brauner
2026-11-16 11:25 ` sashiko-bot
2026-11-17 8:26 ` Alexander Mikhalitsyn
2026-11-16 11:04 ` [PATCH RFC v3 04/44] fs: add SB_I_PSEUDO Christian Brauner
2026-11-16 11:16 ` sashiko-bot
2026-11-16 11:04 ` [PATCH RFC v3 05/44] kernfs: use fc_init_pseudo() Christian Brauner
2026-11-16 11:19 ` sashiko-bot
2026-11-16 11:04 ` [PATCH RFC v3 06/44] proc: " Christian Brauner
2026-11-16 11:17 ` sashiko-bot
2026-11-16 11:04 ` [PATCH RFC v3 07/44] binfmt_misc: " Christian Brauner
2026-11-16 11:16 ` sashiko-bot
2026-11-16 11:04 ` [PATCH RFC v3 08/44] mqueue: " Christian Brauner
2026-11-16 11:16 ` sashiko-bot
2026-11-16 11:04 ` [PATCH RFC v3 09/44] bpf: use fc_init_pseudo() for bpffs Christian Brauner
2026-11-16 11:16 ` sashiko-bot
2026-11-16 20:03 ` Andrii Nakryiko
2026-11-16 11:04 ` [PATCH RFC v3 10/44] nullfs: use fc_init_pseudo() Christian Brauner
2026-11-16 11:16 ` sashiko-bot
2026-11-16 11:04 ` [PATCH RFC v3 11/44] failfs: " Christian Brauner
2026-11-16 11:17 ` sashiko-bot
2026-11-17 8:26 ` Alexander Mikhalitsyn
2026-11-16 11:04 ` [PATCH RFC v3 12/44] rust_binderfs: " Christian Brauner
2026-11-16 11:20 ` sashiko-bot
2026-11-16 12:00 ` Alice Ryhl
2026-11-17 8:27 ` Alexander Mikhalitsyn
2026-11-16 11:04 ` [PATCH RFC v3 13/44] devpts: " Christian Brauner
2026-11-16 11:16 ` sashiko-bot
2026-11-16 11:04 ` [PATCH RFC v3 14/44] debugfs: " Christian Brauner
2026-11-16 11:15 ` sashiko-bot
2026-11-16 11:04 ` [PATCH RFC v3 15/44] tracefs: " Christian Brauner
2026-11-16 11:17 ` sashiko-bot
2026-11-16 11:04 ` [PATCH RFC v3 16/44] configfs: " Christian Brauner
2026-11-16 11:18 ` sashiko-bot
2026-11-16 11:04 ` [PATCH RFC v3 17/44] securityfs: " Christian Brauner
2026-11-16 11:20 ` sashiko-bot
2026-11-17 23:34 ` Paul Moore [this message]
2026-11-16 11:04 ` [PATCH RFC v3 18/44] selinux: use fc_init_pseudo() for selinuxfs Christian Brauner
2026-11-16 11:20 ` sashiko-bot
2026-11-17 23:34 ` Paul Moore
2026-11-16 11:04 ` [PATCH RFC v3 19/44] smack: use fc_init_pseudo() for smackfs Christian Brauner
2026-11-16 11:18 ` sashiko-bot
2026-11-16 11:04 ` [PATCH RFC v3 20/44] apparmor: use fc_init_pseudo() for apparmorfs Christian Brauner
2026-11-16 11:19 ` sashiko-bot
2026-11-16 11:04 ` [PATCH RFC v3 21/44] nfsd: use fc_init_pseudo() Christian Brauner
2026-11-16 11:20 ` sashiko-bot
2026-11-17 8:28 ` Alexander Mikhalitsyn
2026-11-16 11:04 ` [PATCH RFC v3 22/44] sunrpc: use fc_init_pseudo() for rpc_pipefs Christian Brauner
2026-11-16 11:19 ` sashiko-bot
2026-11-16 11:04 ` [PATCH RFC v3 23/44] fuse: use fc_init_pseudo() for fusectl Christian Brauner
2026-11-16 11:20 ` sashiko-bot
2026-11-16 11:04 ` [PATCH RFC v3 24/44] efivarfs: use fc_init_pseudo() Christian Brauner
2026-11-16 11:21 ` sashiko-bot
2026-11-16 11:04 ` [PATCH RFC v3 25/44] pstore: " Christian Brauner
2026-11-16 11:19 ` sashiko-bot
2026-11-16 11:04 ` [PATCH RFC v3 26/44] xenfs: " Christian Brauner
2026-11-16 11:20 ` sashiko-bot
2026-11-17 8:28 ` Alexander Mikhalitsyn
2026-11-16 11:05 ` [PATCH RFC v3 27/44] openpromfs: " Christian Brauner
2026-11-16 11:20 ` sashiko-bot
2026-11-17 8:32 ` Alexander Mikhalitsyn
2026-11-16 11:05 ` [PATCH RFC v3 28/44] ocfs2: use fc_init_pseudo() for dlmfs Christian Brauner
2026-11-16 11:20 ` sashiko-bot
2026-11-17 8:35 ` Alexander Mikhalitsyn
2026-11-16 11:05 ` [PATCH RFC v3 29/44] s390/hypfs: use fc_init_pseudo() Christian Brauner
2026-11-16 11:23 ` sashiko-bot
2026-11-17 8:36 ` Alexander Mikhalitsyn
2026-11-16 11:05 ` [PATCH RFC v3 30/44] powerpc/spufs: " Christian Brauner
2026-11-16 11:28 ` sashiko-bot
2026-11-16 11:05 ` [PATCH RFC v3 31/44] usb: gadget: f_fs: " Christian Brauner
2026-11-16 11:21 ` sashiko-bot
2026-11-16 11:05 ` [PATCH RFC v3 32/44] usb: gadget: gadgetfs: " Christian Brauner
2026-11-16 11:21 ` sashiko-bot
2026-11-16 11:05 ` [PATCH RFC v3 33/44] ovl: refuse data-only layers on pseudo filesystems Christian Brauner
2026-11-16 11:27 ` sashiko-bot
2026-11-16 17:37 ` Amir Goldstein
2026-11-16 17:49 ` Christian Brauner
2026-11-16 11:05 ` [PATCH RFC v3 34/44] selftests/ovl: test " Christian Brauner
2026-11-16 11:28 ` sashiko-bot
2026-11-16 17:16 ` Amir Goldstein
2026-11-16 11:05 ` [PATCH RFC v3 35/44] fs: add file_check_backing() Christian Brauner
2026-11-16 11:30 ` sashiko-bot
2026-11-16 13:07 ` Jan Kara
2026-11-17 8:44 ` Alexander Mikhalitsyn
2026-11-16 11:05 ` [PATCH RFC v3 36/44] loop: refuse files on pseudo filesystems as backing files Christian Brauner
2026-11-16 11:28 ` sashiko-bot
2026-11-16 11:05 ` [PATCH RFC v3 37/44] zloop: refuse zone files on pseudo filesystems Christian Brauner
2026-11-16 11:28 ` sashiko-bot
2026-11-16 11:05 ` [PATCH RFC v3 38/44] nvmet: refuse files on pseudo filesystems as namespace backing files Christian Brauner
2026-11-16 11:24 ` sashiko-bot
2026-11-16 12:00 ` bot+bpf-ci
2026-11-16 13:20 ` Christian Brauner
2026-11-16 11:05 ` [PATCH RFC v3 39/44] target: fileio: refuse files on pseudo filesystems as " Christian Brauner
2026-11-16 11:23 ` sashiko-bot
2026-11-16 11:05 ` [PATCH RFC v3 40/44] fuse: refuse files on pseudo filesystems as passthrough " Christian Brauner
2026-11-16 11:26 ` sashiko-bot
2026-11-16 11:05 ` [PATCH RFC v3 41/44] usb: gadget: f_mass_storage: refuse files on pseudo filesystems Christian Brauner
2026-11-16 11:26 ` sashiko-bot
2026-11-16 11:05 ` [PATCH RFC v3 42/44] erofs: refuse files on pseudo filesystems as backing files Christian Brauner
2026-11-16 11:25 ` sashiko-bot
2026-11-16 11:05 ` [PATCH RFC v3 43/44] acct: refuse files on pseudo filesystems Christian Brauner
2026-11-16 11:27 ` sashiko-bot
2026-11-16 11:05 ` [PATCH RFC v3 44/44] selftests/filesystems: add backing file tests for pseudo files Christian Brauner
2026-11-16 11:29 ` sashiko-bot
2026-11-16 12:00 ` bot+bpf-ci
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=7dc91c090b4f8254f8b6fbe2ec36060f@paul-moore.com \
--to=paul@paul-moore.com \
--cc=agordeev@linux.ibm.com \
--cc=borntraeger@linux.ibm.com \
--cc=brauner@kernel.org \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=jlbec@evilplan.org \
--cc=joseph.qi@linux.alibaba.com \
--cc=linux-s390@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=mark@fasheh.com \
--cc=sashiko-bot@kernel.org \
--cc=selinux@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.