[Devel] [PATCH RH7 12/32] make mntns ->get()/->put()/->install()/->inum() work with &mnt_ns->ns
Pavel Tikhomirov
ptikhomirov at virtuozzo.com
Mon Jun 8 20:05:42 MSK 2020
From: Al Viro <viro at zeniv.linux.org.uk>
Acked-by: "Eric W. Biederman" <ebiederm at xmission.com>
Signed-off-by: Al Viro <viro at zeniv.linux.org.uk>
(cherry picked from VZ8 commit 58be28256d98a6b996b20f49130ea11afb8de75a)
https://jira.sw.ru/browse/PSBM-102357
Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
---
fs/namespace.c | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)
diff --git a/fs/namespace.c b/fs/namespace.c
index cd08475300ef..f137ac232d4e 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -1890,6 +1890,11 @@ static bool is_mnt_ns_file(struct dentry *dentry)
return true;
}
+struct mnt_namespace *to_mnt_ns(struct ns_common *ns)
+{
+ return container_of(ns, struct mnt_namespace, ns);
+}
+
static bool mnt_ns_loop(struct dentry *dentry)
{
/* Could bind mounting the mount namespace inode cause a
@@ -1899,7 +1904,7 @@ static bool mnt_ns_loop(struct dentry *dentry)
if (!is_mnt_ns_file(dentry))
return false;
- mnt_ns = get_proc_ns(dentry->d_inode)->ns;
+ mnt_ns = to_mnt_ns(get_proc_ns(dentry->d_inode)->ns);
return current->nsproxy->mnt_ns->seq >= mnt_ns->seq;
}
@@ -3850,14 +3855,14 @@ bool mnt_may_suid(struct vfsmount *mnt)
static void *mntns_get(struct task_struct *task)
{
- struct mnt_namespace *ns = NULL;
+ struct ns_common *ns = NULL;
struct nsproxy *nsproxy;
task_lock(task);
nsproxy = task->nsproxy;
if (nsproxy) {
- ns = nsproxy->mnt_ns;
- get_mnt_ns(ns);
+ ns = &nsproxy->mnt_ns->ns;
+ get_mnt_ns(to_mnt_ns(ns));
}
task_unlock(task);
@@ -3866,13 +3871,13 @@ static void *mntns_get(struct task_struct *task)
static void mntns_put(void *ns)
{
- put_mnt_ns(ns);
+ put_mnt_ns(to_mnt_ns(ns));
}
static int mntns_install(struct nsproxy *nsproxy, void *ns)
{
struct fs_struct *fs = current->fs;
- struct mnt_namespace *mnt_ns = ns, *old_mnt_ns;
+ struct mnt_namespace *mnt_ns = to_mnt_ns(ns), *old_mnt_ns;
struct path root;
int err;
@@ -3910,8 +3915,8 @@ static int mntns_install(struct nsproxy *nsproxy, void *ns)
static unsigned int mntns_inum(void *ns)
{
- struct mnt_namespace *mnt_ns = ns;
- return mnt_ns->ns.inum;
+ struct ns_common *p = ns;
+ return p->inum;
}
const struct proc_ns_operations mntns_operations = {
--
2.24.1
More information about the Devel
mailing list