Skip to content

Commit 1ed9528

Browse files
committed
anon_inode: raise SB_I_NODEV and SB_I_NOEXEC
It isn't possible to execute anonymous inodes because they cannot be opened in any way after they have been created. This includes execution: execveat(fd_anon_inode, "", NULL, NULL, AT_EMPTY_PATH) Anonymous inodes have inode->f_op set to no_open_fops which sets no_open() which returns ENXIO. That means any call to do_dentry_open() which is the endpoint of the do_open_execat() will fail. There's no chance to execute an anonymous inode. Unless a given subsystem overrides it ofc. However, we should still harden this and raise SB_I_NODEV and SB_I_NOEXEC on the superblock itself so that no one gets any creative ideas. Link: https://lore.kernel.org/[email protected] Reviewed-by: Jeff Layton <[email protected]> Cc: [email protected] # all LTS kernels Signed-off-by: Christian Brauner <[email protected]>
1 parent c83b902 commit 1ed9528

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

fs/anon_inodes.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ static int anon_inodefs_init_fs_context(struct fs_context *fc)
8686
struct pseudo_fs_context *ctx = init_pseudo(fc, ANON_INODE_FS_MAGIC);
8787
if (!ctx)
8888
return -ENOMEM;
89+
fc->s_iflags |= SB_I_NOEXEC;
90+
fc->s_iflags |= SB_I_NODEV;
8991
ctx->dops = &anon_inodefs_dentry_operations;
9092
return 0;
9193
}

0 commit comments

Comments
 (0)