Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

copy_mnt_ns(): use guards

* mntput() of rootmnt and pwdmnt done via __free(mntput)
* mnt_ns_tree_add() can be done within namespace_excl scope.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

Al Viro d7b7253a 7bb4c851

+4 -12
+4 -12
fs/namespace.c
··· 4158 4158 struct user_namespace *user_ns, struct fs_struct *new_fs) 4159 4159 { 4160 4160 struct mnt_namespace *new_ns; 4161 - struct vfsmount *rootmnt = NULL, *pwdmnt = NULL; 4161 + struct vfsmount *rootmnt __free(mntput) = NULL; 4162 + struct vfsmount *pwdmnt __free(mntput) = NULL; 4162 4163 struct mount *p, *q; 4163 4164 struct mount *old; 4164 4165 struct mount *new; ··· 4178 4177 if (IS_ERR(new_ns)) 4179 4178 return new_ns; 4180 4179 4181 - namespace_lock(); 4180 + guard(namespace_excl)(); 4182 4181 /* First pass: copy the tree topology */ 4183 4182 copy_flags = CL_COPY_UNBINDABLE | CL_EXPIRE; 4184 4183 if (user_ns != ns->user_ns) ··· 4186 4185 new = copy_tree(old, old->mnt.mnt_root, copy_flags); 4187 4186 if (IS_ERR(new)) { 4188 4187 emptied_ns = new_ns; 4189 - namespace_unlock(); 4190 4188 return ERR_CAST(new); 4191 4189 } 4192 4190 if (user_ns != ns->user_ns) { 4193 - lock_mount_hash(); 4191 + guard(mount_writer)(); 4194 4192 lock_mnt_tree(new); 4195 - unlock_mount_hash(); 4196 4193 } 4197 4194 new_ns->root = new; 4198 4195 ··· 4222 4223 while (p->mnt.mnt_root != q->mnt.mnt_root) 4223 4224 p = next_mnt(skip_mnt_tree(p), old); 4224 4225 } 4225 - namespace_unlock(); 4226 - 4227 - if (rootmnt) 4228 - mntput(rootmnt); 4229 - if (pwdmnt) 4230 - mntput(pwdmnt); 4231 - 4232 4226 mnt_ns_tree_add(new_ns); 4233 4227 return new_ns; 4234 4228 }