Commit a28d193cbf01375974683c13e99a52ef489e5eb0

Authored by Serge E. Hallyn
Committed by Linus Torvalds
1 parent d1985ad1da

[PATCH] ipcns: fix !CONFIG_IPC_NS behavior

When CONFIG_IPC_NS=n, clone(CLONE_NEWIPC) claims success, but did not actually
clone a new IPC namespace.

Fix this to return -EINVAL so the caller knows his request was denied.

Signed-off-by: Serge E. Hallyn <serue@us.ibm.com>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Showing 2 changed files with 10 additions and 6 deletions Side-by-side Diff

... ... @@ -92,19 +92,16 @@
92 92  
93 93 #ifdef CONFIG_SYSVIPC
94 94 #define INIT_IPC_NS(ns) .ns = &init_ipc_ns,
  95 +extern int copy_ipcs(unsigned long flags, struct task_struct *tsk);
95 96 #else
96 97 #define INIT_IPC_NS(ns)
  98 +static inline int copy_ipcs(unsigned long flags, struct task_struct *tsk)
  99 +{ return 0; }
97 100 #endif
98 101  
99 102 #ifdef CONFIG_IPC_NS
100 103 extern void free_ipc_ns(struct kref *kref);
101   -extern int copy_ipcs(unsigned long flags, struct task_struct *tsk);
102 104 extern int unshare_ipcs(unsigned long flags, struct ipc_namespace **ns);
103   -#else
104   -static inline int copy_ipcs(unsigned long flags, struct task_struct *tsk)
105   -{
106   - return 0;
107   -}
108 105 #endif
109 106  
110 107 static inline struct ipc_namespace *get_ipc_ns(struct ipc_namespace *ns)
... ... @@ -144,6 +144,13 @@
144 144 shm_exit_ns(ns);
145 145 kfree(ns);
146 146 }
  147 +#else
  148 +int copy_ipcs(unsigned long flags, struct task_struct *tsk)
  149 +{
  150 + if (flags & CLONE_NEWIPC)
  151 + return -EINVAL;
  152 + return 0;
  153 +}
147 154 #endif
148 155  
149 156 /**