3 * Copyright (C) 1992 Krishna Balasubramanian
5 * Sep 1997 - Call suser() last after "normal" permission checks so we
6 * get BSD style process accounting right.
7 * Occurs in several places in the IPC code.
8 * Chris Evans, <chris@ferret.lmh.ox.ac.uk>
11 #include <linux/config.h>
12 #include <linux/errno.h>
13 #include <linux/sched.h>
15 #include <linux/sem.h>
16 #include <linux/msg.h>
17 #include <linux/shm.h>
18 #include <linux/stat.h>
19 #include <linux/init.h>
21 #include <asm/uaccess.h>
23 #if defined(CONFIG_SYSVIPC)
25 extern void sem_init (void), msg_init (void), shm_init (void);
27 void __init
ipc_init (void)
36 * Check user, group, other permissions for access
37 * to ipc resources. return 0 if allowed
39 int ipcperms (struct ipc_perm
*ipcp
, short flag
)
40 { /* flag will most probably be 0 or S_...UGO from <linux/stat.h> */
41 int requested_mode
, granted_mode
;
43 requested_mode
= (flag
>> 6) | (flag
>> 3) | flag
;
44 granted_mode
= ipcp
->mode
;
45 if (current
->euid
== ipcp
->cuid
|| current
->euid
== ipcp
->uid
)
47 else if (in_group_p(ipcp
->cgid
) || in_group_p(ipcp
->gid
))
49 /* is there some bit set in requested_mode but not in granted_mode? */
50 if ((requested_mode
& ~granted_mode
& 0007) &&
51 !capable(CAP_IPC_OWNER
))
59 * Dummy functions when SYSV IPC isn't configured
67 int shm_swap (int prio
, int gfp_mask
)
72 asmlinkage
int sys_semget (key_t key
, int nsems
, int semflg
)
77 asmlinkage
int sys_semop (int semid
, struct sembuf
*sops
, unsigned nsops
)
82 asmlinkage
int sys_semctl (int semid
, int semnum
, int cmd
, union semun arg
)
87 asmlinkage
int sys_msgget (key_t key
, int msgflg
)
92 asmlinkage
int sys_msgsnd (int msqid
, struct msgbuf
*msgp
, size_t msgsz
, int msgflg
)
97 asmlinkage
int sys_msgrcv (int msqid
, struct msgbuf
*msgp
, size_t msgsz
, long msgtyp
,
103 asmlinkage
int sys_msgctl (int msqid
, int cmd
, struct msqid_ds
*buf
)
108 asmlinkage
int sys_shmget (key_t key
, int size
, int flag
)
113 asmlinkage
int sys_shmat (int shmid
, char *shmaddr
, int shmflg
, ulong
*addr
)
118 asmlinkage
int sys_shmdt (char *shmaddr
)
123 asmlinkage
int sys_shmctl (int shmid
, int cmd
, struct shmid_ds
*buf
)
128 #endif /* CONFIG_SYSVIPC */