Skip to content

Commit

Permalink
[PATCH] ipcns: fix !CONFIG_IPC_NS behavior
Browse files Browse the repository at this point in the history
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 <[email protected]>
Cc: "Eric W. Biederman" <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Serge E. Hallyn authored and Linus Torvalds committed Mar 27, 2007
1 parent d1985ad commit a28d193
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
9 changes: 3 additions & 6 deletions include/linux/ipc.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,19 +92,16 @@ extern struct ipc_namespace init_ipc_ns;

#ifdef CONFIG_SYSVIPC
#define INIT_IPC_NS(ns) .ns = &init_ipc_ns,
extern int copy_ipcs(unsigned long flags, struct task_struct *tsk);
#else
#define INIT_IPC_NS(ns)
static inline int copy_ipcs(unsigned long flags, struct task_struct *tsk)
{ return 0; }
#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)
Expand Down
7 changes: 7 additions & 0 deletions ipc/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,13 @@ void free_ipc_ns(struct kref *kref)
shm_exit_ns(ns);
kfree(ns);
}
#else
int copy_ipcs(unsigned long flags, struct task_struct *tsk)
{
if (flags & CLONE_NEWIPC)
return -EINVAL;
return 0;
}
#endif

/**
Expand Down

0 comments on commit a28d193

Please sign in to comment.