|
FreeBSD kernel kern code
|
#include <sys/cdefs.h>#include "opt_compat.h"#include "opt_sysvipc.h"#include <sys/param.h>#include <sys/systm.h>#include <sys/sysproto.h>#include <sys/eventhandler.h>#include <sys/kernel.h>#include <sys/proc.h>#include <sys/lock.h>#include <sys/module.h>#include <sys/mutex.h>#include <sys/racct.h>#include <sys/sem.h>#include <sys/syscall.h>#include <sys/syscallsubr.h>#include <sys/sysent.h>#include <sys/sysctl.h>#include <sys/uio.h>#include <sys/malloc.h>#include <sys/jail.h>#include <security/mac/mac_framework.h>
Go to the source code of this file.
Data Structures | |
| struct | sem_undo |
| struct | __semctl_args |
| struct | semget_args |
| struct | semop_args |
Macros | |
| #define | DPRINTF(a) |
| #define | SEMUNDO_MTX sem_undo_mtx |
| #define | SEMUNDO_LOCK() mtx_lock(&SEMUNDO_MTX); |
| #define | SEMUNDO_UNLOCK() mtx_unlock(&SEMUNDO_MTX); |
| #define | SEMUNDO_LOCKASSERT(how) mtx_assert(&SEMUNDO_MTX, (how)); |
| #define | SEMMNI 50 /* # of semaphore identifiers */ |
| #define | SEMMNS 340 /* # of semaphores in system */ |
| #define | SEMUME 50 /* max # of undo entries per process */ |
| #define | SEMMNU 150 /* # of undo structures in system */ |
| #define | SEMMSL SEMMNS /* max # of semaphores per id */ |
| #define | SEMOPM 100 /* max # of operations per semop call */ |
| #define | SEMVMX 32767 /* semaphore maximum value */ |
| #define | SEMAEM 16384 /* adjust on exit max value */ |
| #define | SEM_ALIGN(bytes) (((bytes) + (sizeof(long) - 1)) & ~(sizeof(long) - 1)) |
| #define | SEMUSZ SEM_ALIGN(offsetof(struct sem_undo, un_ent[SEMUME])) |
| #define | SEMU(ix) ((struct sem_undo *)(((intptr_t)semu)+ix * seminfo.semusz)) |
| #define | SMALL_SOPS 8 |
Functions | |
| __FBSDID ("$BSDSUniX$") | |
| FEATURE (sysv_sem,"System V semaphores support") | |
| static | MALLOC_DEFINE (M_SEM,"sem","SVID compatible semaphores") |
| static int | seminit (void) |
| static int | sysvsem_modload (struct module *, int, void *) |
| static int | semunload (void) |
| static void | semexit_myhook (void *arg, struct proc *p) |
| static int | sysctl_sema (SYSCTL_HANDLER_ARGS) |
| static int | semvalid (int semid, struct semid_kernel *semakptr) |
| int | __semctl (struct thread *td, struct __semctl_args *uap) |
| int | semget (struct thread *td, struct semget_args *uap) |
| int | semop (struct thread *td, struct semop_args *uap) |
| static struct sem_undo * | semu_alloc (struct thread *td) |
| static int | semundo_adjust (struct thread *td, struct sem_undo **supptr, int semid, int semseq, int semnum, int adjval) |
| static void | semundo_clear (int semid, int semnum) |
| LIST_HEAD (sem_undo) | |
| SYSCTL_INT (_kern_ipc, OID_AUTO, semmni, CTLFLAG_RDTUN,&seminfo.semmni, 0,"Number of semaphore identifiers") | |
| SYSCTL_INT (_kern_ipc, OID_AUTO, semmns, CTLFLAG_RDTUN,&seminfo.semmns, 0,"Maximum number of semaphores in the system") | |
| SYSCTL_INT (_kern_ipc, OID_AUTO, semmnu, CTLFLAG_RDTUN,&seminfo.semmnu, 0,"Maximum number of undo structures in the system") | |
| SYSCTL_INT (_kern_ipc, OID_AUTO, semmsl, CTLFLAG_RW,&seminfo.semmsl, 0,"Max semaphores per id") | |
| SYSCTL_INT (_kern_ipc, OID_AUTO, semopm, CTLFLAG_RDTUN,&seminfo.semopm, 0,"Max operations per semop call") | |
| SYSCTL_INT (_kern_ipc, OID_AUTO, semume, CTLFLAG_RDTUN,&seminfo.semume, 0,"Max undo entries per process") | |
| SYSCTL_INT (_kern_ipc, OID_AUTO, semusz, CTLFLAG_RDTUN,&seminfo.semusz, 0,"Size in bytes of undo structure") | |
| SYSCTL_INT (_kern_ipc, OID_AUTO, semvmx, CTLFLAG_RW,&seminfo.semvmx, 0,"Semaphore maximum value") | |
| SYSCTL_INT (_kern_ipc, OID_AUTO, semaem, CTLFLAG_RW,&seminfo.semaem, 0,"Adjust on exit max value") | |
| SYSCTL_PROC (_kern_ipc, OID_AUTO, sema, CTLTYPE_OPAQUE|CTLFLAG_RD, NULL, 0, sysctl_sema,"","Semaphore id pool") | |
| DECLARE_MODULE (sysvsem, sysvsem_mod, SI_SUB_SYSV_SEM, SI_ORDER_FIRST) | |
| MODULE_VERSION (sysvsem, 1) | |
| static int | semu_try_free (struct sem_undo *suptr) |
| int | sys___semctl (struct thread *td, struct __semctl_args *uap) |
| int | kern_semctl (struct thread *td, int semid, int semnum, int cmd, union semun *arg, register_t *rval) |
| int | sys_semget (struct thread *td, struct semget_args *uap) |
| int | sys_semop (struct thread *td, struct semop_args *uap) |
Variables | |
| static struct mtx | sem_mtx |
| static struct mtx | sem_undo_mtx |
| static int | semtot = 0 |
| static struct semid_kernel * | sema |
| static struct mtx * | sema_mtx |
| static struct sem * | sem |
| struct seminfo | seminfo |
| static struct syscall_helper_data | sem_syscalls [] |
| static moduledata_t | sysvsem_mod |
| #define DPRINTF | ( | a | ) |
Definition at line 73 of file sysv_sem.c.
Referenced by kern_semctl(), semexit_myhook(), sys_semget(), and sys_semop().
| #define SEM_ALIGN | ( | bytes | ) | (((bytes) + (sizeof(long) - 1)) & ~(sizeof(long) - 1)) |
Definition at line 167 of file sysv_sem.c.
| #define SEMAEM 16384 /* adjust on exit max value */ |
Definition at line 160 of file sysv_sem.c.
| #define SEMMNI 50 /* # of semaphore identifiers */ |
Definition at line 139 of file sysv_sem.c.
| #define SEMMNS 340 /* # of semaphores in system */ |
Definition at line 142 of file sysv_sem.c.
| #define SEMMNU 150 /* # of undo structures in system */ |
Definition at line 148 of file sysv_sem.c.
| #define SEMMSL SEMMNS /* max # of semaphores per id */ |
Definition at line 153 of file sysv_sem.c.
| #define SEMOPM 100 /* max # of operations per semop call */ |
Definition at line 156 of file sysv_sem.c.
| #define SEMU | ( | ix | ) | ((struct sem_undo *)(((intptr_t)semu)+ix * seminfo.semusz)) |
Definition at line 175 of file sysv_sem.c.
Referenced by seminit().
| #define SEMUME 50 /* max # of undo entries per process */ |
Definition at line 145 of file sysv_sem.c.
| #define SEMUNDO_LOCK | ( | ) | mtx_lock(&SEMUNDO_MTX); |
Referenced by kern_semctl(), semexit_myhook(), and sys_semop().
| #define SEMUNDO_LOCKASSERT | ( | how | ) | mtx_assert(&SEMUNDO_MTX, (how)); |
Referenced by semu_alloc(), semu_try_free(), semundo_adjust(), and semundo_clear().
| #define SEMUNDO_MTX sem_undo_mtx |
| #define SEMUNDO_UNLOCK | ( | ) | mtx_unlock(&SEMUNDO_MTX); |
Referenced by kern_semctl(), semexit_myhook(), and sys_semop().
Definition at line 170 of file sysv_sem.c.
| #define SEMVMX 32767 /* semaphore maximum value */ |
Definition at line 159 of file sysv_sem.c.
| #define SMALL_SOPS 8 |
| __FBSDID | ( | "$BSDSUniX$" | ) |
| int __semctl | ( | struct thread * | td, |
| struct __semctl_args * | uap | ||
| ) |
| DECLARE_MODULE | ( | sysvsem | , |
| sysvsem_mod | , | ||
| SI_SUB_SYSV_SEM | , | ||
| SI_ORDER_FIRST | |||
| ) |
| FEATURE | ( | sysv_sem | , |
| "System V semaphores support" | |||
| ) |
| int kern_semctl | ( | struct thread * | td, |
| int | semid, | ||
| int | semnum, | ||
| int | cmd, | ||
| union semun * | arg, | ||
| register_t * | rval | ||
| ) |
Definition at line 579 of file sysv_sem.c.
References count, crfree(), DPRINTF, free(), ipcperm(), malloc(), prison_allow(), racct_sub_cred(), sem, sem_mtx, sema, sema_mtx, semtot, semundo_clear(), SEMUNDO_LOCK, SEMUNDO_UNLOCK, semvalid(), time_second, and wakeup().
Referenced by sys___semctl().


| LIST_HEAD | ( | sem_undo | ) |
Definition at line 103 of file sysv_sem.c.
|
static |
| MODULE_VERSION | ( | sysvsem | , |
| 1 | |||
| ) |
|
static |
Definition at line 1294 of file sysv_sem.c.
References DPRINTF, panic(), sema, sema_mtx, SEMUNDO_LOCK, SEMUNDO_UNLOCK, sem_undo::un_ent, and wakeup().
Referenced by seminit().


| int semget | ( | struct thread * | td, |
| struct semget_args * | uap | ||
| ) |
|
static |
Definition at line 248 of file sysv_sem.c.
References malloc(), mtx_init(), sem, sem_mtx, sem_undo_mtx, sema, sema_mtx, semexit_myhook(), SEMU, and syscall_helper_register().
Referenced by sysvsem_modload().


| int semop | ( | struct thread * | td, |
| struct semop_args * | uap | ||
| ) |
|
static |
Definition at line 369 of file sysv_sem.c.
References SEMUNDO_LOCKASSERT.
Referenced by semundo_adjust().

|
static |
Definition at line 384 of file sysv_sem.c.
References SEMUNDO_LOCKASSERT.
Referenced by semundo_adjust(), and semundo_clear().

|
static |
Definition at line 401 of file sysv_sem.c.
References semu_alloc(), semu_try_free(), SEMUNDO_LOCKASSERT, and sem_undo::un_ent.
Referenced by sys_semop().


|
static |
Definition at line 474 of file sysv_sem.c.
References semu_try_free(), SEMUNDO_LOCKASSERT, and sem_undo::un_ent.
Referenced by kern_semctl().


|
static |
Definition at line 303 of file sysv_sem.c.
References free(), mtx_destroy(), sem, sem_mtx, sem_undo_mtx, sema, sema_mtx, semtot, and syscall_helper_unregister().
Referenced by sysvsem_modload().


|
static |
Definition at line 502 of file sysv_sem.c.
Referenced by kern_semctl().

| int sys___semctl | ( | struct thread * | td, |
| struct __semctl_args * | uap | ||
| ) |
Definition at line 521 of file sysv_sem.c.
References __semctl_args::arg, __semctl_args::cmd, kern_semctl(), __semctl_args::semid, and __semctl_args::semnum.

| int sys_semget | ( | struct thread * | td, |
| struct semget_args * | uap | ||
| ) |
Definition at line 859 of file sysv_sem.c.
References crhold(), DPRINTF, ipcperm(), semget_args::key, semget_args::nsems, prison_allow(), racct_add(), sem, sem_mtx, sema, sema_mtx, semget_args::semflg, semtot, and time_second.

| int sys_semop | ( | struct thread * | td, |
| struct semop_args * | uap | ||
| ) |
Definition at line 983 of file sysv_sem.c.
References DPRINTF, free(), ipcperm(), malloc(), semop_args::nsops, panic(), prison_allow(), racct_get_available(), sem, sema, sema_mtx, semop_args::semid, semundo_adjust(), SEMUNDO_LOCK, SEMUNDO_UNLOCK, semop_args::sops, time_second, and wakeup().

| SYSCTL_INT | ( | _kern_ipc | , |
| OID_AUTO | , | ||
| semmni | , | ||
| CTLFLAG_RDTUN | , | ||
| &seminfo. | semmni, | ||
| 0 | , | ||
| "Number of semaphore identifiers" | |||
| ) |
| SYSCTL_INT | ( | _kern_ipc | , |
| OID_AUTO | , | ||
| semmns | , | ||
| CTLFLAG_RDTUN | , | ||
| &seminfo. | semmns, | ||
| 0 | , | ||
| "Maximum number of semaphores in the system" | |||
| ) |
| SYSCTL_INT | ( | _kern_ipc | , |
| OID_AUTO | , | ||
| semmnu | , | ||
| CTLFLAG_RDTUN | , | ||
| &seminfo. | semmnu, | ||
| 0 | , | ||
| "Maximum number of undo structures in the system" | |||
| ) |
| SYSCTL_INT | ( | _kern_ipc | , |
| OID_AUTO | , | ||
| semmsl | , | ||
| CTLFLAG_RW | , | ||
| &seminfo. | semmsl, | ||
| 0 | , | ||
| "Max semaphores per id" | |||
| ) |
| SYSCTL_INT | ( | _kern_ipc | , |
| OID_AUTO | , | ||
| semopm | , | ||
| CTLFLAG_RDTUN | , | ||
| &seminfo. | semopm, | ||
| 0 | , | ||
| "Max operations per semop call" | |||
| ) |
| SYSCTL_INT | ( | _kern_ipc | , |
| OID_AUTO | , | ||
| semume | , | ||
| CTLFLAG_RDTUN | , | ||
| &seminfo. | semume, | ||
| 0 | , | ||
| "Max undo entries per process" | |||
| ) |
| SYSCTL_INT | ( | _kern_ipc | , |
| OID_AUTO | , | ||
| semusz | , | ||
| CTLFLAG_RDTUN | , | ||
| &seminfo. | semusz, | ||
| 0 | , | ||
| "Size in bytes of undo structure" | |||
| ) |
| SYSCTL_INT | ( | _kern_ipc | , |
| OID_AUTO | , | ||
| semvmx | , | ||
| CTLFLAG_RW | , | ||
| &seminfo. | semvmx, | ||
| 0 | , | ||
| "Semaphore maximum value" | |||
| ) |
| SYSCTL_INT | ( | _kern_ipc | , |
| OID_AUTO | , | ||
| semaem | , | ||
| CTLFLAG_RW | , | ||
| &seminfo. | semaem, | ||
| 0 | , | ||
| "Adjust on exit max value" | |||
| ) |
| SYSCTL_PROC | ( | _kern_ipc | , |
| OID_AUTO | , | ||
| sema | , | ||
| CTLTYPE_OPAQUE| | CTLFLAG_RD, | ||
| NULL | , | ||
| 0 | , | ||
| sysctl_sema | , | ||
| "" | , | ||
| "Semaphore id pool" | |||
| ) |
|
static |
Definition at line 1373 of file sysv_sem.c.
References sema.
|
static |
Definition at line 332 of file sysv_sem.c.
References seminit(), and semunload().

|
static |
Definition at line 102 of file sysv_sem.c.
Referenced by kern_semctl(), seminit(), semunload(), sys_semget(), and sys_semop().
|
static |
Definition at line 97 of file sysv_sem.c.
Referenced by kern_semctl(), seminit(), semunload(), and sys_semget().
|
static |
Definition at line 214 of file sysv_sem.c.
|
static |
Definition at line 98 of file sysv_sem.c.
Referenced by seminit(), and semunload().
|
static |
Definition at line 100 of file sysv_sem.c.
Referenced by kern_semctl(), semexit_myhook(), seminit(), semunload(), sys_semget(), sys_semop(), and sysctl_sema().
|
static |
Definition at line 101 of file sysv_sem.c.
Referenced by kern_semctl(), semexit_myhook(), seminit(), semunload(), sys_semget(), and sys_semop().
| struct seminfo seminfo |
Definition at line 181 of file sysv_sem.c.
|
static |
Definition at line 99 of file sysv_sem.c.
Referenced by kern_semctl(), semunload(), and sys_semget().
|
static |
Definition at line 354 of file sysv_sem.c.