21 #include <linux/shm.h>
23 #include <linux/msg.h>
25 #include <linux/slab.h>
26 #include <linux/capability.h>
33 #include <linux/audit.h>
39 #include <asm/unistd.h>
50 #ifdef CONFIG_MEMORY_HOTPLUG
100 static int __init ipc_init(
void)
136 #ifdef CONFIG_PROC_FS
146 int ids,
int (*show)(
struct seq_file *,
void *))
187 for (total = 0, next_id = 0; total < ids->
in_use; next_id++) {
193 if (ipc->
key != key) {
198 ipc_lock_by_ptr(ipc);
226 for (
id = 0;
id <
IPCMNI && total < ids->
in_use;
id++) {
265 spin_lock(&new->lock);
269 spin_unlock(&new->lock);
277 new->cuid =
new->uid = euid;
278 new->gid =
new->cgid = egid;
280 new->seq = ids->
seq++;
284 new->id = ipc_buildid(
id, new->seq);
309 err = ops->
getnew(ns, params);
369 int flg = params->
flg;
379 ipcp = ipc_findkey(ids, params->
key);
387 err = ops->
getnew(ns, params);
391 if (flg & IPC_CREAT && flg &
IPC_EXCL)
402 err = ipc_check_perms(ns, ipcp, ops, params);
504 #define HDRLEN_KMALLOC (sizeof(struct ipc_rcu_grace) > sizeof(struct ipc_rcu_hdr) ? \
505 sizeof(struct ipc_rcu_grace) : sizeof(struct ipc_rcu_hdr))
506 #define HDRLEN_VMALLOC (sizeof(struct ipc_rcu_sched) > HDRLEN_KMALLOC ? \
507 sizeof(struct ipc_rcu_sched) : HDRLEN_KMALLOC)
509 static inline int rcu_use_vmalloc(
int size)
533 if (rcu_use_vmalloc(size)) {
610 int requested_mode, granted_mode;
613 requested_mode = (flag >> 6) | (flag >> 3) |
flag;
614 granted_mode = ipcp->
mode;
615 if (uid_eq(euid, ipcp->
cuid) ||
616 uid_eq(euid, ipcp->
uid))
621 if ((requested_mode & ~granted_mode & 0007) &&
696 spin_lock(&out->
lock);
702 spin_unlock(&out->
lock);
718 if (ipc_checkid(out,
id)) {
720 return ERR_PTR(-
EIDRM);
740 return ipcget_new(ns, ids, ops, params);
742 return ipcget_public(ns, ids, ops, params);
754 if (!uid_valid(uid) || !gid_valid(gid))
799 audit_ipc_set_perm(extra_perm, perm->
uid,
803 if (uid_eq(euid, ipcp->
cuid) || uid_eq(euid, ipcp->
uid) ||
814 #ifdef CONFIG_ARCH_WANT_IPC_PARSE_VERSION
838 #ifdef CONFIG_PROC_FS
839 struct ipc_proc_iter {
854 for (
id = 0;
id < pos && total < ids->
in_use;
id++) {
863 for ( ; pos <
IPCMNI; pos++) {
867 ipc_lock_by_ptr(ipc);
876 static void *sysvipc_proc_next(
struct seq_file *
s,
void *it, loff_t *pos)
878 struct ipc_proc_iter *iter = s->
private;
886 return sysvipc_find_ipc(&iter->ns->ids[iface->
ids], *pos, pos);
893 static void *sysvipc_proc_start(
struct seq_file *s, loff_t *pos)
895 struct ipc_proc_iter *iter = s->
private;
899 ids = &iter->ns->ids[iface->
ids];
916 return sysvipc_find_ipc(ids, *pos - 1, pos);
919 static void sysvipc_proc_stop(
struct seq_file *s,
void *it)
922 struct ipc_proc_iter *iter = s->
private;
930 ids = &iter->ns->ids[iface->
ids];
935 static int sysvipc_proc_show(
struct seq_file *s,
void *it)
937 struct ipc_proc_iter *iter = s->
private;
943 return iface->
show(s, it);
947 .
start = sysvipc_proc_start,
948 .stop = sysvipc_proc_stop,
949 .next = sysvipc_proc_next,
950 .show = sysvipc_proc_show,
957 struct ipc_proc_iter *iter;
964 ret =
seq_open(file, &sysvipc_proc_seqops);
971 iter->iface = PDE(inode)->data;
972 iter->ns = get_ipc_ns(
current->nsproxy->ipc_ns);
980 static int sysvipc_proc_release(
struct inode *inode,
struct file *file)
983 struct ipc_proc_iter *iter = seq->
private;
989 .
open = sysvipc_proc_open,
992 .release = sysvipc_proc_release,