From: Kirill Korotaev Fix IPC namespace compilation when `make allnoconfig` is used. Checked all 3 possible combinations of config options. Cc: Pavel Emelianov Cc: "Eric W. Biederman" Cc: Cedric Le Goater Signed-off-by: Andrew Morton --- include/linux/init_task.h | 3 ++- include/linux/ipc.h | 18 ++++++++++++++++++ ipc/util.c | 15 --------------- kernel/fork.c | 10 ++++++++++ 4 files changed, 30 insertions(+), 16 deletions(-) diff -puN include/linux/init_task.h~ipc-namespace-utils-compilation-fix include/linux/init_task.h --- a/include/linux/init_task.h~ipc-namespace-utils-compilation-fix +++ a/include/linux/init_task.h @@ -4,6 +4,7 @@ #include #include #include +#include #define INIT_FDTABLE \ { \ @@ -72,8 +73,8 @@ extern struct nsproxy init_nsproxy; .count = ATOMIC_INIT(1), \ .nslock = SPIN_LOCK_UNLOCKED, \ .uts_ns = &init_uts_ns, \ - .ipc_ns = &init_ipc_ns, \ .namespace = NULL, \ + INIT_IPC_NS(ipc_ns) \ } #define INIT_SIGHAND(sighand) { \ diff -puN include/linux/ipc.h~ipc-namespace-utils-compilation-fix include/linux/ipc.h --- a/include/linux/ipc.h~ipc-namespace-utils-compilation-fix +++ a/include/linux/ipc.h @@ -88,20 +88,38 @@ struct ipc_namespace { }; extern struct ipc_namespace init_ipc_ns; + +#ifdef CONFIG_SYSVIPC +#define INIT_IPC_NS(ns) .ns = &init_ipc_ns, +#else +#define INIT_IPC_NS(ns) +#endif + +#ifdef CONFIG_IPC_NS extern void free_ipc_ns(struct kref *kref); extern int copy_ipcs(unsigned long flags, struct task_struct *tsk); extern int unshare_ipcs(unsigned long flags, struct ipc_namespace **ns); +#else +static inline int copy_ipcs(unsigned long flags, struct task_struct *tsk) +{ + return 0; +} +#endif static inline struct ipc_namespace *get_ipc_ns(struct ipc_namespace *ns) { +#ifdef CONFIG_IPC_NS if (ns) kref_get(&ns->kref); +#endif return ns; } static inline void put_ipc_ns(struct ipc_namespace *ns) { +#ifdef CONFIG_IPC_NS kref_put(&ns->kref, free_ipc_ns); +#endif } #endif /* __KERNEL__ */ diff -puN ipc/util.c~ipc-namespace-utils-compilation-fix ipc/util.c --- a/ipc/util.c~ipc-namespace-utils-compilation-fix +++ a/ipc/util.c @@ -145,21 +145,6 @@ void free_ipc_ns(struct kref *kref) shm_exit_ns(ns); kfree(ns); } -#else -int unshare_ipcs(unsigned long flags, struct ipc_namespace **ns) -{ - return -EINVAL; -} - -int copy_ipcs(unsigned long flags, struct task_struct *tsk) -{ - return 0; -} - -void free_ipc_ns(struct kref *kref) -{ - BUG(); /* init_ipc_ns should never be put */ -} #endif /** diff -puN kernel/fork.c~ipc-namespace-utils-compilation-fix kernel/fork.c --- a/kernel/fork.c~ipc-namespace-utils-compilation-fix +++ a/kernel/fork.c @@ -1556,6 +1556,16 @@ static int unshare_semundo(unsigned long return 0; } +#ifndef CONFIG_IPC_NS +static inline int unshare_ipcs(unsigned long flags, struct ipc_namespace **ns) +{ + if (flags & CLONE_NEWIPC) + return -EINVAL; + + return 0; +} +#endif + /* * unshare allows a process to 'unshare' part of the process * context which was originally shared using clone. copy_* _