FreeBSD kernel kern code
|
#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/sysproto.h>
#include <sys/file.h>
#include <sys/kernel.h>
#include <sys/lock.h>
#include <sys/malloc.h>
#include <sys/mutex.h>
#include <sys/priv.h>
#include <sys/proc.h>
#include <sys/refcount.h>
#include <sys/racct.h>
#include <sys/resourcevar.h>
#include <sys/rwlock.h>
#include <sys/sched.h>
#include <sys/sx.h>
#include <sys/syscallsubr.h>
#include <sys/sysctl.h>
#include <sys/sysent.h>
#include <sys/time.h>
#include <sys/umtxvar.h>
#include <vm/vm.h>
#include <vm/vm_param.h>
#include <vm/pmap.h>
#include <vm/vm_map.h>
Go to the source code of this file.
Data Structures | |
struct | setpriority_args |
struct | rtprio_thread_args |
struct | rtprio_args |
struct | setrlimit_args |
struct | getrlimit_args |
struct | getrusage_args |
Macros | |
#define | UIHASH(uid) (&uihashtbl[(uid) & uihash]) |
#define | flsll(x) (fls((x) >> 32) != 0 ? fls((x) >> 32) + 32 : fls(x)) |
Functions | |
__FBSDID ("$FreeBSD$") | |
static | MALLOC_DEFINE (M_PLIMIT, "plimit", "plimit structures") |
static | MALLOC_DEFINE (M_UIDINFO, "uidinfo", "uidinfo structures") |
static | LIST_HEAD (uihashhead, uidinfo) |
int | sys_getpriority (struct thread *td, struct getpriority_args *uap) |
int | kern_getpriority (struct thread *td, int which, int who) |
int | sys_setpriority (struct thread *td, struct setpriority_args *uap) |
int | kern_setpriority (struct thread *td, int which, int who, int prio) |
static int | donice (struct thread *td, struct proc *p, int n) |
SYSCTL_INT (_security_bsd, OID_AUTO, unprivileged_idprio, CTLFLAG_RW, &unprivileged_idprio, 0, "Allow non-root users to set an idle priority (deprecated)") | |
int | sys_rtprio_thread (struct thread *td, struct rtprio_thread_args *uap) |
int | sys_rtprio (struct thread *td, struct rtprio_args *uap) |
int | rtp_to_pri (struct rtprio *rtp, struct thread *td) |
void | pri_to_rtp (struct thread *td, struct rtprio *rtp) |
int | sys_setrlimit (struct thread *td, struct setrlimit_args *uap) |
static void | lim_cb (void *arg) |
int | kern_setrlimit (struct thread *td, u_int which, struct rlimit *limp) |
int | kern_proc_setrlimit (struct thread *td, struct proc *p, u_int which, struct rlimit *limp) |
int | sys_getrlimit (struct thread *td, struct getrlimit_args *uap) |
void | calccru (struct proc *p, struct timeval *up, struct timeval *sp) |
void | calcru (struct proc *p, struct timeval *up, struct timeval *sp) |
void | rufetchtd (struct thread *td, struct rusage *ru) |
static uint64_t | mul64_by_fraction (uint64_t a, uint64_t b, uint64_t c) |
static void | calcru1 (struct proc *p, struct rusage_ext *ruxp, struct timeval *up, struct timeval *sp) |
int | sys_getrusage (struct thread *td, struct getrusage_args *uap) |
int | kern_getrusage (struct thread *td, int who, struct rusage *rup) |
void | rucollect (struct rusage *ru, struct rusage *ru2) |
void | ruadd (struct rusage *ru, struct rusage_ext *rux, struct rusage *ru2, struct rusage_ext *rux2) |
static void | ruxagg_ext_locked (struct rusage_ext *rux, struct thread *td) |
void | ruxagg_locked (struct proc *p, struct thread *td) |
void | ruxagg (struct proc *p, struct thread *td) |
void | rufetch (struct proc *p, struct rusage *ru) |
void | rufetchcalc (struct proc *p, struct rusage *ru, struct timeval *up, struct timeval *sp) |
struct plimit * | lim_alloc () |
struct plimit * | lim_hold (struct plimit *limp) |
struct plimit * | lim_cowsync (void) |
void | lim_fork (struct proc *p1, struct proc *p2) |
void | lim_free (struct plimit *limp) |
void | lim_freen (struct plimit *limp, int n) |
void | lim_copy (struct plimit *dst, struct plimit *src) |
rlim_t | lim_max (struct thread *td, int which) |
rlim_t | lim_max_proc (struct proc *p, int which) |
rlim_t() | lim_cur (struct thread *td, int which) |
rlim_t | lim_cur_proc (struct proc *p, int which) |
void | lim_rlimit (struct thread *td, int which, struct rlimit *rlp) |
void | lim_rlimit_proc (struct proc *p, int which, struct rlimit *rlp) |
void | uihashinit () |
static struct uidinfo * | uilookup (uid_t uid) |
struct uidinfo * | uifind (uid_t uid) |
void | uihold (struct uidinfo *uip) |
void | uifree (struct uidinfo *uip) |
static int | chglimit (struct uidinfo *uip, long *limit, int diff, rlim_t max, const char *name) |
int | chgproccnt (struct uidinfo *uip, int diff, rlim_t max) |
int | chgsbsize (struct uidinfo *uip, u_int *hiwat, u_int to, rlim_t max) |
int | chgptscnt (struct uidinfo *uip, int diff, rlim_t max) |
int | chgkqcnt (struct uidinfo *uip, int diff, rlim_t max) |
int | chgumtxcnt (struct uidinfo *uip, int diff, rlim_t max) |
Variables | |
static struct rwlock | uihashtbl_lock |
static int | unprivileged_idprio |
#define flsll | ( | x | ) | (fls((x) >> 32) != 0 ? fls((x) >> 32) + 32 : fls(x)) |
Definition at line 890 of file kern_resource.c.
#define UIHASH | ( | uid | ) | (&uihashtbl[(uid) & uihash]) |
Definition at line 71 of file kern_resource.c.
__FBSDID | ( | "$FreeBSD$" | ) |
void calccru | ( | struct proc * | p, |
struct timeval * | up, | ||
struct timeval * | sp | ||
) |
Definition at line 817 of file kern_resource.c.
References calcru1().
Referenced by fill_kinfo_proc_only(), kern_getrusage(), and proc_to_reap().
void calcru | ( | struct proc * | p, |
struct timeval * | up, | ||
struct timeval * | sp | ||
) |
Definition at line 830 of file kern_resource.c.
References calcru1(), cpu_ticks, and ruxagg().
Referenced by fill_kinfo_proc_only(), kern_clock_gettime(), proc_to_reap(), and rufetchcalc().
|
static |
Definition at line 973 of file kern_resource.c.
References cputick2usec(), mul64_by_fraction(), printf(), st, and vm_guest.
Referenced by calccru(), calcru(), and rufetchtd().
int chgkqcnt | ( | struct uidinfo * | uip, |
int | diff, | ||
rlim_t | max | ||
) |
Definition at line 1581 of file kern_resource.c.
References chglimit().
Referenced by kern_kqueue(), and kqueue_close().
|
inlinestatic |
Definition at line 1523 of file kern_resource.c.
References name, and printf().
Referenced by chgkqcnt(), chgproccnt(), chgptscnt(), chgsbsize(), and chgumtxcnt().
int chgproccnt | ( | struct uidinfo * | uip, |
int | diff, | ||
rlim_t | max | ||
) |
Definition at line 1544 of file kern_resource.c.
References chglimit().
Referenced by change_ruid(), fork1(), proc0_init(), and proc_reap().
int chgptscnt | ( | struct uidinfo * | uip, |
int | diff, | ||
rlim_t | max | ||
) |
Definition at line 1574 of file kern_resource.c.
References chglimit().
Referenced by pts_alloc(), pts_alloc_external(), and ptsdrv_free().
int chgsbsize | ( | struct uidinfo * | uip, |
u_int * | hiwat, | ||
u_int | to, | ||
rlim_t | max | ||
) |
Definition at line 1554 of file kern_resource.c.
References chglimit().
Referenced by sbrelease_internal(), sbreserve_locked(), and sodealloc().
int chgumtxcnt | ( | struct uidinfo * | uip, |
int | diff, | ||
rlim_t | max | ||
) |
Definition at line 1588 of file kern_resource.c.
References chglimit().
Referenced by umtx_shm_create_reg(), and umtx_shm_free_reg().
|
static |
Definition at line 268 of file kern_resource.c.
References p_cansched(), priv_check(), and sched_nice().
Referenced by kern_setpriority().
int kern_getpriority | ( | struct thread * | td, |
int | which, | ||
int | who | ||
) |
Definition at line 99 of file kern_resource.c.
References allproc_lock, p_cansee(), pfind(), pgfind(), and proctree_lock.
Referenced by sys_getpriority().
int kern_getrusage | ( | struct thread * | td, |
int | who, | ||
struct rusage * | rup | ||
) |
Definition at line 1072 of file kern_resource.c.
References calccru(), rufetchcalc(), and rufetchtd().
Referenced by dotrace(), and sys_getrusage().
int kern_proc_setrlimit | ( | struct thread * | td, |
struct proc * | p, | ||
u_int | which, | ||
struct rlimit * | limp | ||
) |
Definition at line 656 of file kern_resource.c.
References addr, lim_alloc(), lim_cb(), lim_copy(), lim_cowsync(), lim_free(), lim_freen(), maxdsiz, maxfilesperproc, maxprocperuid, maxssiz, priv_check(), and thread_cow_synced().
Referenced by kern_setrlimit(), and sysctl_kern_proc_rlimit().
int kern_setpriority | ( | struct thread * | td, |
int | which, | ||
int | who, | ||
int | prio | ||
) |
Definition at line 188 of file kern_resource.c.
References allproc_lock, donice(), p_cansee(), pfind(), pgfind(), and proctree_lock.
Referenced by sys_setpriority().
int kern_setrlimit | ( | struct thread * | td, |
u_int | which, | ||
struct rlimit * | limp | ||
) |
Definition at line 649 of file kern_resource.c.
References kern_proc_setrlimit().
Referenced by exec_map_stack(), and sys_setrlimit().
struct plimit * lim_alloc | ( | ) |
Definition at line 1212 of file kern_resource.c.
References malloc().
Referenced by kern_proc_setrlimit(), and proc0_init().
|
static |
Definition at line 614 of file kern_resource.c.
References cpu_tickrate(), kern_psignal(), killproc(), lim_cb(), lim_rlimit_proc(), and ruxagg().
Referenced by kern_proc_setrlimit(), lim_cb(), and lim_fork().
void lim_copy | ( | struct plimit * | dst, |
struct plimit * | src | ||
) |
Definition at line 1284 of file kern_resource.c.
References src.
Referenced by kern_proc_setrlimit().
struct plimit * lim_cowsync | ( | void | ) |
Definition at line 1230 of file kern_resource.c.
References lim_hold().
Referenced by kern_proc_setrlimit(), and thread_cow_update().
rlim_t() lim_cur | ( | struct thread * | td, |
int | which | ||
) |
Definition at line 1317 of file kern_resource.c.
References lim_rlimit().
Referenced by coredump(), fork1(), getmaxfd(), kern_kqueue(), pts_alloc(), pts_alloc_external(), sbreserve_locked(), umtx_shm_create_reg(), and vn_rlimit_fsize().
rlim_t lim_cur_proc | ( | struct proc * | p, |
int | which | ||
) |
Definition at line 1327 of file kern_resource.c.
References lim_rlimit_proc().
Referenced by enforce_limits(), and exec_aout_imgact().
void lim_fork | ( | struct proc * | p1, |
struct proc * | p2 | ||
) |
Definition at line 1250 of file kern_resource.c.
References lim_cb(), and lim_hold().
Referenced by do_fork().
void lim_free | ( | struct plimit * | limp | ) |
Definition at line 1264 of file kern_resource.c.
References free().
Referenced by exit1(), kern_proc_setrlimit(), thread_cow_free(), and thread_cow_update().
void lim_freen | ( | struct plimit * | limp, |
int | n | ||
) |
Definition at line 1272 of file kern_resource.c.
References free().
Referenced by kern_proc_setrlimit(), and thread_reap_domain().
struct plimit * lim_hold | ( | struct plimit * | limp | ) |
Definition at line 1222 of file kern_resource.c.
Referenced by lim_cowsync(), lim_fork(), thread_cow_get(), and thread_cow_get_proc().
rlim_t lim_max | ( | struct thread * | td, |
int | which | ||
) |
Definition at line 1296 of file kern_resource.c.
References lim_rlimit().
Referenced by copyout_map(), exec_map_stack(), kern_shmat_locked(), and shm_mmap_large().
rlim_t lim_max_proc | ( | struct proc * | p, |
int | which | ||
) |
Definition at line 1305 of file kern_resource.c.
References lim_rlimit_proc().
void lim_rlimit | ( | struct thread * | td, |
int | which, | ||
struct rlimit * | rlp | ||
) |
Definition at line 1340 of file kern_resource.c.
Referenced by lim_cur(), lim_max(), and sys_getrlimit().
void lim_rlimit_proc | ( | struct proc * | p, |
int | which, | ||
struct rlimit * | rlp | ||
) |
Definition at line 1353 of file kern_resource.c.
Referenced by exec_map_stack(), lim_cb(), lim_cur_proc(), lim_max_proc(), note_procstat_rlimit(), and sysctl_kern_proc_rlimit().
|
static |
Definition at line 73 of file kern_resource.c.
|
static |
|
static |
|
static |
Definition at line 894 of file kern_resource.c.
References flsll.
Referenced by calcru1().
void pri_to_rtp | ( | struct thread * | td, |
struct rtprio * | rtp | ||
) |
Definition at line 519 of file kern_resource.c.
Referenced by getscheduler(), ksched_getparam(), sys_rtprio(), and sys_rtprio_thread().
int rtp_to_pri | ( | struct rtprio * | rtp, |
struct thread * | td | ||
) |
Definition at line 476 of file kern_resource.c.
References sched_class(), sched_prio(), sched_user_prio(), and umtx_pi_adjust().
Referenced by ksched_setscheduler(), poll_idle(), sys_rtprio(), sys_rtprio_thread(), and thread_create().
void ruadd | ( | struct rusage * | ru, |
struct rusage_ext * | rux, | ||
struct rusage * | ru2, | ||
struct rusage_ext * | rux2 | ||
) |
Definition at line 1121 of file kern_resource.c.
References rucollect().
Referenced by exit1(), and proc_reap().
void rucollect | ( | struct rusage * | ru, |
struct rusage * | ru2 | ||
) |
Definition at line 1107 of file kern_resource.c.
Referenced by ruadd(), rufetch(), and thread_exit().
void rufetch | ( | struct proc * | p, |
struct rusage * | ru | ||
) |
Definition at line 1176 of file kern_resource.c.
References rucollect(), and ruxagg().
Referenced by fill_kinfo_proc_only(), kern_process_cputime(), proc0_post(), and rufetchcalc().
void rufetchcalc | ( | struct proc * | p, |
struct rusage * | ru, | ||
struct timeval * | up, | ||
struct timeval * | sp | ||
) |
Definition at line 1197 of file kern_resource.c.
References calcru(), and rufetch().
Referenced by acct_process(), kern_getrusage(), and tty_info().
void rufetchtd | ( | struct thread * | td, |
struct rusage * | ru | ||
) |
Definition at line 862 of file kern_resource.c.
References calcru1(), cpu_ticks, and ruxagg_locked().
Referenced by fill_kinfo_thread(), and kern_getrusage().
void ruxagg | ( | struct proc * | p, |
struct thread * | td | ||
) |
Definition at line 1163 of file kern_resource.c.
References ruxagg_locked().
Referenced by calcru(), lim_cb(), and rufetch().
|
static |
Definition at line 1139 of file kern_resource.c.
Referenced by ruxagg_locked().
void ruxagg_locked | ( | struct proc * | p, |
struct thread * | td | ||
) |
Definition at line 1149 of file kern_resource.c.
References ruxagg_ext_locked().
Referenced by rufetchtd(), ruxagg(), and thread_exit().
int sys_getpriority | ( | struct thread * | td, |
struct getpriority_args * | uap | ||
) |
Definition at line 92 of file kern_resource.c.
References kern_getpriority().
int sys_getrlimit | ( | struct thread * | td, |
struct getrlimit_args * | uap | ||
) |
Definition at line 800 of file kern_resource.c.
References lim_rlimit(), getrlimit_args::rlp, and getrlimit_args::which.
int sys_getrusage | ( | struct thread * | td, |
struct getrusage_args * | uap | ||
) |
Definition at line 1060 of file kern_resource.c.
References kern_getrusage(), getrusage_args::rusage, and getrusage_args::who.
int sys_rtprio | ( | struct thread * | td, |
struct rtprio_args * | uap | ||
) |
Definition at line 382 of file kern_resource.c.
References rtprio_args::function, p_cansched(), p_cansee(), pfind(), rtprio_args::pid, pri_to_rtp(), priv_check(), rtprio_args::rtp, rtp_to_pri(), and unprivileged_idprio.
int sys_rtprio_thread | ( | struct thread * | td, |
struct rtprio_thread_args * | uap | ||
) |
Definition at line 301 of file kern_resource.c.
References rtprio_thread_args::function, rtprio_thread_args::lwpid, p_cansched(), p_cansee(), pri_to_rtp(), priv_check(), rtprio_thread_args::rtp, rtp_to_pri(), tdfind(), and unprivileged_idprio.
int sys_setpriority | ( | struct thread * | td, |
struct setpriority_args * | uap | ||
) |
Definition at line 181 of file kern_resource.c.
References kern_setpriority(), setpriority_args::prio, setpriority_args::which, and setpriority_args::who.
int sys_setrlimit | ( | struct thread * | td, |
struct setrlimit_args * | uap | ||
) |
Definition at line 602 of file kern_resource.c.
References kern_setrlimit(), setrlimit_args::rlp, and setrlimit_args::which.
SYSCTL_INT | ( | _security_bsd | , |
OID_AUTO | , | ||
unprivileged_idprio | , | ||
CTLFLAG_RW | , | ||
& | unprivileged_idprio, | ||
0 | , | ||
"Allow non-root users to set an idle priority (deprecated)" | |||
) |
struct uidinfo * uifind | ( | uid_t | uid | ) |
Definition at line 1400 of file kern_resource.c.
References free(), malloc(), UIHASH, uihashtbl_lock, uihold(), and uilookup().
Referenced by do_execve(), proc0_init(), sys_seteuid(), sys_setresuid(), sys_setreuid(), and sys_setuid().
void uifree | ( | struct uidinfo * | uip | ) |
Definition at line 1471 of file kern_resource.c.
References free(), printf(), and uihashtbl_lock.
Referenced by change_euid(), change_ruid(), crfree_final(), do_execve(), sys_seteuid(), sys_setresuid(), sys_setreuid(), and sys_setuid().
void uihashinit | ( | ) |
Definition at line 1365 of file kern_resource.c.
References hashinit(), maxproc, and uihashtbl_lock.
Referenced by procinit().
void uihold | ( | struct uidinfo * | uip | ) |
Definition at line 1449 of file kern_resource.c.
Referenced by change_euid(), change_ruid(), crcopy(), uifind(), and uilookup().
|
static |
Definition at line 1378 of file kern_resource.c.
References UIHASH, uihashtbl_lock, and uihold().
Referenced by uifind().
|
static |
Definition at line 72 of file kern_resource.c.
Referenced by uifind(), uifree(), uihashinit(), and uilookup().
|
static |
Definition at line 285 of file kern_resource.c.
Referenced by sys_rtprio(), and sys_rtprio_thread().