mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-30 19:51:31 -04:00
Merge branch 'work.sane_pwd' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull misc vfs updates from Al Viro: "Making sure that something like a referral point won't end up as pwd or root. The main part is the last commit (fixing mntns_install()); that one fixes a hard-to-hit race. The fchdir() commit is making fchdir(2) a bit more robust - it should be impossible to get opened files (even O_PATH ones) for referral points in the first place, so the existing checks are OK, but checking the same thing as in chdir(2) is just as cheap. The path_init() commit removes a redundant check that shouldn't have been there in the first place" * 'work.sane_pwd' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: make sure that mntns_install() doesn't end up with referral for root path_init(): don't bother with checking MAY_EXEC for LOOKUP_ROOT make sure that fchdir() won't accept referral points, etc.
This commit is contained in:
commit
050453295f
4 changed files with 55 additions and 21 deletions
|
|
@ -3462,8 +3462,9 @@ static void mntns_put(struct ns_common *ns)
|
|||
static int mntns_install(struct nsproxy *nsproxy, struct ns_common *ns)
|
||||
{
|
||||
struct fs_struct *fs = current->fs;
|
||||
struct mnt_namespace *mnt_ns = to_mnt_ns(ns);
|
||||
struct mnt_namespace *mnt_ns = to_mnt_ns(ns), *old_mnt_ns;
|
||||
struct path root;
|
||||
int err;
|
||||
|
||||
if (!ns_capable(mnt_ns->user_ns, CAP_SYS_ADMIN) ||
|
||||
!ns_capable(current_user_ns(), CAP_SYS_CHROOT) ||
|
||||
|
|
@ -3474,15 +3475,18 @@ static int mntns_install(struct nsproxy *nsproxy, struct ns_common *ns)
|
|||
return -EINVAL;
|
||||
|
||||
get_mnt_ns(mnt_ns);
|
||||
put_mnt_ns(nsproxy->mnt_ns);
|
||||
old_mnt_ns = nsproxy->mnt_ns;
|
||||
nsproxy->mnt_ns = mnt_ns;
|
||||
|
||||
/* Find the root */
|
||||
root.mnt = &mnt_ns->root->mnt;
|
||||
root.dentry = mnt_ns->root->mnt.mnt_root;
|
||||
path_get(&root);
|
||||
while(d_mountpoint(root.dentry) && follow_down_one(&root))
|
||||
;
|
||||
err = vfs_path_lookup(mnt_ns->root->mnt.mnt_root, &mnt_ns->root->mnt,
|
||||
"/", LOOKUP_DOWN, &root);
|
||||
if (err) {
|
||||
/* revert to old namespace */
|
||||
nsproxy->mnt_ns = old_mnt_ns;
|
||||
put_mnt_ns(mnt_ns);
|
||||
return err;
|
||||
}
|
||||
|
||||
/* Update the pwd and root */
|
||||
set_fs_pwd(fs, &root);
|
||||
|
|
|
|||
Loading…
Reference in a new issue