Skip to content

Commit cc50a07

Browse files
committed
userns: Remove the now unnecessary FS_USERNS_DEV_MOUNT flag
Now that SB_I_NODEV controls the nodev behavior devpts can just clear this flag during mount. Simplifying the code and making it easier to audit how the code works. While still preserving the invariant that s_iflags is only modified during mount. Acked-by: Seth Forshee <seth.forshee@canonical.com> Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
1 parent 67690f9 commit cc50a07

3 files changed

Lines changed: 3 additions & 4 deletions

File tree

‎fs/devpts/inode.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,7 @@ devpts_fill_super(struct super_block *s, void *data, int silent)
396396
{
397397
struct inode *inode;
398398

399+
s->s_iflags &= ~SB_I_NODEV;
399400
s->s_blocksize = 1024;
400401
s->s_blocksize_bits = 10;
401402
s->s_magic = DEVPTS_SUPER_MAGIC;
@@ -480,7 +481,7 @@ static struct file_system_type devpts_fs_type = {
480481
.name = "devpts",
481482
.mount = devpts_mount,
482483
.kill_sb = devpts_kill_sb,
483-
.fs_flags = FS_USERNS_MOUNT | FS_USERNS_DEV_MOUNT,
484+
.fs_flags = FS_USERNS_MOUNT,
484485
};
485486

486487
/*

‎fs/super.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,7 @@ static struct super_block *alloc_super(struct file_system_type *type, int flags,
206206
init_waitqueue_head(&s->s_writers.wait_unfrozen);
207207
s->s_bdi = &noop_backing_dev_info;
208208
s->s_flags = flags;
209-
if ((s->s_user_ns != &init_user_ns) &&
210-
!(type->fs_flags & FS_USERNS_DEV_MOUNT))
209+
if (s->s_user_ns != &init_user_ns)
211210
s->s_iflags |= SB_I_NODEV;
212211
INIT_HLIST_NODE(&s->s_instances);
213212
INIT_HLIST_BL_HEAD(&s->s_anon);

‎include/linux/fs.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2022,7 +2022,6 @@ struct file_system_type {
20222022
#define FS_BINARY_MOUNTDATA 2
20232023
#define FS_HAS_SUBTYPE 4
20242024
#define FS_USERNS_MOUNT 8 /* Can be mounted by userns root */
2025-
#define FS_USERNS_DEV_MOUNT 16 /* A userns mount does not imply MNT_NODEV */
20262025
#define FS_RENAME_DOES_D_MOVE 32768 /* FS will handle d_move() during rename() internally. */
20272026
struct dentry *(*mount) (struct file_system_type *, int,
20282027
const char *, void *);

0 commit comments

Comments
 (0)