diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2014-11-01 00:00:23 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2014-12-04 14:33:24 -0500 |
commit | 58be28256d98a6b996b20f49130ea11afb8de75a (patch) | |
tree | 34e4a64998fdac7d61199df862f51c3d9995c469 /fs | |
parent | 435d5f4bb2ccba3b791d9ef61d2590e30b8e806e (diff) |
make mntns ->get()/->put()/->install()/->inum() work with &mnt_ns->ns
Acked-by: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/namespace.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/fs/namespace.c b/fs/namespace.c index adc2ea2532a0..5c21fdadabe4 100644 --- a/fs/namespace.c +++ b/fs/namespace.c | |||
@@ -1582,6 +1582,11 @@ static bool is_mnt_ns_file(struct dentry *dentry) | |||
1582 | return true; | 1582 | return true; |
1583 | } | 1583 | } |
1584 | 1584 | ||
1585 | struct mnt_namespace *to_mnt_ns(struct ns_common *ns) | ||
1586 | { | ||
1587 | return container_of(ns, struct mnt_namespace, ns); | ||
1588 | } | ||
1589 | |||
1585 | static bool mnt_ns_loop(struct dentry *dentry) | 1590 | static bool mnt_ns_loop(struct dentry *dentry) |
1586 | { | 1591 | { |
1587 | /* Could bind mounting the mount namespace inode cause a | 1592 | /* Could bind mounting the mount namespace inode cause a |
@@ -1591,7 +1596,7 @@ static bool mnt_ns_loop(struct dentry *dentry) | |||
1591 | if (!is_mnt_ns_file(dentry)) | 1596 | if (!is_mnt_ns_file(dentry)) |
1592 | return false; | 1597 | return false; |
1593 | 1598 | ||
1594 | mnt_ns = get_proc_ns(dentry->d_inode)->ns; | 1599 | mnt_ns = to_mnt_ns(get_proc_ns(dentry->d_inode)->ns); |
1595 | return current->nsproxy->mnt_ns->seq >= mnt_ns->seq; | 1600 | return current->nsproxy->mnt_ns->seq >= mnt_ns->seq; |
1596 | } | 1601 | } |
1597 | 1602 | ||
@@ -3146,14 +3151,14 @@ found: | |||
3146 | 3151 | ||
3147 | static void *mntns_get(struct task_struct *task) | 3152 | static void *mntns_get(struct task_struct *task) |
3148 | { | 3153 | { |
3149 | struct mnt_namespace *ns = NULL; | 3154 | struct ns_common *ns = NULL; |
3150 | struct nsproxy *nsproxy; | 3155 | struct nsproxy *nsproxy; |
3151 | 3156 | ||
3152 | task_lock(task); | 3157 | task_lock(task); |
3153 | nsproxy = task->nsproxy; | 3158 | nsproxy = task->nsproxy; |
3154 | if (nsproxy) { | 3159 | if (nsproxy) { |
3155 | ns = nsproxy->mnt_ns; | 3160 | ns = &nsproxy->mnt_ns->ns; |
3156 | get_mnt_ns(ns); | 3161 | get_mnt_ns(to_mnt_ns(ns)); |
3157 | } | 3162 | } |
3158 | task_unlock(task); | 3163 | task_unlock(task); |
3159 | 3164 | ||
@@ -3162,13 +3167,13 @@ static void *mntns_get(struct task_struct *task) | |||
3162 | 3167 | ||
3163 | static void mntns_put(void *ns) | 3168 | static void mntns_put(void *ns) |
3164 | { | 3169 | { |
3165 | put_mnt_ns(ns); | 3170 | put_mnt_ns(to_mnt_ns(ns)); |
3166 | } | 3171 | } |
3167 | 3172 | ||
3168 | static int mntns_install(struct nsproxy *nsproxy, void *ns) | 3173 | static int mntns_install(struct nsproxy *nsproxy, void *ns) |
3169 | { | 3174 | { |
3170 | struct fs_struct *fs = current->fs; | 3175 | struct fs_struct *fs = current->fs; |
3171 | struct mnt_namespace *mnt_ns = ns; | 3176 | struct mnt_namespace *mnt_ns = to_mnt_ns(ns); |
3172 | struct path root; | 3177 | struct path root; |
3173 | 3178 | ||
3174 | if (!ns_capable(mnt_ns->user_ns, CAP_SYS_ADMIN) || | 3179 | if (!ns_capable(mnt_ns->user_ns, CAP_SYS_ADMIN) || |
@@ -3200,8 +3205,8 @@ static int mntns_install(struct nsproxy *nsproxy, void *ns) | |||
3200 | 3205 | ||
3201 | static unsigned int mntns_inum(void *ns) | 3206 | static unsigned int mntns_inum(void *ns) |
3202 | { | 3207 | { |
3203 | struct mnt_namespace *mnt_ns = ns; | 3208 | struct ns_common *p = ns; |
3204 | return mnt_ns->ns.inum; | 3209 | return p->inum; |
3205 | } | 3210 | } |
3206 | 3211 | ||
3207 | const struct proc_ns_operations mntns_operations = { | 3212 | const struct proc_ns_operations mntns_operations = { |