diff options
Diffstat (limited to 'fs/namei.c')
-rw-r--r-- | fs/namei.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/fs/namei.c b/fs/namei.c index ad74877e1442..da689c9c005e 100644 --- a/fs/namei.c +++ b/fs/namei.c | |||
@@ -1100,7 +1100,6 @@ static int follow_automount(struct path *path, struct nameidata *nd, | |||
1100 | bool *need_mntput) | 1100 | bool *need_mntput) |
1101 | { | 1101 | { |
1102 | struct vfsmount *mnt; | 1102 | struct vfsmount *mnt; |
1103 | const struct cred *old_cred; | ||
1104 | int err; | 1103 | int err; |
1105 | 1104 | ||
1106 | if (!path->dentry->d_op || !path->dentry->d_op->d_automount) | 1105 | if (!path->dentry->d_op || !path->dentry->d_op->d_automount) |
@@ -1129,9 +1128,7 @@ static int follow_automount(struct path *path, struct nameidata *nd, | |||
1129 | if (nd->total_link_count >= 40) | 1128 | if (nd->total_link_count >= 40) |
1130 | return -ELOOP; | 1129 | return -ELOOP; |
1131 | 1130 | ||
1132 | old_cred = override_creds(&init_cred); | ||
1133 | mnt = path->dentry->d_op->d_automount(path); | 1131 | mnt = path->dentry->d_op->d_automount(path); |
1134 | revert_creds(old_cred); | ||
1135 | if (IS_ERR(mnt)) { | 1132 | if (IS_ERR(mnt)) { |
1136 | /* | 1133 | /* |
1137 | * The filesystem is allowed to return -EISDIR here to indicate | 1134 | * The filesystem is allowed to return -EISDIR here to indicate |
@@ -2941,10 +2938,16 @@ static inline int open_to_namei_flags(int flag) | |||
2941 | 2938 | ||
2942 | static int may_o_create(const struct path *dir, struct dentry *dentry, umode_t mode) | 2939 | static int may_o_create(const struct path *dir, struct dentry *dentry, umode_t mode) |
2943 | { | 2940 | { |
2941 | struct user_namespace *s_user_ns; | ||
2944 | int error = security_path_mknod(dir, dentry, mode, 0); | 2942 | int error = security_path_mknod(dir, dentry, mode, 0); |
2945 | if (error) | 2943 | if (error) |
2946 | return error; | 2944 | return error; |
2947 | 2945 | ||
2946 | s_user_ns = dir->dentry->d_sb->s_user_ns; | ||
2947 | if (!kuid_has_mapping(s_user_ns, current_fsuid()) || | ||
2948 | !kgid_has_mapping(s_user_ns, current_fsgid())) | ||
2949 | return -EOVERFLOW; | ||
2950 | |||
2948 | error = inode_permission(dir->dentry->d_inode, MAY_WRITE | MAY_EXEC); | 2951 | error = inode_permission(dir->dentry->d_inode, MAY_WRITE | MAY_EXEC); |
2949 | if (error) | 2952 | if (error) |
2950 | return error; | 2953 | return error; |