From: Cedric Le Goater Add an identifier to nsproxy. The default init_ns_proxy has identifier 0 and allocated nsproxies are given -1. This identifier will be used by a new syscall sys_bind_ns. Signed-off-by: Cedric Le Goater Cc: Kirill Korotaev Cc: Eric W. Biederman Cc: Herbert Poetzl Cc: Sukadev Bhattiprolu Signed-off-by: Andrew Morton --- include/linux/init_task.h | 1 + include/linux/nsproxy.h | 1 + kernel/nsproxy.c | 4 +++- 3 files changed, 5 insertions(+), 1 deletion(-) diff -puN include/linux/init_task.h~add-an-identifier-to-nsproxy include/linux/init_task.h --- a/include/linux/init_task.h~add-an-identifier-to-nsproxy +++ a/include/linux/init_task.h @@ -75,6 +75,7 @@ extern struct nsproxy init_nsproxy; #define INIT_NSPROXY(nsproxy) { \ .count = ATOMIC_INIT(1), \ .nslock = SPIN_LOCK_UNLOCKED, \ + .id = 0, \ .uts_ns = &init_uts_ns, \ .mnt_ns = NULL, \ INIT_IPC_NS(ipc_ns) \ diff -puN include/linux/nsproxy.h~add-an-identifier-to-nsproxy include/linux/nsproxy.h --- a/include/linux/nsproxy.h~add-an-identifier-to-nsproxy +++ a/include/linux/nsproxy.h @@ -23,6 +23,7 @@ struct ipc_namespace; struct nsproxy { atomic_t count; spinlock_t nslock; + unsigned long id; struct uts_namespace *uts_ns; struct ipc_namespace *ipc_ns; struct mnt_namespace *mnt_ns; diff -puN kernel/nsproxy.c~add-an-identifier-to-nsproxy kernel/nsproxy.c --- a/kernel/nsproxy.c~add-an-identifier-to-nsproxy +++ a/kernel/nsproxy.c @@ -45,8 +45,10 @@ static inline struct nsproxy *clone_name struct nsproxy *ns; ns = kmemdup(orig, sizeof(struct nsproxy), GFP_KERNEL); - if (ns) + if (ns) { atomic_set(&ns->count, 1); + ns->id = -1; + } return ns; } _