From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from sea.source.kernel.org ([172.234.252.31]) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1xSujH-0002iw-NO for apparmor@lists.ubuntu.com; Mon, 16 Nov 2026 11:18:31 +0000 From: Christian Brauner Date: Mon, 16 Nov 2026 12:04:50 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20261116-work-loop-pseudo-v3-17-8cbbea1cf34f@kernel.org> References: <20261116-work-loop-pseudo-v3-0-8cbbea1cf34f@kernel.org> In-Reply-To: <20261116-work-loop-pseudo-v3-0-8cbbea1cf34f@kernel.org> X-Developer-Signature: v=1; a=openpgp-sha256; l=1852; i=brauner@kernel.org; h=from:subject:message-id; bh=eMcnNCEpWBwKj5om0lrEeWJ5nBa2aNmgGW6gKfibtdI=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMWT9ely05XJ7OEvs8TnzdthOuj5jRmeNvcusK/wb9d009 sqseiv+uaOUhUGMi0FWTJHFod0kXG45T8Vmo0wNmDmsTCBDGLg4BWAiZtwM/8tXxgrFR/CedHKe 0mA1KbT0X+dFm3JBzXc/uE6/jTfZp8XI8K/AdXL+qxbtObkKd1SmMq4za1/jJnJCs+L8dFueFAl 3PgA= X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 Subject: [apparmor] [PATCH RFC v3 17/44] securityfs: use fc_init_pseudo() List-Id: AppArmor discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: linux-fsdevel@vger.kernel.org Cc: Jann Horn , Chris Mason , Josef Bacik , Christoph Hellwig , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org, Alexander Viro , Jan Kara , 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 , linux-erofs@lists.ozlabs.org, linux-kselftest@vger.kernel.org, "Christian Brauner (Amutable)" , Alexander Mikhalitsyn , Chris Down 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//fd/ 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 Reviewed-by: Chris Down Signed-off-by: Christian Brauner (Amutable) --- 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 #include #include +#include #include #include #include @@ -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; 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