pidfs: raise SB_I_NODEV and SB_I_NOEXEC
authorChristian Brauner <brauner@kernel.org>
Wed, 18 Jun 2025 20:53:35 +0000 (22:53 +0200)
committerChristian Brauner <brauner@kernel.org>
Thu, 19 Jun 2025 12:28:23 +0000 (14:28 +0200)
Similar to commit 1ed95281c0c7 ("anon_inode: raise SB_I_NODEV and SB_I_NOEXEC"):
it shouldn't be possible to execute pidfds via
execveat(fd_anon_inode, "", NULL, NULL, AT_EMPTY_PATH)
so raise SB_I_NOEXEC so that no one gets any creative ideas.

Also raise SB_I_NODEV as we don't expect or support any devices on pidfs.

Link: https://lore.kernel.org/20250618-work-pidfs-persistent-v2-1-98f3456fd552@kernel.org
Reviewed-by: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@canonical.com>
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/pidfs.c

index c1f0a067be40ce4eaab7ca1e739ad34519c4b45d..ff2560b34ed1794663d046e1f1f5c28ca51b6864 100644 (file)
@@ -891,6 +891,8 @@ static int pidfs_init_fs_context(struct fs_context *fc)
        if (!ctx)
                return -ENOMEM;
 
+       fc->s_iflags |= SB_I_NOEXEC;
+       fc->s_iflags |= SB_I_NODEV;
        ctx->ops = &pidfs_sops;
        ctx->eops = &pidfs_export_operations;
        ctx->dops = &pidfs_dentry_operations;