Skip to content

Commit

Permalink
kernfs: The cgroup filesystem also benefits from SB_I_NOEXEC
Browse files Browse the repository at this point in the history
The cgroup filesystem is in the same boat as sysfs.  No one ever
permits executables of any kind on the cgroup filesystem, and there is
no reasonable future case to support executables in the future.

Therefore move the setting of SB_I_NOEXEC which makes the code proof
against future mistakes of accidentally creating executables from
sysfs to kernfs itself.  Making the code simpler and covering the
sysfs, cgroup, and cgroup2 filesystems.

Acked-by: Seth Forshee <[email protected]>
Signed-off-by: "Eric W. Biederman" <[email protected]>
  • Loading branch information
ebiederm committed Jun 23, 2016
1 parent a001e74 commit 29a517c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 2 additions & 0 deletions fs/kernfs/mount.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ static int kernfs_fill_super(struct super_block *sb, unsigned long magic)
struct dentry *root;

info->sb = sb;
/* Userspace would break if executables appear on sysfs */
sb->s_iflags |= SB_I_NOEXEC;
sb->s_blocksize = PAGE_SIZE;
sb->s_blocksize_bits = PAGE_SHIFT;
sb->s_magic = magic;
Expand Down
3 changes: 1 addition & 2 deletions fs/sysfs/mount.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ static struct dentry *sysfs_mount(struct file_system_type *fs_type,
if (IS_ERR(root) || !new_sb)
kobj_ns_drop(KOBJ_NS_TYPE_NET, ns);
else if (new_sb)
/* Userspace would break if executables appear on sysfs */
root->d_sb->s_iflags |= SB_I_USERNS_VISIBLE | SB_I_NOEXEC;
root->d_sb->s_iflags |= SB_I_USERNS_VISIBLE;

return root;
}
Expand Down

0 comments on commit 29a517c

Please sign in to comment.