10Sstevel@tonic-gate /*
20Sstevel@tonic-gate * CDDL HEADER START
30Sstevel@tonic-gate *
40Sstevel@tonic-gate * The contents of this file are subject to the terms of the
5*1443Skchow * Common Development and Distribution License (the "License").
6*1443Skchow * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate *
80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate * See the License for the specific language governing permissions
110Sstevel@tonic-gate * and limitations under the License.
120Sstevel@tonic-gate *
130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate *
190Sstevel@tonic-gate * CDDL HEADER END
200Sstevel@tonic-gate */
210Sstevel@tonic-gate /*
22*1443Skchow * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
230Sstevel@tonic-gate * Use is subject to license terms.
240Sstevel@tonic-gate */
250Sstevel@tonic-gate
260Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI"
270Sstevel@tonic-gate
280Sstevel@tonic-gate #include <sys/types.h>
290Sstevel@tonic-gate #include <sys/cmn_err.h>
300Sstevel@tonic-gate #include <sys/sysmacros.h>
310Sstevel@tonic-gate #include <sys/proc.h>
320Sstevel@tonic-gate #include <sys/rctl.h>
330Sstevel@tonic-gate #include <sys/rctl_impl.h>
340Sstevel@tonic-gate #include <sys/port_kernel.h>
350Sstevel@tonic-gate
360Sstevel@tonic-gate #include <sys/vmparam.h>
370Sstevel@tonic-gate #include <sys/machparam.h>
380Sstevel@tonic-gate
390Sstevel@tonic-gate /*
400Sstevel@tonic-gate * Process-based resource controls
410Sstevel@tonic-gate * The structure of the kernel leaves us no particular place where the process
420Sstevel@tonic-gate * abstraction can be declared--it is intertwined with the growth of the Unix
430Sstevel@tonic-gate * kernel. Accordingly, we place all of the resource control logic associated
440Sstevel@tonic-gate * with processes, both existing and future, in this file.
450Sstevel@tonic-gate */
460Sstevel@tonic-gate
470Sstevel@tonic-gate rctl_hndl_t rctlproc_legacy[RLIM_NLIMITS];
480Sstevel@tonic-gate uint_t rctlproc_flags[RLIM_NLIMITS] = {
490Sstevel@tonic-gate RCTL_LOCAL_SIGNAL, /* RLIMIT_CPU */
500Sstevel@tonic-gate RCTL_LOCAL_DENY | RCTL_LOCAL_SIGNAL, /* RLIMIT_FSIZE */
510Sstevel@tonic-gate RCTL_LOCAL_DENY, /* RLIMIT_DATA */
520Sstevel@tonic-gate RCTL_LOCAL_DENY, /* RLIMIT_STACK */
530Sstevel@tonic-gate RCTL_LOCAL_DENY, /* RLIMIT_CORE */
540Sstevel@tonic-gate RCTL_LOCAL_DENY, /* RLIMIT_NOFILE */
550Sstevel@tonic-gate RCTL_LOCAL_DENY /* RLIMIT_VMEM */
560Sstevel@tonic-gate };
570Sstevel@tonic-gate int rctlproc_signals[RLIM_NLIMITS] = {
580Sstevel@tonic-gate SIGXCPU, /* RLIMIT_CPU */
590Sstevel@tonic-gate SIGXFSZ, /* RLIMIT_FSIZE */
600Sstevel@tonic-gate 0, 0, 0, 0, 0 /* remainder do not signal */
610Sstevel@tonic-gate };
620Sstevel@tonic-gate
630Sstevel@tonic-gate rctl_hndl_t rc_process_msgmnb;
640Sstevel@tonic-gate rctl_hndl_t rc_process_msgtql;
650Sstevel@tonic-gate rctl_hndl_t rc_process_semmsl;
660Sstevel@tonic-gate rctl_hndl_t rc_process_semopm;
670Sstevel@tonic-gate rctl_hndl_t rc_process_portev;
680Sstevel@tonic-gate
690Sstevel@tonic-gate /*
700Sstevel@tonic-gate * process.max-cpu-time / RLIMIT_CPU
710Sstevel@tonic-gate */
720Sstevel@tonic-gate /*ARGSUSED*/
730Sstevel@tonic-gate static int
proc_cpu_time_test(struct rctl * rctl,struct proc * p,rctl_entity_p_t * e,rctl_val_t * rval,rctl_qty_t inc,uint_t flags)740Sstevel@tonic-gate proc_cpu_time_test(struct rctl *rctl, struct proc *p, rctl_entity_p_t *e,
750Sstevel@tonic-gate rctl_val_t *rval, rctl_qty_t inc, uint_t flags)
760Sstevel@tonic-gate {
770Sstevel@tonic-gate return (inc >= rval->rcv_value);
780Sstevel@tonic-gate }
790Sstevel@tonic-gate
800Sstevel@tonic-gate static rctl_ops_t proc_cpu_time_ops = {
810Sstevel@tonic-gate rcop_no_action,
820Sstevel@tonic-gate rcop_no_usage,
830Sstevel@tonic-gate rcop_no_set,
840Sstevel@tonic-gate proc_cpu_time_test
850Sstevel@tonic-gate };
860Sstevel@tonic-gate
870Sstevel@tonic-gate /*
880Sstevel@tonic-gate * process.max-file-size / RLIMIT_FSIZE
890Sstevel@tonic-gate */
900Sstevel@tonic-gate static int
proc_filesize_set(rctl_t * rctl,struct proc * p,rctl_entity_p_t * e,rctl_qty_t nv)910Sstevel@tonic-gate proc_filesize_set(rctl_t *rctl, struct proc *p, rctl_entity_p_t *e,
920Sstevel@tonic-gate rctl_qty_t nv)
930Sstevel@tonic-gate {
940Sstevel@tonic-gate if (p->p_model == DATAMODEL_NATIVE)
950Sstevel@tonic-gate nv = MIN(nv, rctl->rc_dict_entry->rcd_max_native);
960Sstevel@tonic-gate else
970Sstevel@tonic-gate nv = MIN(nv, rctl->rc_dict_entry->rcd_max_ilp32);
980Sstevel@tonic-gate
990Sstevel@tonic-gate ASSERT(e->rcep_t == RCENTITY_PROCESS);
1000Sstevel@tonic-gate e->rcep_p.proc->p_fsz_ctl = nv;
1010Sstevel@tonic-gate
1020Sstevel@tonic-gate return (0);
1030Sstevel@tonic-gate }
1040Sstevel@tonic-gate
1050Sstevel@tonic-gate static rctl_ops_t proc_filesize_ops = {
1060Sstevel@tonic-gate rcop_no_action,
1070Sstevel@tonic-gate rcop_no_usage,
1080Sstevel@tonic-gate proc_filesize_set,
1090Sstevel@tonic-gate rcop_no_test
1100Sstevel@tonic-gate };
1110Sstevel@tonic-gate
1120Sstevel@tonic-gate /*
1130Sstevel@tonic-gate * process.max-data / RLIMIT_DATA
1140Sstevel@tonic-gate */
1150Sstevel@tonic-gate
1160Sstevel@tonic-gate /*
1170Sstevel@tonic-gate * process.max-stack-size / RLIMIT_STACK
1180Sstevel@tonic-gate */
1190Sstevel@tonic-gate static int
proc_stack_set(rctl_t * rctl,struct proc * p,rctl_entity_p_t * e,rctl_qty_t nv)1200Sstevel@tonic-gate proc_stack_set(rctl_t *rctl, struct proc *p, rctl_entity_p_t *e,
1210Sstevel@tonic-gate rctl_qty_t nv)
1220Sstevel@tonic-gate {
1230Sstevel@tonic-gate klwp_t *lwp = ttolwp(curthread);
1240Sstevel@tonic-gate
1250Sstevel@tonic-gate if (p->p_model == DATAMODEL_NATIVE)
1260Sstevel@tonic-gate nv = MIN(nv, rctl->rc_dict_entry->rcd_max_native);
1270Sstevel@tonic-gate else
1280Sstevel@tonic-gate nv = MIN(nv, rctl->rc_dict_entry->rcd_max_ilp32);
1290Sstevel@tonic-gate
1300Sstevel@tonic-gate /*
1310Sstevel@tonic-gate * In the process of changing the rlimit, this function actually
1320Sstevel@tonic-gate * gets called a number of times. We only want to save the current
1330Sstevel@tonic-gate * rlimit the first time we come through here. In post_syscall(),
1340Sstevel@tonic-gate * we copyin() the lwp's ustack, and compare it to the rlimit we
1350Sstevel@tonic-gate * save here; if the two match, we adjust the ustack to reflect
1360Sstevel@tonic-gate * the new stack bounds.
1370Sstevel@tonic-gate *
1380Sstevel@tonic-gate * We check to make sure that we're changing the rlimit of our
1390Sstevel@tonic-gate * own process rather than on behalf of some other process. The
1400Sstevel@tonic-gate * notion of changing this resource limit on behalf of another
1410Sstevel@tonic-gate * process is problematic at best, and changing the amount of stack
1420Sstevel@tonic-gate * space a process is allowed to consume is a rather antiquated
1430Sstevel@tonic-gate * notion that has limited applicability in our multithreaded
1440Sstevel@tonic-gate * process model.
1450Sstevel@tonic-gate */
1460Sstevel@tonic-gate ASSERT(e->rcep_t == RCENTITY_PROCESS);
1470Sstevel@tonic-gate if (lwp != NULL && lwp->lwp_procp == e->rcep_p.proc &&
1480Sstevel@tonic-gate lwp->lwp_ustack && lwp->lwp_old_stk_ctl == 0) {
1490Sstevel@tonic-gate lwp->lwp_old_stk_ctl = (size_t)e->rcep_p.proc->p_stk_ctl;
1500Sstevel@tonic-gate curthread->t_post_sys = 1;
1510Sstevel@tonic-gate }
1520Sstevel@tonic-gate
1530Sstevel@tonic-gate e->rcep_p.proc->p_stk_ctl = nv;
1540Sstevel@tonic-gate
1550Sstevel@tonic-gate return (0);
1560Sstevel@tonic-gate }
1570Sstevel@tonic-gate
1580Sstevel@tonic-gate static rctl_ops_t proc_stack_ops = {
1590Sstevel@tonic-gate rcop_no_action,
1600Sstevel@tonic-gate rcop_no_usage,
1610Sstevel@tonic-gate proc_stack_set,
1620Sstevel@tonic-gate rcop_no_test
1630Sstevel@tonic-gate };
1640Sstevel@tonic-gate
1650Sstevel@tonic-gate /*
1660Sstevel@tonic-gate * process.max-file-descriptors / RLIMIT_NOFILE
1670Sstevel@tonic-gate */
1680Sstevel@tonic-gate static int
proc_nofile_set(rctl_t * rctl,struct proc * p,rctl_entity_p_t * e,rctl_qty_t nv)1690Sstevel@tonic-gate proc_nofile_set(rctl_t *rctl, struct proc *p, rctl_entity_p_t *e, rctl_qty_t nv)
1700Sstevel@tonic-gate {
1710Sstevel@tonic-gate ASSERT(e->rcep_t == RCENTITY_PROCESS);
1720Sstevel@tonic-gate if (p->p_model == DATAMODEL_NATIVE)
1730Sstevel@tonic-gate nv = MIN(nv, rctl->rc_dict_entry->rcd_max_native);
1740Sstevel@tonic-gate else
1750Sstevel@tonic-gate nv = MIN(nv, rctl->rc_dict_entry->rcd_max_ilp32);
1760Sstevel@tonic-gate
1770Sstevel@tonic-gate e->rcep_p.proc->p_fno_ctl = nv;
1780Sstevel@tonic-gate
1790Sstevel@tonic-gate return (0);
1800Sstevel@tonic-gate }
1810Sstevel@tonic-gate
1820Sstevel@tonic-gate static rctl_ops_t proc_nofile_ops = {
1830Sstevel@tonic-gate rcop_no_action,
1840Sstevel@tonic-gate rcop_no_usage,
1850Sstevel@tonic-gate proc_nofile_set,
1860Sstevel@tonic-gate rcop_absolute_test
1870Sstevel@tonic-gate };
1880Sstevel@tonic-gate
1890Sstevel@tonic-gate /*
1900Sstevel@tonic-gate * process.max-address-space / RLIMIT_VMEM
1910Sstevel@tonic-gate */
1920Sstevel@tonic-gate static int
proc_vmem_set(rctl_t * rctl,struct proc * p,rctl_entity_p_t * e,rctl_qty_t nv)1930Sstevel@tonic-gate proc_vmem_set(rctl_t *rctl, struct proc *p, rctl_entity_p_t *e, rctl_qty_t nv)
1940Sstevel@tonic-gate {
1950Sstevel@tonic-gate ASSERT(e->rcep_t == RCENTITY_PROCESS);
1960Sstevel@tonic-gate if (p->p_model == DATAMODEL_ILP32)
1970Sstevel@tonic-gate nv = MIN(nv, rctl->rc_dict_entry->rcd_max_ilp32);
1980Sstevel@tonic-gate else
1990Sstevel@tonic-gate nv = MIN(nv, rctl->rc_dict_entry->rcd_max_native);
2000Sstevel@tonic-gate
2010Sstevel@tonic-gate e->rcep_p.proc->p_vmem_ctl = nv;
2020Sstevel@tonic-gate
2030Sstevel@tonic-gate return (0);
2040Sstevel@tonic-gate }
2050Sstevel@tonic-gate
2060Sstevel@tonic-gate static rctl_ops_t proc_vmem_ops = {
2070Sstevel@tonic-gate rcop_no_action,
2080Sstevel@tonic-gate rcop_no_usage,
2090Sstevel@tonic-gate proc_vmem_set,
2100Sstevel@tonic-gate rcop_no_test
2110Sstevel@tonic-gate };
2120Sstevel@tonic-gate
2130Sstevel@tonic-gate /*
2140Sstevel@tonic-gate * void rctlproc_default_init()
2150Sstevel@tonic-gate *
2160Sstevel@tonic-gate * Overview
2170Sstevel@tonic-gate * Establish default basic and privileged control values on the init process.
2180Sstevel@tonic-gate * These correspond to the soft and hard limits, respectively.
2190Sstevel@tonic-gate */
2200Sstevel@tonic-gate void
rctlproc_default_init(struct proc * initp,rctl_alloc_gp_t * gp)2210Sstevel@tonic-gate rctlproc_default_init(struct proc *initp, rctl_alloc_gp_t *gp)
2220Sstevel@tonic-gate {
2230Sstevel@tonic-gate struct rlimit64 rlp64;
2240Sstevel@tonic-gate
2250Sstevel@tonic-gate /*
2260Sstevel@tonic-gate * RLIMIT_CPU: deny never, sigtoproc(pp, NULL, SIGXCPU).
2270Sstevel@tonic-gate */
2280Sstevel@tonic-gate rlp64.rlim_cur = rlp64.rlim_max = RLIM64_INFINITY;
2290Sstevel@tonic-gate (void) rctl_rlimit_set(rctlproc_legacy[RLIMIT_CPU], initp, &rlp64, gp,
2300Sstevel@tonic-gate RCTL_LOCAL_SIGNAL, SIGXCPU, kcred);
2310Sstevel@tonic-gate
2320Sstevel@tonic-gate /*
2330Sstevel@tonic-gate * RLIMIT_FSIZE: deny always, sigtoproc(pp, NULL, SIGXFSZ).
2340Sstevel@tonic-gate */
2350Sstevel@tonic-gate rlp64.rlim_cur = rlp64.rlim_max = RLIM64_INFINITY;
2360Sstevel@tonic-gate (void) rctl_rlimit_set(rctlproc_legacy[RLIMIT_FSIZE], initp, &rlp64, gp,
2370Sstevel@tonic-gate RCTL_LOCAL_SIGNAL | RCTL_LOCAL_DENY, SIGXFSZ, kcred);
2380Sstevel@tonic-gate
2390Sstevel@tonic-gate /*
2400Sstevel@tonic-gate * RLIMIT_DATA: deny always, no default action.
2410Sstevel@tonic-gate */
2420Sstevel@tonic-gate rlp64.rlim_cur = rlp64.rlim_max = RLIM64_INFINITY;
2430Sstevel@tonic-gate (void) rctl_rlimit_set(rctlproc_legacy[RLIMIT_DATA], initp, &rlp64, gp,
2440Sstevel@tonic-gate RCTL_LOCAL_DENY, 0, kcred);
2450Sstevel@tonic-gate
2460Sstevel@tonic-gate /*
2470Sstevel@tonic-gate * RLIMIT_STACK: deny always, no default action.
2480Sstevel@tonic-gate */
2490Sstevel@tonic-gate #ifdef __sparc
2500Sstevel@tonic-gate rlp64.rlim_cur = DFLSSIZ;
2510Sstevel@tonic-gate rlp64.rlim_max = LONG_MAX;
2520Sstevel@tonic-gate #else
2530Sstevel@tonic-gate rlp64.rlim_cur = DFLSSIZ;
2540Sstevel@tonic-gate rlp64.rlim_max = MAXSSIZ;
2550Sstevel@tonic-gate #endif
2560Sstevel@tonic-gate (void) rctl_rlimit_set(rctlproc_legacy[RLIMIT_STACK], initp, &rlp64, gp,
2570Sstevel@tonic-gate RCTL_LOCAL_DENY, 0, kcred);
2580Sstevel@tonic-gate
2590Sstevel@tonic-gate /*
2600Sstevel@tonic-gate * RLIMIT_CORE: deny always, no default action.
2610Sstevel@tonic-gate */
2620Sstevel@tonic-gate rlp64.rlim_cur = rlp64.rlim_max = RLIM64_INFINITY;
2630Sstevel@tonic-gate (void) rctl_rlimit_set(rctlproc_legacy[RLIMIT_CORE], initp, &rlp64, gp,
2640Sstevel@tonic-gate RCTL_LOCAL_DENY, 0, kcred);
2650Sstevel@tonic-gate
2660Sstevel@tonic-gate /*
2670Sstevel@tonic-gate * RLIMIT_NOFILE: deny always, no action.
2680Sstevel@tonic-gate */
2690Sstevel@tonic-gate rlp64.rlim_cur = rlim_fd_cur;
2700Sstevel@tonic-gate rlp64.rlim_max = rlim_fd_max;
2710Sstevel@tonic-gate (void) rctl_rlimit_set(rctlproc_legacy[RLIMIT_NOFILE], initp, &rlp64,
2720Sstevel@tonic-gate gp, RCTL_LOCAL_DENY, 0, kcred);
2730Sstevel@tonic-gate
2740Sstevel@tonic-gate /*
2750Sstevel@tonic-gate * RLIMIT_VMEM
2760Sstevel@tonic-gate */
2770Sstevel@tonic-gate rlp64.rlim_cur = rlp64.rlim_max = RLIM64_INFINITY;
2780Sstevel@tonic-gate (void) rctl_rlimit_set(rctlproc_legacy[RLIMIT_VMEM], initp, &rlp64, gp,
2790Sstevel@tonic-gate RCTL_LOCAL_DENY, 0, kcred);
2800Sstevel@tonic-gate }
2810Sstevel@tonic-gate
2820Sstevel@tonic-gate /*
2830Sstevel@tonic-gate * void rctlproc_init()
2840Sstevel@tonic-gate *
2850Sstevel@tonic-gate * Overview
2860Sstevel@tonic-gate * Register the various resource controls associated with process entities.
2870Sstevel@tonic-gate * The historical rlim_infinity_map and rlim_infinity32_map are now encoded
2880Sstevel@tonic-gate * here as the native and ILP32 infinite values for each resource control.
2890Sstevel@tonic-gate */
2900Sstevel@tonic-gate void
rctlproc_init()2910Sstevel@tonic-gate rctlproc_init()
2920Sstevel@tonic-gate {
2930Sstevel@tonic-gate rctl_set_t *set;
2940Sstevel@tonic-gate rctl_alloc_gp_t *gp;
2950Sstevel@tonic-gate rctl_entity_p_t e;
2960Sstevel@tonic-gate
2970Sstevel@tonic-gate rctlproc_legacy[RLIMIT_CPU] = rctl_register("process.max-cpu-time",
2980Sstevel@tonic-gate RCENTITY_PROCESS, RCTL_GLOBAL_LOWERABLE | RCTL_GLOBAL_DENY_NEVER |
2990Sstevel@tonic-gate RCTL_GLOBAL_CPU_TIME | RCTL_GLOBAL_INFINITE | RCTL_GLOBAL_SECONDS,
3000Sstevel@tonic-gate UINT64_MAX, UINT64_MAX, &proc_cpu_time_ops);
3010Sstevel@tonic-gate rctlproc_legacy[RLIMIT_FSIZE] = rctl_register("process.max-file-size",
3020Sstevel@tonic-gate RCENTITY_PROCESS, RCTL_GLOBAL_LOWERABLE | RCTL_GLOBAL_DENY_ALWAYS |
3030Sstevel@tonic-gate RCTL_GLOBAL_FILE_SIZE | RCTL_GLOBAL_BYTES,
3040Sstevel@tonic-gate MAXOFFSET_T, MAXOFFSET_T, &proc_filesize_ops);
3050Sstevel@tonic-gate rctlproc_legacy[RLIMIT_DATA] = rctl_register("process.max-data-size",
3060Sstevel@tonic-gate RCENTITY_PROCESS, RCTL_GLOBAL_LOWERABLE | RCTL_GLOBAL_DENY_ALWAYS |
3070Sstevel@tonic-gate RCTL_GLOBAL_SIGNAL_NEVER | RCTL_GLOBAL_BYTES,
3080Sstevel@tonic-gate ULONG_MAX, UINT32_MAX, &rctl_default_ops);
3090Sstevel@tonic-gate #ifdef _LP64
3100Sstevel@tonic-gate #ifdef __sparc
3110Sstevel@tonic-gate rctlproc_legacy[RLIMIT_STACK] = rctl_register("process.max-stack-size",
3120Sstevel@tonic-gate RCENTITY_PROCESS, RCTL_GLOBAL_LOWERABLE | RCTL_GLOBAL_DENY_ALWAYS |
3130Sstevel@tonic-gate RCTL_GLOBAL_SIGNAL_NEVER | RCTL_GLOBAL_BYTES,
3140Sstevel@tonic-gate LONG_MAX, INT32_MAX, &proc_stack_ops);
3150Sstevel@tonic-gate #else /* __sparc */
3160Sstevel@tonic-gate rctlproc_legacy[RLIMIT_STACK] = rctl_register("process.max-stack-size",
3170Sstevel@tonic-gate RCENTITY_PROCESS, RCTL_GLOBAL_LOWERABLE | RCTL_GLOBAL_DENY_ALWAYS |
3180Sstevel@tonic-gate RCTL_GLOBAL_SIGNAL_NEVER | RCTL_GLOBAL_BYTES,
319*1443Skchow MAXSSIZ, USRSTACK32 - PAGESIZE, &proc_stack_ops);
3200Sstevel@tonic-gate #endif /* __sparc */
3210Sstevel@tonic-gate #else /* _LP64 */
3220Sstevel@tonic-gate rctlproc_legacy[RLIMIT_STACK] = rctl_register("process.max-stack-size",
3230Sstevel@tonic-gate RCENTITY_PROCESS, RCTL_GLOBAL_LOWERABLE | RCTL_GLOBAL_DENY_ALWAYS |
3240Sstevel@tonic-gate RCTL_GLOBAL_SIGNAL_NEVER | RCTL_GLOBAL_BYTES,
325*1443Skchow USRSTACK - PAGESIZE, USRSTACK - PAGESIZE, &proc_stack_ops);
3260Sstevel@tonic-gate #endif
3270Sstevel@tonic-gate rctlproc_legacy[RLIMIT_CORE] = rctl_register("process.max-core-size",
3280Sstevel@tonic-gate RCENTITY_PROCESS, RCTL_GLOBAL_LOWERABLE | RCTL_GLOBAL_DENY_ALWAYS |
3290Sstevel@tonic-gate RCTL_GLOBAL_SIGNAL_NEVER | RCTL_GLOBAL_BYTES,
3300Sstevel@tonic-gate MIN(MAXOFFSET_T, ULONG_MAX), UINT32_MAX, &rctl_default_ops);
3310Sstevel@tonic-gate rctlproc_legacy[RLIMIT_NOFILE] = rctl_register(
3320Sstevel@tonic-gate "process.max-file-descriptor", RCENTITY_PROCESS,
3330Sstevel@tonic-gate RCTL_GLOBAL_LOWERABLE | RCTL_GLOBAL_DENY_ALWAYS |
3340Sstevel@tonic-gate RCTL_GLOBAL_COUNT, INT32_MAX, INT32_MAX, &proc_nofile_ops);
3350Sstevel@tonic-gate rctlproc_legacy[RLIMIT_VMEM] =
3360Sstevel@tonic-gate rctl_register("process.max-address-space", RCENTITY_PROCESS,
3370Sstevel@tonic-gate RCTL_GLOBAL_LOWERABLE | RCTL_GLOBAL_DENY_ALWAYS |
3380Sstevel@tonic-gate RCTL_GLOBAL_SIGNAL_NEVER | RCTL_GLOBAL_BYTES,
3390Sstevel@tonic-gate ULONG_MAX, UINT32_MAX, &proc_vmem_ops);
3400Sstevel@tonic-gate
3410Sstevel@tonic-gate rc_process_semmsl = rctl_register("process.max-sem-nsems",
3420Sstevel@tonic-gate RCENTITY_PROCESS, RCTL_GLOBAL_DENY_ALWAYS | RCTL_GLOBAL_COUNT,
3430Sstevel@tonic-gate SHRT_MAX, SHRT_MAX, &rctl_absolute_ops);
3440Sstevel@tonic-gate rctl_add_legacy_limit("process.max-sem-nsems", "semsys",
3450Sstevel@tonic-gate "seminfo_semmsl", 512, SHRT_MAX);
3460Sstevel@tonic-gate
3470Sstevel@tonic-gate rc_process_semopm = rctl_register("process.max-sem-ops",
3480Sstevel@tonic-gate RCENTITY_PROCESS, RCTL_GLOBAL_DENY_ALWAYS | RCTL_GLOBAL_COUNT,
3490Sstevel@tonic-gate INT_MAX, INT_MAX, &rctl_absolute_ops);
3500Sstevel@tonic-gate rctl_add_legacy_limit("process.max-sem-ops", "semsys",
3510Sstevel@tonic-gate "seminfo_semopm", 512, INT_MAX);
3520Sstevel@tonic-gate
3530Sstevel@tonic-gate rc_process_msgmnb = rctl_register("process.max-msg-qbytes",
3540Sstevel@tonic-gate RCENTITY_PROCESS, RCTL_GLOBAL_DENY_ALWAYS | RCTL_GLOBAL_BYTES,
3550Sstevel@tonic-gate ULONG_MAX, ULONG_MAX, &rctl_absolute_ops);
3560Sstevel@tonic-gate rctl_add_legacy_limit("process.max-msg-qbytes", "msgsys",
3570Sstevel@tonic-gate "msginfo_msgmnb", 65536, ULONG_MAX);
3580Sstevel@tonic-gate
3590Sstevel@tonic-gate rc_process_msgtql = rctl_register("process.max-msg-messages",
3600Sstevel@tonic-gate RCENTITY_PROCESS, RCTL_GLOBAL_DENY_ALWAYS | RCTL_GLOBAL_COUNT,
3610Sstevel@tonic-gate UINT_MAX, UINT_MAX, &rctl_absolute_ops);
3620Sstevel@tonic-gate rctl_add_legacy_limit("process.max-msg-messages", "msgsys",
3630Sstevel@tonic-gate "msginfo_msgtql", 8192, UINT_MAX);
3640Sstevel@tonic-gate
3650Sstevel@tonic-gate rc_process_portev = rctl_register("process.max-port-events",
3660Sstevel@tonic-gate RCENTITY_PROCESS, RCTL_GLOBAL_DENY_ALWAYS | RCTL_GLOBAL_COUNT,
3670Sstevel@tonic-gate PORT_MAX_EVENTS, PORT_MAX_EVENTS, &rctl_absolute_ops);
3680Sstevel@tonic-gate rctl_add_default_limit("process.max-port-events", PORT_DEFAULT_EVENTS,
3690Sstevel@tonic-gate RCPRIV_PRIVILEGED, RCTL_LOCAL_DENY);
3700Sstevel@tonic-gate
3710Sstevel@tonic-gate /*
3720Sstevel@tonic-gate * Place minimal set of controls on "sched" process for inheritance by
3730Sstevel@tonic-gate * processes created via newproc().
3740Sstevel@tonic-gate */
3750Sstevel@tonic-gate set = rctl_set_create();
3760Sstevel@tonic-gate gp = rctl_set_init_prealloc(RCENTITY_PROCESS);
3770Sstevel@tonic-gate mutex_enter(&curproc->p_lock);
3780Sstevel@tonic-gate e.rcep_p.proc = curproc;
3790Sstevel@tonic-gate e.rcep_t = RCENTITY_PROCESS;
3800Sstevel@tonic-gate curproc->p_rctls = rctl_set_init(RCENTITY_PROCESS, curproc, &e,
3810Sstevel@tonic-gate set, gp);
3820Sstevel@tonic-gate mutex_exit(&curproc->p_lock);
3830Sstevel@tonic-gate rctl_prealloc_destroy(gp);
3840Sstevel@tonic-gate }
385