Skip to content

Commit dd8b477

Browse files
author
Christian Brauner
committed
mount: Support "nosymfollow" in new mount api
Commit dab741e ("Add a "nosymfollow" mount option.") added support for the "nosymfollow" mount option allowing to block following symlinks when resolving paths. The mount option so far was only available in the old mount api. Make it available in the new mount api as well. Bonus is that it can be applied to a whole subtree not just a single mount. Cc: Christoph Hellwig <[email protected]> Cc: Mattias Nissler <[email protected]> Cc: Aleksa Sarai <[email protected]> Cc: Al Viro <[email protected]> Cc: Ross Zwisler <[email protected]> Signed-off-by: Christian Brauner <[email protected]>
1 parent 8124c8a commit dd8b477

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

fs/namespace.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3464,9 +3464,10 @@ SYSCALL_DEFINE5(mount, char __user *, dev_name, char __user *, dir_name,
34643464
return ret;
34653465
}
34663466

3467-
#define FSMOUNT_VALID_FLAGS \
3468-
(MOUNT_ATTR_RDONLY | MOUNT_ATTR_NOSUID | MOUNT_ATTR_NODEV | \
3469-
MOUNT_ATTR_NOEXEC | MOUNT_ATTR__ATIME | MOUNT_ATTR_NODIRATIME)
3467+
#define FSMOUNT_VALID_FLAGS \
3468+
(MOUNT_ATTR_RDONLY | MOUNT_ATTR_NOSUID | MOUNT_ATTR_NODEV | \
3469+
MOUNT_ATTR_NOEXEC | MOUNT_ATTR__ATIME | MOUNT_ATTR_NODIRATIME | \
3470+
MOUNT_ATTR_NOSYMFOLLOW)
34703471

34713472
#define MOUNT_SETATTR_VALID_FLAGS (FSMOUNT_VALID_FLAGS | MOUNT_ATTR_IDMAP)
34723473

@@ -3487,6 +3488,8 @@ static unsigned int attr_flags_to_mnt_flags(u64 attr_flags)
34873488
mnt_flags |= MNT_NOEXEC;
34883489
if (attr_flags & MOUNT_ATTR_NODIRATIME)
34893490
mnt_flags |= MNT_NODIRATIME;
3491+
if (attr_flags & MOUNT_ATTR_NOSYMFOLLOW)
3492+
mnt_flags |= MNT_NOSYMFOLLOW;
34903493

34913494
return mnt_flags;
34923495
}

include/uapi/linux/mount.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ enum fsconfig_command {
120120
#define MOUNT_ATTR_STRICTATIME 0x00000020 /* - Always perform atime updates */
121121
#define MOUNT_ATTR_NODIRATIME 0x00000080 /* Do not update directory access times */
122122
#define MOUNT_ATTR_IDMAP 0x00100000 /* Idmap mount to @userns_fd in struct mount_attr. */
123+
#define MOUNT_ATTR_NOSYMFOLLOW 0x00200000 /* Do not follow symlinks */
123124

124125
/*
125126
* mount_setattr()

0 commit comments

Comments
 (0)