aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/mount.h3
-rw-r--r--fs/namespace.c6
-rw-r--r--include/linux/ipc_namespace.h3
-rw-r--r--include/linux/ns_common.h8
-rw-r--r--include/linux/pid_namespace.h3
-rw-r--r--include/linux/user_namespace.h3
-rw-r--r--include/linux/utsname.h3
-rw-r--r--include/net/net_namespace.h3
-rw-r--r--init/version.c2
-rw-r--r--ipc/msgutil.c2
-rw-r--r--ipc/namespace.c8
-rw-r--r--kernel/pid.c2
-rw-r--r--kernel/pid_namespace.c6
-rw-r--r--kernel/user.c2
-rw-r--r--kernel/user_namespace.c6
-rw-r--r--kernel/utsname.c6
-rw-r--r--net/core/net_namespace.c6
17 files changed, 43 insertions, 29 deletions
diff --git a/fs/mount.h b/fs/mount.h
index f82c62840905..0ad6f760ce52 100644
--- a/fs/mount.h
+++ b/fs/mount.h
@@ -1,10 +1,11 @@
1#include <linux/mount.h> 1#include <linux/mount.h>
2#include <linux/seq_file.h> 2#include <linux/seq_file.h>
3#include <linux/poll.h> 3#include <linux/poll.h>
4#include <linux/ns_common.h>
4 5
5struct mnt_namespace { 6struct mnt_namespace {
6 atomic_t count; 7 atomic_t count;
7 unsigned int proc_inum; 8 struct ns_common ns;
8 struct mount * root; 9 struct mount * root;
9 struct list_head list; 10 struct list_head list;
10 struct user_namespace *user_ns; 11 struct user_namespace *user_ns;
diff --git a/fs/namespace.c b/fs/namespace.c
index 5b66b2b3624d..adc2ea2532a0 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -2640,7 +2640,7 @@ dput_out:
2640 2640
2641static void free_mnt_ns(struct mnt_namespace *ns) 2641static void free_mnt_ns(struct mnt_namespace *ns)
2642{ 2642{
2643 proc_free_inum(ns->proc_inum); 2643 proc_free_inum(ns->ns.inum);
2644 put_user_ns(ns->user_ns); 2644 put_user_ns(ns->user_ns);
2645 kfree(ns); 2645 kfree(ns);
2646} 2646}
@@ -2662,7 +2662,7 @@ static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns)
2662 new_ns = kmalloc(sizeof(struct mnt_namespace), GFP_KERNEL); 2662 new_ns = kmalloc(sizeof(struct mnt_namespace), GFP_KERNEL);
2663 if (!new_ns) 2663 if (!new_ns)
2664 return ERR_PTR(-ENOMEM); 2664 return ERR_PTR(-ENOMEM);
2665 ret = proc_alloc_inum(&new_ns->proc_inum); 2665 ret = proc_alloc_inum(&new_ns->ns.inum);
2666 if (ret) { 2666 if (ret) {
2667 kfree(new_ns); 2667 kfree(new_ns);
2668 return ERR_PTR(ret); 2668 return ERR_PTR(ret);
@@ -3201,7 +3201,7 @@ static int mntns_install(struct nsproxy *nsproxy, void *ns)
3201static unsigned int mntns_inum(void *ns) 3201static unsigned int mntns_inum(void *ns)
3202{ 3202{
3203 struct mnt_namespace *mnt_ns = ns; 3203 struct mnt_namespace *mnt_ns = ns;
3204 return mnt_ns->proc_inum; 3204 return mnt_ns->ns.inum;
3205} 3205}
3206 3206
3207const struct proc_ns_operations mntns_operations = { 3207const struct proc_ns_operations mntns_operations = {
diff --git a/include/linux/ipc_namespace.h b/include/linux/ipc_namespace.h
index 35e7eca4e33b..52a640128151 100644
--- a/include/linux/ipc_namespace.h
+++ b/include/linux/ipc_namespace.h
@@ -6,6 +6,7 @@
6#include <linux/rwsem.h> 6#include <linux/rwsem.h>
7#include <linux/notifier.h> 7#include <linux/notifier.h>
8#include <linux/nsproxy.h> 8#include <linux/nsproxy.h>
9#include <linux/ns_common.h>
9 10
10/* 11/*
11 * ipc namespace events 12 * ipc namespace events
@@ -68,7 +69,7 @@ struct ipc_namespace {
68 /* user_ns which owns the ipc ns */ 69 /* user_ns which owns the ipc ns */
69 struct user_namespace *user_ns; 70 struct user_namespace *user_ns;
70 71
71 unsigned int proc_inum; 72 struct ns_common ns;
72}; 73};
73 74
74extern struct ipc_namespace init_ipc_ns; 75extern struct ipc_namespace init_ipc_ns;
diff --git a/include/linux/ns_common.h b/include/linux/ns_common.h
new file mode 100644
index 000000000000..e7db1cd54047
--- /dev/null
+++ b/include/linux/ns_common.h
@@ -0,0 +1,8 @@
1#ifndef _LINUX_NS_COMMON_H
2#define _LINUX_NS_COMMON_H
3
4struct ns_common {
5 unsigned int inum;
6};
7
8#endif
diff --git a/include/linux/pid_namespace.h b/include/linux/pid_namespace.h
index 1997ffc295a7..b9cf6c51b181 100644
--- a/include/linux/pid_namespace.h
+++ b/include/linux/pid_namespace.h
@@ -8,6 +8,7 @@
8#include <linux/threads.h> 8#include <linux/threads.h>
9#include <linux/nsproxy.h> 9#include <linux/nsproxy.h>
10#include <linux/kref.h> 10#include <linux/kref.h>
11#include <linux/ns_common.h>
11 12
12struct pidmap { 13struct pidmap {
13 atomic_t nr_free; 14 atomic_t nr_free;
@@ -43,7 +44,7 @@ struct pid_namespace {
43 kgid_t pid_gid; 44 kgid_t pid_gid;
44 int hide_pid; 45 int hide_pid;
45 int reboot; /* group exit code if this pidns was rebooted */ 46 int reboot; /* group exit code if this pidns was rebooted */
46 unsigned int proc_inum; 47 struct ns_common ns;
47}; 48};
48 49
49extern struct pid_namespace init_pid_ns; 50extern struct pid_namespace init_pid_ns;
diff --git a/include/linux/user_namespace.h b/include/linux/user_namespace.h
index e95372654f09..4cf06c140e21 100644
--- a/include/linux/user_namespace.h
+++ b/include/linux/user_namespace.h
@@ -3,6 +3,7 @@
3 3
4#include <linux/kref.h> 4#include <linux/kref.h>
5#include <linux/nsproxy.h> 5#include <linux/nsproxy.h>
6#include <linux/ns_common.h>
6#include <linux/sched.h> 7#include <linux/sched.h>
7#include <linux/err.h> 8#include <linux/err.h>
8 9
@@ -26,7 +27,7 @@ struct user_namespace {
26 int level; 27 int level;
27 kuid_t owner; 28 kuid_t owner;
28 kgid_t group; 29 kgid_t group;
29 unsigned int proc_inum; 30 struct ns_common ns;
30 31
31 /* Register of per-UID persistent keyrings for this namespace */ 32 /* Register of per-UID persistent keyrings for this namespace */
32#ifdef CONFIG_PERSISTENT_KEYRINGS 33#ifdef CONFIG_PERSISTENT_KEYRINGS
diff --git a/include/linux/utsname.h b/include/linux/utsname.h
index 239e27733d6c..5093f58ae192 100644
--- a/include/linux/utsname.h
+++ b/include/linux/utsname.h
@@ -5,6 +5,7 @@
5#include <linux/sched.h> 5#include <linux/sched.h>
6#include <linux/kref.h> 6#include <linux/kref.h>
7#include <linux/nsproxy.h> 7#include <linux/nsproxy.h>
8#include <linux/ns_common.h>
8#include <linux/err.h> 9#include <linux/err.h>
9#include <uapi/linux/utsname.h> 10#include <uapi/linux/utsname.h>
10 11
@@ -23,7 +24,7 @@ struct uts_namespace {
23 struct kref kref; 24 struct kref kref;
24 struct new_utsname name; 25 struct new_utsname name;
25 struct user_namespace *user_ns; 26 struct user_namespace *user_ns;
26 unsigned int proc_inum; 27 struct ns_common ns;
27}; 28};
28extern struct uts_namespace init_uts_ns; 29extern struct uts_namespace init_uts_ns;
29 30
diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
index e0d64667a4b3..2e8756b8c775 100644
--- a/include/net/net_namespace.h
+++ b/include/net/net_namespace.h
@@ -26,6 +26,7 @@
26#endif 26#endif
27#include <net/netns/nftables.h> 27#include <net/netns/nftables.h>
28#include <net/netns/xfrm.h> 28#include <net/netns/xfrm.h>
29#include <linux/ns_common.h>
29 30
30struct user_namespace; 31struct user_namespace;
31struct proc_dir_entry; 32struct proc_dir_entry;
@@ -60,7 +61,7 @@ struct net {
60 61
61 struct user_namespace *user_ns; /* Owning user namespace */ 62 struct user_namespace *user_ns; /* Owning user namespace */
62 63
63 unsigned int proc_inum; 64 struct ns_common ns;
64 65
65 struct proc_dir_entry *proc_net; 66 struct proc_dir_entry *proc_net;
66 struct proc_dir_entry *proc_net_stat; 67 struct proc_dir_entry *proc_net_stat;
diff --git a/init/version.c b/init/version.c
index 1a4718e500fe..e23dbdabb26b 100644
--- a/init/version.c
+++ b/init/version.c
@@ -35,7 +35,7 @@ struct uts_namespace init_uts_ns = {
35 .domainname = UTS_DOMAINNAME, 35 .domainname = UTS_DOMAINNAME,
36 }, 36 },
37 .user_ns = &init_user_ns, 37 .user_ns = &init_user_ns,
38 .proc_inum = PROC_UTS_INIT_INO, 38 .ns.inum = PROC_UTS_INIT_INO,
39}; 39};
40EXPORT_SYMBOL_GPL(init_uts_ns); 40EXPORT_SYMBOL_GPL(init_uts_ns);
41 41
diff --git a/ipc/msgutil.c b/ipc/msgutil.c
index 7e7095974d54..5930471a2902 100644
--- a/ipc/msgutil.c
+++ b/ipc/msgutil.c
@@ -31,7 +31,7 @@ DEFINE_SPINLOCK(mq_lock);
31struct ipc_namespace init_ipc_ns = { 31struct ipc_namespace init_ipc_ns = {
32 .count = ATOMIC_INIT(1), 32 .count = ATOMIC_INIT(1),
33 .user_ns = &init_user_ns, 33 .user_ns = &init_user_ns,
34 .proc_inum = PROC_IPC_INIT_INO, 34 .ns.inum = PROC_IPC_INIT_INO,
35}; 35};
36 36
37atomic_t nr_ipc_ns = ATOMIC_INIT(1); 37atomic_t nr_ipc_ns = ATOMIC_INIT(1);
diff --git a/ipc/namespace.c b/ipc/namespace.c
index b54468e48e32..177fa9db391d 100644
--- a/ipc/namespace.c
+++ b/ipc/namespace.c
@@ -26,7 +26,7 @@ static struct ipc_namespace *create_ipc_ns(struct user_namespace *user_ns,
26 if (ns == NULL) 26 if (ns == NULL)
27 return ERR_PTR(-ENOMEM); 27 return ERR_PTR(-ENOMEM);
28 28
29 err = proc_alloc_inum(&ns->proc_inum); 29 err = proc_alloc_inum(&ns->ns.inum);
30 if (err) { 30 if (err) {
31 kfree(ns); 31 kfree(ns);
32 return ERR_PTR(err); 32 return ERR_PTR(err);
@@ -35,7 +35,7 @@ static struct ipc_namespace *create_ipc_ns(struct user_namespace *user_ns,
35 atomic_set(&ns->count, 1); 35 atomic_set(&ns->count, 1);
36 err = mq_init_ns(ns); 36 err = mq_init_ns(ns);
37 if (err) { 37 if (err) {
38 proc_free_inum(ns->proc_inum); 38 proc_free_inum(ns->ns.inum);
39 kfree(ns); 39 kfree(ns);
40 return ERR_PTR(err); 40 return ERR_PTR(err);
41 } 41 }
@@ -119,7 +119,7 @@ static void free_ipc_ns(struct ipc_namespace *ns)
119 */ 119 */
120 ipcns_notify(IPCNS_REMOVED); 120 ipcns_notify(IPCNS_REMOVED);
121 put_user_ns(ns->user_ns); 121 put_user_ns(ns->user_ns);
122 proc_free_inum(ns->proc_inum); 122 proc_free_inum(ns->ns.inum);
123 kfree(ns); 123 kfree(ns);
124} 124}
125 125
@@ -186,7 +186,7 @@ static unsigned int ipcns_inum(void *vp)
186{ 186{
187 struct ipc_namespace *ns = vp; 187 struct ipc_namespace *ns = vp;
188 188
189 return ns->proc_inum; 189 return ns->ns.inum;
190} 190}
191 191
192const struct proc_ns_operations ipcns_operations = { 192const struct proc_ns_operations ipcns_operations = {
diff --git a/kernel/pid.c b/kernel/pid.c
index 9b9a26698144..3650698cf1dc 100644
--- a/kernel/pid.c
+++ b/kernel/pid.c
@@ -79,7 +79,7 @@ struct pid_namespace init_pid_ns = {
79 .level = 0, 79 .level = 0,
80 .child_reaper = &init_task, 80 .child_reaper = &init_task,
81 .user_ns = &init_user_ns, 81 .user_ns = &init_user_ns,
82 .proc_inum = PROC_PID_INIT_INO, 82 .ns.inum = PROC_PID_INIT_INO,
83}; 83};
84EXPORT_SYMBOL_GPL(init_pid_ns); 84EXPORT_SYMBOL_GPL(init_pid_ns);
85 85
diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c
index db95d8eb761b..99e27e5bf906 100644
--- a/kernel/pid_namespace.c
+++ b/kernel/pid_namespace.c
@@ -105,7 +105,7 @@ static struct pid_namespace *create_pid_namespace(struct user_namespace *user_ns
105 if (ns->pid_cachep == NULL) 105 if (ns->pid_cachep == NULL)
106 goto out_free_map; 106 goto out_free_map;
107 107
108 err = proc_alloc_inum(&ns->proc_inum); 108 err = proc_alloc_inum(&ns->ns.inum);
109 if (err) 109 if (err)
110 goto out_free_map; 110 goto out_free_map;
111 111
@@ -142,7 +142,7 @@ static void destroy_pid_namespace(struct pid_namespace *ns)
142{ 142{
143 int i; 143 int i;
144 144
145 proc_free_inum(ns->proc_inum); 145 proc_free_inum(ns->ns.inum);
146 for (i = 0; i < PIDMAP_ENTRIES; i++) 146 for (i = 0; i < PIDMAP_ENTRIES; i++)
147 kfree(ns->pidmap[i].page); 147 kfree(ns->pidmap[i].page);
148 put_user_ns(ns->user_ns); 148 put_user_ns(ns->user_ns);
@@ -365,7 +365,7 @@ static int pidns_install(struct nsproxy *nsproxy, void *ns)
365static unsigned int pidns_inum(void *ns) 365static unsigned int pidns_inum(void *ns)
366{ 366{
367 struct pid_namespace *pid_ns = ns; 367 struct pid_namespace *pid_ns = ns;
368 return pid_ns->proc_inum; 368 return pid_ns->ns.inum;
369} 369}
370 370
371const struct proc_ns_operations pidns_operations = { 371const struct proc_ns_operations pidns_operations = {
diff --git a/kernel/user.c b/kernel/user.c
index 4efa39350e44..a7ca84bad8e6 100644
--- a/kernel/user.c
+++ b/kernel/user.c
@@ -50,7 +50,7 @@ struct user_namespace init_user_ns = {
50 .count = ATOMIC_INIT(3), 50 .count = ATOMIC_INIT(3),
51 .owner = GLOBAL_ROOT_UID, 51 .owner = GLOBAL_ROOT_UID,
52 .group = GLOBAL_ROOT_GID, 52 .group = GLOBAL_ROOT_GID,
53 .proc_inum = PROC_USER_INIT_INO, 53 .ns.inum = PROC_USER_INIT_INO,
54#ifdef CONFIG_PERSISTENT_KEYRINGS 54#ifdef CONFIG_PERSISTENT_KEYRINGS
55 .persistent_keyring_register_sem = 55 .persistent_keyring_register_sem =
56 __RWSEM_INITIALIZER(init_user_ns.persistent_keyring_register_sem), 56 __RWSEM_INITIALIZER(init_user_ns.persistent_keyring_register_sem),
diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c
index aa312b0dc3ec..fde584082673 100644
--- a/kernel/user_namespace.c
+++ b/kernel/user_namespace.c
@@ -86,7 +86,7 @@ int create_user_ns(struct cred *new)
86 if (!ns) 86 if (!ns)
87 return -ENOMEM; 87 return -ENOMEM;
88 88
89 ret = proc_alloc_inum(&ns->proc_inum); 89 ret = proc_alloc_inum(&ns->ns.inum);
90 if (ret) { 90 if (ret) {
91 kmem_cache_free(user_ns_cachep, ns); 91 kmem_cache_free(user_ns_cachep, ns);
92 return ret; 92 return ret;
@@ -136,7 +136,7 @@ void free_user_ns(struct user_namespace *ns)
136#ifdef CONFIG_PERSISTENT_KEYRINGS 136#ifdef CONFIG_PERSISTENT_KEYRINGS
137 key_put(ns->persistent_keyring_register); 137 key_put(ns->persistent_keyring_register);
138#endif 138#endif
139 proc_free_inum(ns->proc_inum); 139 proc_free_inum(ns->ns.inum);
140 kmem_cache_free(user_ns_cachep, ns); 140 kmem_cache_free(user_ns_cachep, ns);
141 ns = parent; 141 ns = parent;
142 } while (atomic_dec_and_test(&parent->count)); 142 } while (atomic_dec_and_test(&parent->count));
@@ -891,7 +891,7 @@ static int userns_install(struct nsproxy *nsproxy, void *ns)
891static unsigned int userns_inum(void *ns) 891static unsigned int userns_inum(void *ns)
892{ 892{
893 struct user_namespace *user_ns = ns; 893 struct user_namespace *user_ns = ns;
894 return user_ns->proc_inum; 894 return user_ns->ns.inum;
895} 895}
896 896
897const struct proc_ns_operations userns_operations = { 897const struct proc_ns_operations userns_operations = {
diff --git a/kernel/utsname.c b/kernel/utsname.c
index 883aaaa7de8a..b1cd00b828f2 100644
--- a/kernel/utsname.c
+++ b/kernel/utsname.c
@@ -42,7 +42,7 @@ static struct uts_namespace *clone_uts_ns(struct user_namespace *user_ns,
42 if (!ns) 42 if (!ns)
43 return ERR_PTR(-ENOMEM); 43 return ERR_PTR(-ENOMEM);
44 44
45 err = proc_alloc_inum(&ns->proc_inum); 45 err = proc_alloc_inum(&ns->ns.inum);
46 if (err) { 46 if (err) {
47 kfree(ns); 47 kfree(ns);
48 return ERR_PTR(err); 48 return ERR_PTR(err);
@@ -84,7 +84,7 @@ void free_uts_ns(struct kref *kref)
84 84
85 ns = container_of(kref, struct uts_namespace, kref); 85 ns = container_of(kref, struct uts_namespace, kref);
86 put_user_ns(ns->user_ns); 86 put_user_ns(ns->user_ns);
87 proc_free_inum(ns->proc_inum); 87 proc_free_inum(ns->ns.inum);
88 kfree(ns); 88 kfree(ns);
89} 89}
90 90
@@ -127,7 +127,7 @@ static unsigned int utsns_inum(void *vp)
127{ 127{
128 struct uts_namespace *ns = vp; 128 struct uts_namespace *ns = vp;
129 129
130 return ns->proc_inum; 130 return ns->ns.inum;
131} 131}
132 132
133const struct proc_ns_operations utsns_operations = { 133const struct proc_ns_operations utsns_operations = {
diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
index 7f155175bba8..f2f756ce99d7 100644
--- a/net/core/net_namespace.c
+++ b/net/core/net_namespace.c
@@ -386,12 +386,12 @@ EXPORT_SYMBOL_GPL(get_net_ns_by_pid);
386 386
387static __net_init int net_ns_net_init(struct net *net) 387static __net_init int net_ns_net_init(struct net *net)
388{ 388{
389 return proc_alloc_inum(&net->proc_inum); 389 return proc_alloc_inum(&net->ns.inum);
390} 390}
391 391
392static __net_exit void net_ns_net_exit(struct net *net) 392static __net_exit void net_ns_net_exit(struct net *net)
393{ 393{
394 proc_free_inum(net->proc_inum); 394 proc_free_inum(net->ns.inum);
395} 395}
396 396
397static struct pernet_operations __net_initdata net_ns_ops = { 397static struct pernet_operations __net_initdata net_ns_ops = {
@@ -664,7 +664,7 @@ static int netns_install(struct nsproxy *nsproxy, void *ns)
664static unsigned int netns_inum(void *ns) 664static unsigned int netns_inum(void *ns)
665{ 665{
666 struct net *net = ns; 666 struct net *net = ns;
667 return net->proc_inum; 667 return net->ns.inum;
668} 668}
669 669
670const struct proc_ns_operations netns_operations = { 670const struct proc_ns_operations netns_operations = {