]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
copy address of proc_ns_ops into ns_common
authorAl Viro <viro@zeniv.linux.org.uk>
Sat, 1 Nov 2014 06:32:53 +0000 (02:32 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Thu, 4 Dec 2014 19:34:47 +0000 (14:34 -0500)
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
13 files changed:
fs/namespace.c
fs/proc/inode.c
include/linux/ns_common.h
init/version.c
ipc/msgutil.c
ipc/namespace.c
kernel/nsproxy.c
kernel/pid.c
kernel/pid_namespace.c
kernel/user.c
kernel/user_namespace.c
kernel/utsname.c
net/core/net_namespace.c

index 30738d200866d96dd47a22997fa76afbdd7a84f6..f815218f92d318d84a4c9ba950846dcd16d8a573 100644 (file)
@@ -2672,6 +2672,7 @@ static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns)
                kfree(new_ns);
                return ERR_PTR(ret);
        }
+       new_ns->ns.ops = &mntns_operations;
        new_ns->seq = atomic64_add_return(1, &mnt_ns_seq);
        atomic_set(&new_ns->count, 1);
        new_ns->root = NULL;
index 43b703c6cd3b00320b4e2568b66f2329b2bd0134..a212996e0987cfe1d1858a9741f53df96cec9c88 100644 (file)
@@ -32,7 +32,6 @@ static void proc_evict_inode(struct inode *inode)
 {
        struct proc_dir_entry *de;
        struct ctl_table_header *head;
-       const struct proc_ns_operations *ns_ops;
        struct ns_common *ns;
 
        truncate_inode_pages_final(&inode->i_data);
@@ -51,10 +50,9 @@ static void proc_evict_inode(struct inode *inode)
                sysctl_head_put(head);
        }
        /* Release any associated namespace */
-       ns_ops = PROC_I(inode)->ns.ns_ops;
        ns = PROC_I(inode)->ns.ns;
-       if (ns_ops && ns)
-               ns_ops->put(ns);
+       if (ns && ns->ops)
+               ns->ops->put(ns);
 }
 
 static struct kmem_cache * proc_inode_cachep;
index e7db1cd54047489065d692d87b95e1176f07e2c7..ce23cf4bbe6902d17e0a920de2e4a231e7176ee7 100644 (file)
@@ -1,7 +1,10 @@
 #ifndef _LINUX_NS_COMMON_H
 #define _LINUX_NS_COMMON_H
 
+struct proc_ns_operations;
+
 struct ns_common {
+       const struct proc_ns_operations *ops;
        unsigned int inum;
 };
 
index e23dbdabb26bfd89ddc32781195cc209221ebb1c..fe41a63efed63b54831b2546df1553288052b97c 100644 (file)
@@ -36,6 +36,9 @@ struct uts_namespace init_uts_ns = {
        },
        .user_ns = &init_user_ns,
        .ns.inum = PROC_UTS_INIT_INO,
+#ifdef CONFIG_UTS_NS
+       .ns.ops = &utsns_operations,
+#endif
 };
 EXPORT_SYMBOL_GPL(init_uts_ns);
 
index 5930471a29022e8ed1b9e47d4bcc8b8f78e08379..2b491590ebab1f7fac5b6fecaf632a9a5aebada7 100644 (file)
@@ -32,6 +32,9 @@ struct ipc_namespace init_ipc_ns = {
        .count          = ATOMIC_INIT(1),
        .user_ns = &init_user_ns,
        .ns.inum = PROC_IPC_INIT_INO,
+#ifdef CONFIG_IPC_NS
+       .ns.ops = &ipcns_operations,
+#endif
 };
 
 atomic_t nr_ipc_ns = ATOMIC_INIT(1);
index bcdd7a5c122aa6983c4c89eb359eea6e99a3bb2a..382e2aa42d8aac77692702d50dd9de4ffaec0e2f 100644 (file)
@@ -31,6 +31,7 @@ static struct ipc_namespace *create_ipc_ns(struct user_namespace *user_ns,
                kfree(ns);
                return ERR_PTR(err);
        }
+       ns->ns.ops = &ipcns_operations;
 
        atomic_set(&ns->count, 1);
        err = mq_init_ns(ns);
index ef42d0ab3115709adbe4b4a27c71f3638a481954..87c37221cb7f66a6b7e1e082821a8857479177e6 100644 (file)
@@ -220,11 +220,11 @@ void exit_task_namespaces(struct task_struct *p)
 
 SYSCALL_DEFINE2(setns, int, fd, int, nstype)
 {
-       const struct proc_ns_operations *ops;
        struct task_struct *tsk = current;
        struct nsproxy *new_nsproxy;
        struct proc_ns *ei;
        struct file *file;
+       struct ns_common *ns;
        int err;
 
        file = proc_ns_fget(fd);
@@ -233,8 +233,8 @@ SYSCALL_DEFINE2(setns, int, fd, int, nstype)
 
        err = -EINVAL;
        ei = get_proc_ns(file_inode(file));
-       ops = ei->ns_ops;
-       if (nstype && (ops->type != nstype))
+       ns = ei->ns;
+       if (nstype && (ns->ops->type != nstype))
                goto out;
 
        new_nsproxy = create_new_namespaces(0, tsk, current_user_ns(), tsk->fs);
@@ -243,7 +243,7 @@ SYSCALL_DEFINE2(setns, int, fd, int, nstype)
                goto out;
        }
 
-       err = ops->install(new_nsproxy, ei->ns);
+       err = ns->ops->install(new_nsproxy, ns);
        if (err) {
                free_nsproxy(new_nsproxy);
                goto out;
index 3650698cf1dc9b797593c30d984fa89cd3b4b0be..c17a993a4d2a3ef4b35ac42c5afe4ca89cb1d5f4 100644 (file)
@@ -80,6 +80,9 @@ struct pid_namespace init_pid_ns = {
        .child_reaper = &init_task,
        .user_ns = &init_user_ns,
        .ns.inum = PROC_PID_INIT_INO,
+#ifdef CONFIG_PID_NS
+       .ns.ops = &pidns_operations,
+#endif
 };
 EXPORT_SYMBOL_GPL(init_pid_ns);
 
index 5aa9158a84d558a2e30c6e1d1c418173102fcc50..e1bafe3b47bb4af35475754434fdd53ac8337318 100644 (file)
@@ -108,6 +108,7 @@ static struct pid_namespace *create_pid_namespace(struct user_namespace *user_ns
        err = ns_alloc_inum(&ns->ns);
        if (err)
                goto out_free_map;
+       ns->ns.ops = &pidns_operations;
 
        kref_init(&ns->kref);
        ns->level = level;
index a7ca84bad8e6c544b77537fe5a295fc81ef9381d..69b800aebf13574a4b3a57445016a62d83e9d87b 100644 (file)
@@ -51,6 +51,9 @@ struct user_namespace init_user_ns = {
        .owner = GLOBAL_ROOT_UID,
        .group = GLOBAL_ROOT_GID,
        .ns.inum = PROC_USER_INIT_INO,
+#ifdef CONFIG_USER_NS
+       .ns.ops = &userns_operations,
+#endif
 #ifdef CONFIG_PERSISTENT_KEYRINGS
        .persistent_keyring_register_sem =
        __RWSEM_INITIALIZER(init_user_ns.persistent_keyring_register_sem),
index 6bf8177768e5d2ad727e5fe0fd9d7a8db8126b15..1491ad00388fe1c8e91fe7fdc85caf334ff99f56 100644 (file)
@@ -91,6 +91,7 @@ int create_user_ns(struct cred *new)
                kmem_cache_free(user_ns_cachep, ns);
                return ret;
        }
+       ns->ns.ops = &userns_operations;
 
        atomic_set(&ns->count, 1);
        /* Leave the new->user_ns reference with the new user namespace. */
index c2a2b321d88a9951e38ed90a2091f4cfbc36edee..831ea71082320e1859daa1f434008816c3052333 100644 (file)
@@ -48,6 +48,8 @@ static struct uts_namespace *clone_uts_ns(struct user_namespace *user_ns,
                return ERR_PTR(err);
        }
 
+       ns->ns.ops = &utsns_operations;
+
        down_read(&uts_sem);
        memcpy(&ns->name, &old_ns->name, sizeof(ns->name));
        ns->user_ns = get_user_ns(user_ns);
index da775f53f3fd1fb4449f855309a8008650a8af4d..4d4acaf7b4985012e2c4eebc3da711d359d74b1e 100644 (file)
@@ -339,6 +339,7 @@ struct net *get_net_ns_by_fd(int fd)
 {
        struct proc_ns *ei;
        struct file *file;
+       struct ns_common *ns;
        struct net *net;
 
        file = proc_ns_fget(fd);
@@ -346,8 +347,9 @@ struct net *get_net_ns_by_fd(int fd)
                return ERR_CAST(file);
 
        ei = get_proc_ns(file_inode(file));
-       if (ei->ns_ops == &netns_operations)
-               net = get_net(container_of(ei->ns, struct net, ns));
+       ns = ei->ns;
+       if (ns->ops == &netns_operations)
+               net = get_net(container_of(ns, struct net, ns));
        else
                net = ERR_PTR(-EINVAL);
 
@@ -386,6 +388,9 @@ EXPORT_SYMBOL_GPL(get_net_ns_by_pid);
 
 static __net_init int net_ns_net_init(struct net *net)
 {
+#ifdef CONFIG_NET_NS
+       net->ns.ops = &netns_operations;
+#endif
        return ns_alloc_inum(&net->ns);
 }