@@ -3465,6 +3465,28 @@ SYSCALL_DEFINE5(mount, char __user *, dev_name, char __user *, dir_name,
3465
3465
return ret ;
3466
3466
}
3467
3467
3468
+ #define FSMOUNT_VALID_FLAGS \
3469
+ (MOUNT_ATTR_RDONLY | MOUNT_ATTR_NOSUID | MOUNT_ATTR_NODEV | \
3470
+ MOUNT_ATTR_NOEXEC | MOUNT_ATTR__ATIME | MOUNT_ATTR_NODIRATIME)
3471
+
3472
+ static unsigned int attr_flags_to_mnt_flags (u64 attr_flags )
3473
+ {
3474
+ unsigned int mnt_flags = 0 ;
3475
+
3476
+ if (attr_flags & MOUNT_ATTR_RDONLY )
3477
+ mnt_flags |= MNT_READONLY ;
3478
+ if (attr_flags & MOUNT_ATTR_NOSUID )
3479
+ mnt_flags |= MNT_NOSUID ;
3480
+ if (attr_flags & MOUNT_ATTR_NODEV )
3481
+ mnt_flags |= MNT_NODEV ;
3482
+ if (attr_flags & MOUNT_ATTR_NOEXEC )
3483
+ mnt_flags |= MNT_NOEXEC ;
3484
+ if (attr_flags & MOUNT_ATTR_NODIRATIME )
3485
+ mnt_flags |= MNT_NODIRATIME ;
3486
+
3487
+ return mnt_flags ;
3488
+ }
3489
+
3468
3490
/*
3469
3491
* Create a kernel mount representation for a new, prepared superblock
3470
3492
* (specified by fs_fd) and attach to an open_tree-like file descriptor.
@@ -3487,24 +3509,10 @@ SYSCALL_DEFINE3(fsmount, int, fs_fd, unsigned int, flags,
3487
3509
if ((flags & ~(FSMOUNT_CLOEXEC )) != 0 )
3488
3510
return - EINVAL ;
3489
3511
3490
- if (attr_flags & ~(MOUNT_ATTR_RDONLY |
3491
- MOUNT_ATTR_NOSUID |
3492
- MOUNT_ATTR_NODEV |
3493
- MOUNT_ATTR_NOEXEC |
3494
- MOUNT_ATTR__ATIME |
3495
- MOUNT_ATTR_NODIRATIME ))
3512
+ if (attr_flags & ~FSMOUNT_VALID_FLAGS )
3496
3513
return - EINVAL ;
3497
3514
3498
- if (attr_flags & MOUNT_ATTR_RDONLY )
3499
- mnt_flags |= MNT_READONLY ;
3500
- if (attr_flags & MOUNT_ATTR_NOSUID )
3501
- mnt_flags |= MNT_NOSUID ;
3502
- if (attr_flags & MOUNT_ATTR_NODEV )
3503
- mnt_flags |= MNT_NODEV ;
3504
- if (attr_flags & MOUNT_ATTR_NOEXEC )
3505
- mnt_flags |= MNT_NOEXEC ;
3506
- if (attr_flags & MOUNT_ATTR_NODIRATIME )
3507
- mnt_flags |= MNT_NODIRATIME ;
3515
+ mnt_flags = attr_flags_to_mnt_flags (attr_flags );
3508
3516
3509
3517
switch (attr_flags & MOUNT_ATTR__ATIME ) {
3510
3518
case MOUNT_ATTR_STRICTATIME :
0 commit comments