rctl_proc.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <sys/sysmacros.h>
#include <sys/rctl_impl.h>
#include <sys/port_kernel.h>
#include <sys/machparam.h>
/*
* Process-based resource controls
* The structure of the kernel leaves us no particular place where the process
* abstraction can be declared--it is intertwined with the growth of the Unix
* kernel. Accordingly, we place all of the resource control logic associated
* with processes, both existing and future, in this file.
*/
RCTL_LOCAL_SIGNAL, /* RLIMIT_CPU */
RCTL_LOCAL_DENY, /* RLIMIT_DATA */
RCTL_LOCAL_DENY, /* RLIMIT_STACK */
RCTL_LOCAL_DENY, /* RLIMIT_CORE */
RCTL_LOCAL_DENY, /* RLIMIT_NOFILE */
RCTL_LOCAL_DENY /* RLIMIT_VMEM */
};
int rctlproc_signals[RLIM_NLIMITS] = {
SIGXCPU, /* RLIMIT_CPU */
SIGXFSZ, /* RLIMIT_FSIZE */
0, 0, 0, 0, 0 /* remainder do not signal */
};
/*
* process.max-cpu-time / RLIMIT_CPU
*/
/*ARGSUSED*/
static int
{
}
static rctl_ops_t proc_cpu_time_ops = {
};
/*
* process.max-file-size / RLIMIT_FSIZE
*/
static int
{
if (p->p_model == DATAMODEL_NATIVE)
else
return (0);
}
static rctl_ops_t proc_filesize_ops = {
};
/*
* process.max-data / RLIMIT_DATA
*/
/*
* process.max-stack-size / RLIMIT_STACK
*/
static int
{
if (p->p_model == DATAMODEL_NATIVE)
else
/*
* In the process of changing the rlimit, this function actually
* gets called a number of times. We only want to save the current
* rlimit the first time we come through here. In post_syscall(),
* we copyin() the lwp's ustack, and compare it to the rlimit we
* save here; if the two match, we adjust the ustack to reflect
* the new stack bounds.
*
* We check to make sure that we're changing the rlimit of our
* own process rather than on behalf of some other process. The
* notion of changing this resource limit on behalf of another
* process is problematic at best, and changing the amount of stack
* space a process is allowed to consume is a rather antiquated
* notion that has limited applicability in our multithreaded
* process model.
*/
}
return (0);
}
static rctl_ops_t proc_stack_ops = {
};
/*
* process.max-file-descriptors / RLIMIT_NOFILE
*/
static int
{
if (p->p_model == DATAMODEL_NATIVE)
else
return (0);
}
static rctl_ops_t proc_nofile_ops = {
};
/*
* process.max-address-space / RLIMIT_VMEM
*/
static int
{
if (p->p_model == DATAMODEL_ILP32)
else
return (0);
}
static rctl_ops_t proc_vmem_ops = {
};
/*
* void rctlproc_default_init()
*
* Overview
* Establish default basic and privileged control values on the init process.
* These correspond to the soft and hard limits, respectively.
*/
void
{
/*
* RLIMIT_CPU: deny never, sigtoproc(pp, NULL, SIGXCPU).
*/
/*
* RLIMIT_FSIZE: deny always, sigtoproc(pp, NULL, SIGXFSZ).
*/
/*
* RLIMIT_DATA: deny always, no default action.
*/
RCTL_LOCAL_DENY, 0, kcred);
/*
* RLIMIT_STACK: deny always, no default action.
*/
#ifdef __sparc
#else
#endif
RCTL_LOCAL_DENY, 0, kcred);
/*
* RLIMIT_CORE: deny always, no default action.
*/
RCTL_LOCAL_DENY, 0, kcred);
/*
* RLIMIT_NOFILE: deny always, no action.
*/
/*
* RLIMIT_VMEM
*/
RCTL_LOCAL_DENY, 0, kcred);
}
/*
* void rctlproc_init()
*
* Overview
* Register the various resource controls associated with process entities.
* The historical rlim_infinity_map and rlim_infinity32_map are now encoded
* here as the native and ILP32 infinite values for each resource control.
*/
void
{
#ifdef _LP64
#ifdef __sparc
#else /* __sparc */
#endif /* __sparc */
#else /* _LP64 */
#endif
"process.max-file-descriptor", RCENTITY_PROCESS,
/*
* Place minimal set of controls on "sched" process for inheritance by
* processes created via newproc().
*/
set = rctl_set_create();
e.rcep_t = RCENTITY_PROCESS;
}