static struct ipc_namespace *create_ipc_ns(struct user_namespace *user_ns,
					   struct ipc_namespace *old_ns)
{
	struct ipc_namespace *ns;
	int err;

	ns = kmalloc(sizeof(struct ipc_namespace), GFP_KERNEL);
	if (ns == NULL)
		return ERR_PTR(-ENOMEM);

	err = proc_alloc_inum(&ns->proc_inum);
	if (err) {
		kfree(ns);
		return ERR_PTR(err);
	}

	atomic_set(&ns->count, 1);
	err = mq_init_ns(ns);
	if (err) {
		proc_free_inum(ns->proc_inum);
		kfree(ns);
		return ERR_PTR(err);
	}
	atomic_inc(&nr_ipc_ns);

	sem_init_ns(ns);
	msg_init_ns(ns);
	shm_init_ns(ns);

	/*
	 * msgmni has already been computed for the new ipc ns.
	 * Thus, do the ipcns creation notification before registering that
	 * new ipcns in the chain.
	 */
	ipcns_notify(IPCNS_CREATED);
	register_ipcns_notifier(ns);

	ns->user_ns = get_user_ns(user_ns);

	return ns;
}
Exemple #2
0
/*
 * Clone a new ns copying an original utsname, setting refcount to 1
 * @old_ns: namespace to clone
 * Return ERR_PTR(-ENOMEM) on error (failure to kmalloc), new ns otherwise
 */
static struct uts_namespace *clone_uts_ns(struct user_namespace *user_ns,
        struct uts_namespace *old_ns)
{
    struct uts_namespace *ns;
    int err;

    ns = create_uts_ns();
    if (!ns)
        return ERR_PTR(-ENOMEM);

    err = proc_alloc_inum(&ns->proc_inum);
    if (err) {
        kfree(ns);
        return ERR_PTR(err);
    }

    down_read(&uts_sem);
    memcpy(&ns->name, &old_ns->name, sizeof(ns->name));
    ns->user_ns = get_user_ns(user_ns);
    up_read(&uts_sem);
    return ns;
}
Exemple #3
0
void __init proc_self_init(void)
{
	proc_alloc_inum(&self_inum);
}
Exemple #4
0
void __init proc_thread_self_init(void)
{
	proc_alloc_inum(&thread_self_inum);
}