/* * linux/ipc/namespace.c * Copyright (C) 2006 Pavel Emelyanov OpenVZ, SWsoft Inc. */ #include #include #include #include #include #include #include #include #include "util.h" static struct ipc_namespace *create_ipc_ns(void) { struct ipc_namespace *ns; int err; ns = kmalloc(sizeof(struct ipc_namespace), GFP_KERNEL); if (ns == NULL) return ERR_PTR(-ENOMEM); atomic_set(&ns->count, 1); err = mq_init_ns(ns); if (err) { 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); return ns; } struct ipc_namespace *copy_ipcs(unsigned long flags, struct ipc_namespace *ns) { if (!(flags & CLONE_NEWIPC)) return get_ipc_ns(ns); return create_ipc_ns(); } /* * free_ipcs - free all ipcs of one type * @ns: the namespace to remove the ipcs from * @ids: the table of ipcs to free * @free: the function called to free each individual ipc * * Called for each kind of ipc when an ipc_namespace exits. */ void free_ipcs(struct ipc_namespace *ns, struct ipc_ids *ids, void (*free)(struct ipc_namespace *, struct kern_ipc_perm *)) { struct kern_ipc_perm *perm; int next_id; int total, in_use; down_write(&ids->rw_mutex); in_use = ids->in_use; for (total = 0, next_id = 0; total < in_use; next_id++) { perm = idr_find(&ids->ipcs_idr, next_id); if (perm == NULL) continue; ipc_lock_by_ptr(perm); free(ns, perm); total++; } up_write(&ids->rw_mutex); } static void free_ipc_ns(struct ipc_namespace *ns) { /* * Unregistering the hotplug notifier at the beginning guarantees * that the ipc namespace won't be freed while we are inside the * callback routine. Since the blocking_notifier_chain_XXX routines * hold a rw lock on the notifier list, unregister_ipcns_notifier() * won't take the rw lock before blocking_notifier_call_chain() has * released the rd lock. */ unregister_ipcns_notifier(ns); sem_exit_ns(ns); msg_exit_ns(ns); shm_exit_ns(ns); kfree(ns); atomic_dec(&nr_ipc_ns); /* * Do the ipcns removal notification after decrementing nr_ipc_ns in * order to have a correct value when recomputing msgmni. */ ipcns_notify(IPCNS_REMOVED); } /* * put_ipc_ns - drop a reference to an ipc namespace. * @ns: the namespace to put * * If this is the last task in the namespace exiting, and * it is dropping the refcount to 0, then it can race with * a task in another ipc namespace but in a mounts namespace * which has this ipcns's mqueuefs mounted, doing some action * with one of the mqueuefs files. That can raise the refcount. * So dropping the refcount, and raising the refcount when * accessing it through the VFS, are protected with mq_lock. * * (Clearly, a task raising the refcount on its own ipc_ns * needn't take mq_lock since it can't race with the last task * in the ipcns exiting). */ void put_ipc_ns(struct ipc_namespace *ns) { if (atomic_dec_and_lock(&ns->count, &mq_lock)) { mq_clear_sbinfo(ns); spin_unlock(&mq_lock); mq_put_mnt(ns); free_ipc_ns(ns); } } lue='linux-3.7.y'>linux-3.7.y Hosts the 0x221E linux distro kernel.Ubuntu
summaryrefslogtreecommitdiff
AgeCommit message (Expand)Author
2022-06-21certs: Move load_certificate_list() to be with the asymmetric keys codeDavid Howells
2022-05-23KEYS: trusted: Introduce support for NXP CAAM-based trusted keysAhmad Fatoum
2022-05-23KEYS: trusted: allow use of kernel RNG for key materialAhmad Fatoum
2022-05-23certs: Factor out the blacklist hash creationMickaël Salaün
2022-03-08KEYS: Introduce link restriction for machine keysEric Snowberg
2022-03-08KEYS: store reference to machine keyringEric Snowberg
2022-01-09keys: X.509 public key issuer lookup without AKIDAndrew Zaborowski
2021-05-01Merge tag 'integrity-v5.13' of git://git.kernel.org/pub/scm/linux/kernel/git/...Linus Torvalds
2021-04-26Merge branch 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert...Linus Torvalds
2021-04-26Merge tag 'keys-cve-2020-26541-v3' of git://git.kernel.org/pub/scm/linux/kern...Linus Torvalds
2021-04-14KEYS: trusted: Introduce TEE based Trusted KeysSumit Garg
2021-04-14KEYS: trusted: Add generic trusted keys frameworkSumit Garg
2021-04-14security: keys: trusted: use ASN.1 TPM2 key format for the blobsJames Bottomley
2021-04-14security: keys: trusted: fix TPM2 authorizationsJames Bottomley
2021-04-09ima: enable loading of build time generated key on .ima keyringNayna Jain
2021-03-26ima: Support EC keys for signature verificationStefan Berger
2021-03-11certs: Add EFI_CERT_X509_GUID support for dbx entriesEric Snowberg
2021-01-21encrypted-keys: Replace HTTP links with HTTPS onesAlexander A. Klimov
2020-11-23rxrpc: Don't leak the service-side session key to userspaceDavid Howells
2020-11-23rxrpc: Remove the rxk5 security class as it's now defunctDavid Howells
2020-08-04Merge tag 'docs-5.9' of git://git.lwn.net/linuxLinus Torvalds
2020-06-19docs: crypto: convert asymmetric-keys.txt to ReSTMauro Carvalho Chehab
2020-06-15RxRPC: Replace zero-length array with flexible-arrayGustavo A. R. Silva
2020-06-15keys: encrypted-type: Replace zero-length array with flexible-arrayGustavo A. R. Silva
2020-06-02keys: Implement update for the big_key typeDavid Howells
2020-06-02KEYS: Replace zero-length array with flexible-arrayGustavo A. R. Silva
2020-03-29KEYS: Don't write out to userspace while holding key semaphoreWaiman Long
2019-11-30Merge tag 'powerpc-5.5-1' of git://git.kernel.org/pub/scm/linux/kernel/git/po...Linus Torvalds
2019-11-12KEYS: trusted: Move TPM2 trusted keys codeSumit Garg
2019-11-12KEYS: trusted: Create trusted keys subsystemSumit Garg
2019-11-12KEYS: Use common tpm_buf for trusted and asymmetric keysSumit Garg
2019-11-12tpm: Move tpm_buf code to include/linux/Sumit Garg
2019-11-12certs: Add wrapper function to check blacklisted binary hashNayna Jain
2019-07-08Merge tag 'keys-request-20190626' of git://git.kernel.org/pub/scm/linux/kerne...Linus Torvalds
2019-06-19keys: Move the RCU locks outwards from the keyring search functionsDavid Howells
2019-06-05treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 441Thomas Gleixner
2019-05-30treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152Thomas Gleixner
2019-05-24treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 36Thomas Gleixner
2019-04-08KEYS: trusted: fix -Wvarags warningndesaulniers@google.com
2019-03-10Merge branch 'next-integrity' of git://git.kernel.org/pub/scm/linux/kernel/gi...Linus Torvalds
2019-02-22KEYS: user: Align the payload bufferEric Biggers
2019-02-15keys: Fix dependency loop between construction record and auth keyDavid Howells
2019-02-04integrity, KEYS: add a reference to platform keyringKairui Song
2018-10-26KEYS: Move trusted.h to include/keys [ver #2]Denis Kenzior
2018-10-26KEYS: Provide missing asymmetric key subops for new key type ops [ver #2]David Howells
2018-06-15docs: Fix some broken referencesMauro Carvalho Chehab