FreeBSD kernel kern code
|
#include <sys/cdefs.h>
#include "opt_sysvipc.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/sysproto.h>
#include <sys/kernel.h>
#include <sys/priv.h>
#include <sys/proc.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/module.h>
#include <sys/mount.h>
#include <sys/msg.h>
#include <sys/racct.h>
#include <sys/sx.h>
#include <sys/syscall.h>
#include <sys/syscallsubr.h>
#include <sys/sysent.h>
#include <sys/sysctl.h>
#include <sys/malloc.h>
#include <sys/jail.h>
#include <security/audit/audit.h>
#include <security/mac/mac_framework.h>
Go to the source code of this file.
Data Structures | |
struct | msgmap |
struct | msgctl_args |
struct | msgget_args |
struct | msgsnd_args |
struct | msgrcv_args |
Macros | |
#define | DPRINTF(a) (void)0 |
#define | MSGSSZ 8 /* Each segment must be 2^N long */ |
#define | MSGSEG 2048 /* must be less than 32767 */ |
#define | MSGMAX (MSGSSZ*MSGSEG) |
#define | MSGMNB 2048 /* max # of bytes in a queue */ |
#define | MSGMNI 40 |
#define | MSGTQL 40 |
#define | MSQID(ix, ds) ((ix) & 0xffff | (((ds).msg_perm.seq << 16) & 0xffff0000)) |
#define | MSQID_IX(id) ((id) & 0xffff) |
#define | MSQID_SEQ(id) (((id) >> 16) & 0xffff) |
#define | MSG_LOCKED 01000 /* Is this msqid_ds locked? */ |
Functions | |
__FBSDID ("$FreeBSD$") | |
FEATURE (sysv_msg, "System V message queues support") | |
static | MALLOC_DEFINE (M_MSG, "msg", "SVID compatible message queues") |
static int | msginit (void) |
static int | msgunload (void) |
static int | sysvmsg_modload (struct module *, int, void *) |
static void | msq_remove (struct msqid_kernel *) |
static struct prison * | msg_find_prison (struct ucred *) |
static int | msq_prison_cansee (struct prison *, struct msqid_kernel *) |
static int | msg_prison_check (void *, void *) |
static int | msg_prison_set (void *, void *) |
static int | msg_prison_get (void *, void *) |
static int | msg_prison_remove (void *, void *) |
static void | msg_prison_cleanup (struct prison *) |
static void | msg_freehdr (struct msg *msghdr) |
DECLARE_MODULE (sysvmsg, sysvmsg_mod, SI_SUB_SYSV_MSG, SI_ORDER_FIRST) | |
MODULE_VERSION (sysvmsg, 1) | |
int | sys_msgctl (struct thread *td, struct msgctl_args *uap) |
int | kern_msgctl (struct thread *td, int msqid, int cmd, struct msqid_ds *msqbuf) |
int | sys_msgget (struct thread *td, struct msgget_args *uap) |
int | kern_msgsnd (struct thread *td, int msqid, const void *msgp, size_t msgsz, int msgflg, long mtype) |
int | sys_msgsnd (struct thread *td, struct msgsnd_args *uap) |
int | kern_msgrcv (struct thread *td, int msqid, void *msgp, size_t msgsz, long msgtyp, int msgflg, long *mtype) |
int | sys_msgrcv (struct thread *td, struct msgrcv_args *uap) |
static int | sysctl_msqids (SYSCTL_HANDLER_ARGS) |
SYSCTL_INT (_kern_ipc, OID_AUTO, msgmax, CTLFLAG_RD, &msginfo.msgmax, 0, "Maximum message size") | |
SYSCTL_INT (_kern_ipc, OID_AUTO, msgmni, CTLFLAG_RDTUN, &msginfo.msgmni, 0, "Number of message queue identifiers") | |
SYSCTL_INT (_kern_ipc, OID_AUTO, msgmnb, CTLFLAG_RDTUN, &msginfo.msgmnb, 0, "Maximum number of bytes in a queue") | |
SYSCTL_INT (_kern_ipc, OID_AUTO, msgtql, CTLFLAG_RDTUN, &msginfo.msgtql, 0, "Maximum number of messages in the system") | |
SYSCTL_INT (_kern_ipc, OID_AUTO, msgssz, CTLFLAG_RDTUN, &msginfo.msgssz, 0, "Size of a message segment") | |
SYSCTL_INT (_kern_ipc, OID_AUTO, msgseg, CTLFLAG_RDTUN, &msginfo.msgseg, 0, "Number of message segments") | |
SYSCTL_PROC (_kern_ipc, OID_AUTO, msqids, CTLTYPE_OPAQUE|CTLFLAG_RD|CTLFLAG_MPSAFE, NULL, 0, sysctl_msqids, "", "Array of struct msqid_kernel for each potential message queue") | |
static int | msg_prison_remove (void *obj, void *data __unused) |
SYSCTL_JAIL_PARAM_SYS_NODE (sysvmsg, CTLFLAG_RW, "SYSV message queues") | |
Variables | |
struct msginfo | msginfo |
static int | nfree_msgmaps |
static short | free_msgmaps |
static struct msg * | free_msghdrs |
static char * | msgpool |
static struct msgmap * | msgmaps |
static struct msg * | msghdrs |
static struct msqid_kernel * | msqids |
static struct mtx | msq_mtx |
static unsigned | msg_prison_slot |
static struct syscall_helper_data | msg_syscalls [] |
static moduledata_t | sysvmsg_mod |
#define DPRINTF | ( | a | ) | (void)0 |
Definition at line 105 of file sysv_msg.c.
#define MSG_LOCKED 01000 /* Is this msqid_ds locked? */ |
Definition at line 165 of file sysv_msg.c.
Definition at line 116 of file sysv_msg.c.
#define MSGMNB 2048 /* max # of bytes in a queue */ |
Definition at line 118 of file sysv_msg.c.
#define MSGMNI 40 |
Definition at line 121 of file sysv_msg.c.
#define MSGSEG 2048 /* must be less than 32767 */ |
Definition at line 114 of file sysv_msg.c.
#define MSGSSZ 8 /* Each segment must be 2^N long */ |
Definition at line 111 of file sysv_msg.c.
#define MSGTQL 40 |
Definition at line 124 of file sysv_msg.c.
#define MSQID | ( | ix, | |
ds | |||
) | ((ix) & 0xffff | (((ds).msg_perm.seq << 16) & 0xffff0000)) |
Definition at line 151 of file sysv_msg.c.
#define MSQID_IX | ( | id | ) | ((id) & 0xffff) |
Definition at line 152 of file sysv_msg.c.
#define MSQID_SEQ | ( | id | ) | (((id) >> 16) & 0xffff) |
Definition at line 153 of file sysv_msg.c.
__FBSDID | ( | "$FreeBSD$" | ) |
DECLARE_MODULE | ( | sysvmsg | , |
sysvmsg_mod | , | ||
SI_SUB_SYSV_MSG | , | ||
SI_ORDER_FIRST | |||
) |
FEATURE | ( | sysv_msg | , |
"System V message queues support" | |||
) |
int kern_msgctl | ( | struct thread * | td, |
int | msqid, | ||
int | cmd, | ||
struct msqid_ds * | msqbuf | ||
) |
Definition at line 499 of file sysv_msg.c.
References DPRINTF, ipcperm(), msg_find_prison(), msginfo, msq_mtx, msq_prison_cansee(), msq_remove(), msqids, priv_check(), and time_second.
Referenced by sys_msgctl().
int kern_msgrcv | ( | struct thread * | td, |
int | msqid, | ||
void * | msgp, | ||
size_t | msgsz, | ||
long | msgtyp, | ||
int | msgflg, | ||
long * | mtype | ||
) |
Definition at line 1139 of file sysv_msg.c.
References DPRINTF, ipcperm(), msg_find_prison(), msg_freehdr(), msginfo, msgmaps, msgpool, msq_mtx, msq_prison_cansee(), msqids, msgmap::next, panic(), time_second, and wakeup().
Referenced by sys_msgrcv().
int kern_msgsnd | ( | struct thread * | td, |
int | msqid, | ||
const void * | msgp, | ||
size_t | msgsz, | ||
int | msgflg, | ||
long | mtype | ||
) |
Definition at line 769 of file sysv_msg.c.
References DPRINTF, free_msghdrs, free_msgmaps, hz, ipcperm(), msg_find_prison(), msg_freehdr(), MSG_LOCKED, msginfo, msgmaps, msgpool, msq_mtx, msq_prison_cansee(), msqids, msgmap::next, nfree_msgmaps, panic(), time_second, and wakeup().
Referenced by sys_msgsnd().
|
static |
MODULE_VERSION | ( | sysvmsg | , |
1 | |||
) |
|
static |
Definition at line 451 of file sysv_msg.c.
References msg_prison_slot, and pr.
Referenced by kern_msgctl(), kern_msgrcv(), kern_msgsnd(), sys_msgget(), and sysctl_msqids().
|
static |
Definition at line 387 of file sysv_msg.c.
References free_msghdrs, free_msgmaps, msginfo, msgmaps, msgmap::next, nfree_msgmaps, and panic().
Referenced by kern_msgrcv(), kern_msgsnd(), and msq_remove().
|
static |
Definition at line 1500 of file sysv_msg.c.
References data, msg_prison_slot, pr, and vfs_copyopt().
Referenced by msginit().
|
static |
Definition at line 1656 of file sysv_msg.c.
References msginfo, msq_mtx, msq_remove(), msqids, and pr.
Referenced by msg_prison_remove(), and msg_prison_set().
|
static |
Definition at line 1622 of file sysv_msg.c.
References data, msg_prison_slot, pr, and vfs_setopt().
Referenced by msginit().
|
static |
|
static |
Definition at line 1642 of file sysv_msg.c.
References msg_prison_cleanup(), msg_prison_slot, and pr.
|
static |
Definition at line 1535 of file sysv_msg.c.
References data, msg_prison_cleanup(), msg_prison_slot, osd_free_reserved(), osd_reserve(), pr, vfs_copyopt(), and vfs_flagopt().
Referenced by msginit().
|
static |
Definition at line 213 of file sysv_msg.c.
References allprison, allprison_lock, DPRINTF, free_msghdrs, free_msgmaps, malloc(), msg_prison_check(), msg_prison_get(), msg_prison_remove(), msg_prison_set(), msg_prison_slot, msg_syscalls, msghdrs, msginfo, msgmaps, msgpool, msq_mtx, msqids, msgmap::next, nfree_msgmaps, osd_free_reserved(), osd_reserve(), panic(), pr, prison0, and syscall_helper_register().
Referenced by sysvmsg_modload().
|
static |
Definition at line 316 of file sysv_msg.c.
References free(), MSG_LOCKED, msg_prison_slot, msg_syscalls, msghdrs, msginfo, msgmaps, msgpool, msq_mtx, msqids, and syscall_helper_unregister().
Referenced by sysvmsg_modload().
|
static |
Definition at line 463 of file sysv_msg.c.
References prison_ischild().
Referenced by kern_msgctl(), kern_msgrcv(), kern_msgsnd(), and sysctl_msqids().
|
static |
Definition at line 413 of file sysv_msg.c.
References crfree(), msg_freehdr(), panic(), and wakeup().
Referenced by kern_msgctl(), and msg_prison_cleanup().
int sys_msgctl | ( | struct thread * | td, |
struct msgctl_args * | uap | ||
) |
Definition at line 481 of file sysv_msg.c.
References msgctl_args::buf, msgctl_args::cmd, DPRINTF, kern_msgctl(), and msgctl_args::msqid.
int sys_msgget | ( | struct thread * | td, |
struct msgget_args * | uap | ||
) |
Definition at line 645 of file sysv_msg.c.
References crhold(), DPRINTF, ipcperm(), msgget_args::key, msg_find_prison(), MSG_LOCKED, msgget_args::msgflg, msginfo, msq_mtx, msqids, and time_second.
int sys_msgrcv | ( | struct thread * | td, |
struct msgrcv_args * | uap | ||
) |
Definition at line 1399 of file sysv_msg.c.
References DPRINTF, kern_msgrcv(), msgrcv_args::msgflg, msgrcv_args::msgp, msgrcv_args::msgsz, msgrcv_args::msgtyp, and msgrcv_args::msqid.
int sys_msgsnd | ( | struct thread * | td, |
struct msgsnd_args * | uap | ||
) |
Definition at line 1111 of file sysv_msg.c.
References DPRINTF, kern_msgsnd(), msgsnd_args::msgflg, msgsnd_args::msgp, msgsnd_args::msgsz, and msgsnd_args::msqid.
SYSCTL_INT | ( | _kern_ipc | , |
OID_AUTO | , | ||
msgmax | , | ||
CTLFLAG_RD | , | ||
&msginfo. | msgmax, | ||
0 | , | ||
"Maximum message size" | |||
) |
SYSCTL_INT | ( | _kern_ipc | , |
OID_AUTO | , | ||
msgmnb | , | ||
CTLFLAG_RDTUN | , | ||
&msginfo. | msgmnb, | ||
0 | , | ||
"Maximum number of bytes in a queue" | |||
) |
SYSCTL_INT | ( | _kern_ipc | , |
OID_AUTO | , | ||
msgmni | , | ||
CTLFLAG_RDTUN | , | ||
&msginfo. | msgmni, | ||
0 | , | ||
"Number of message queue identifiers" | |||
) |
SYSCTL_INT | ( | _kern_ipc | , |
OID_AUTO | , | ||
msgseg | , | ||
CTLFLAG_RDTUN | , | ||
&msginfo. | msgseg, | ||
0 | , | ||
"Number of message segments" | |||
) |
SYSCTL_INT | ( | _kern_ipc | , |
OID_AUTO | , | ||
msgssz | , | ||
CTLFLAG_RDTUN | , | ||
&msginfo. | msgssz, | ||
0 | , | ||
"Size of a message segment" | |||
) |
SYSCTL_INT | ( | _kern_ipc | , |
OID_AUTO | , | ||
msgtql | , | ||
CTLFLAG_RDTUN | , | ||
&msginfo. | msgtql, | ||
0 | , | ||
"Maximum number of messages in the system" | |||
) |
SYSCTL_JAIL_PARAM_SYS_NODE | ( | sysvmsg | , |
CTLFLAG_RW | , | ||
"SYSV message queues" | |||
) |
|
static |
Definition at line 1417 of file sysv_msg.c.
References msg_find_prison(), msginfo, msq_mtx, msq_prison_cansee(), msqids, and pr.
SYSCTL_PROC | ( | _kern_ipc | , |
OID_AUTO | , | ||
msqids | , | ||
CTLTYPE_OPAQUE|CTLFLAG_RD| | CTLFLAG_MPSAFE, | ||
NULL | , | ||
0 | , | ||
sysctl_msqids | , | ||
"" | , | ||
"Array of struct msqid_kernel for each potential message queue" | |||
) |
|
static |
Definition at line 355 of file sysv_msg.c.
References msginit(), and msgunload().
|
static |
Definition at line 169 of file sysv_msg.c.
Referenced by kern_msgsnd(), msg_freehdr(), and msginit().
|
static |
Definition at line 168 of file sysv_msg.c.
Referenced by kern_msgsnd(), msg_freehdr(), and msginit().
|
static |
Definition at line 175 of file sysv_msg.c.
Referenced by msg_find_prison(), msg_prison_check(), msg_prison_get(), msg_prison_remove(), msg_prison_set(), msginit(), and msgunload().
|
static |
Definition at line 177 of file sysv_msg.c.
Referenced by msginit(), and msgunload().
|
static |
Definition at line 172 of file sysv_msg.c.
Referenced by msginit(), and msgunload().
struct msginfo msginfo |
Definition at line 137 of file sysv_msg.c.
Referenced by kern_msgctl(), kern_msgrcv(), kern_msgsnd(), msg_freehdr(), msg_prison_cleanup(), msginit(), msgunload(), sys_msgget(), and sysctl_msqids().
|
static |
Definition at line 171 of file sysv_msg.c.
Referenced by kern_msgrcv(), kern_msgsnd(), msg_freehdr(), msginit(), and msgunload().
|
static |
Definition at line 170 of file sysv_msg.c.
Referenced by kern_msgrcv(), kern_msgsnd(), msginit(), and msgunload().
|
static |
Definition at line 174 of file sysv_msg.c.
Referenced by kern_msgctl(), kern_msgrcv(), kern_msgsnd(), msg_prison_cleanup(), msginit(), msgunload(), sys_msgget(), and sysctl_msqids().
|
static |
Definition at line 173 of file sysv_msg.c.
Referenced by kern_msgctl(), kern_msgrcv(), kern_msgsnd(), msg_prison_cleanup(), msginit(), msgunload(), sys_msgget(), and sysctl_msqids().
|
static |
Definition at line 167 of file sysv_msg.c.
Referenced by kern_msgsnd(), msg_freehdr(), and msginit().
|
static |
Definition at line 377 of file sysv_msg.c.