FreeBSD kernel kern code
|
#include <sys/cdefs.h>
#include "opt_compat.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/umtx.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]) |
Functions | |
__FBSDID ("$BSDSUniX$") | |
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 | sys_setpriority (struct thread *td, struct setpriority_args *uap) |
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") | |
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 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_locked (struct rusage_ext *rux, 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) |
void | lim_fork (struct proc *p1, struct proc *p2) |
void | lim_free (struct plimit *limp) |
void | lim_copy (struct plimit *dst, struct plimit *src) |
rlim_t | lim_max (struct proc *p, int which) |
rlim_t | lim_cur (struct proc *p, int which) |
void | lim_rlimit (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) |
void | ui_racct_foreach (void(*callback)(struct racct *racct, void *arg2, void *arg3), void *arg2, void *arg3) |
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) |
Variables | |
static struct rwlock | uihashtbl_lock |
static int | unprivileged_idprio |
#define UIHASH | ( | uid | ) | (&uihashtbl[(uid) & uihash]) |
Definition at line 72 of file kern_resource.c.
Referenced by uifind(), and uilookup().
__FBSDID | ( | "$BSDSUniX$" | ) |
void calccru | ( | struct proc * | p, |
struct timeval * | up, | ||
struct timeval * | sp | ||
) |
Definition at line 809 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 825 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 884 of file kern_resource.c.
References cputick2usec(), and printf().
Referenced by calccru(), calcru(), and rufetchtd().
int chgproccnt | ( | struct uidinfo * | uip, |
int | diff, | ||
rlim_t | max | ||
) |
Definition at line 1357 of file kern_resource.c.
References printf().
Referenced by change_ruid(), fork1(), proc0_init(), and proc_reap().
int chgptscnt | ( | struct uidinfo * | uip, |
int | diff, | ||
rlim_t | max | ||
) |
Definition at line 1409 of file kern_resource.c.
References printf().
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 1381 of file kern_resource.c.
References printf().
Referenced by sbrelease_internal(), sbreserve_locked(), sodealloc(), uipc_rcvd(), and uipc_send().
|
static |
Definition at line 260 of file kern_resource.c.
References p_cansched(), priv_check(), and sched_nice().
Referenced by sys_setpriority().
int kern_getrusage | ( | struct thread * | td, |
int | who, | ||
struct rusage * | rup | ||
) |
Definition at line 979 of file kern_resource.c.
References calccru(), rufetchcalc(), and rufetchtd().
Referenced by sys_getrusage().
int kern_proc_setrlimit | ( | struct thread * | td, |
struct proc * | p, | ||
u_int | which, | ||
struct rlimit * | limp | ||
) |
Definition at line 659 of file kern_resource.c.
References hz, lim_alloc(), lim_cb(), lim_copy(), lim_free(), maxdsiz, maxfilesperproc, maxprocperuid, maxssiz, and priv_check().
Referenced by kern_setrlimit(), and sysctl_kern_proc_rlimit().
int kern_setrlimit | ( | struct thread * | td, |
u_int | which, | ||
struct rlimit * | limp | ||
) |
Definition at line 652 of file kern_resource.c.
References kern_proc_setrlimit().
Referenced by sys_setrlimit().
struct plimit* lim_alloc | ( | ) |
Definition at line 1112 of file kern_resource.c.
References malloc().
Referenced by kern_proc_setrlimit(), proc0_init(), and sys_acct().
|
static |
Definition at line 618 of file kern_resource.c.
References cpu_tickrate(), hz, kern_psignal(), killproc(), lim_rlimit(), and ruxagg().
Referenced by kern_proc_setrlimit(), and lim_fork().
void lim_copy | ( | struct plimit * | dst, |
struct plimit * | src | ||
) |
Definition at line 1154 of file kern_resource.c.
Referenced by kern_proc_setrlimit().
rlim_t lim_cur | ( | struct proc * | p, |
int | which | ||
) |
Definition at line 1180 of file kern_resource.c.
References lim_rlimit().
Referenced by coredump(), do_aout_hdr(), exec_aout_imgact(), fork1(), getmaxfd(), pts_alloc(), pts_alloc_external(), sbreserve_locked(), sys_getdtablesize(), and vn_rlimit_fsize().
void lim_fork | ( | struct proc * | p1, |
struct proc * | p2 | ||
) |
Definition at line 1131 of file kern_resource.c.
References hz, lim_cb(), and lim_hold().
Referenced by do_fork().
void lim_free | ( | struct plimit * | limp | ) |
Definition at line 1140 of file kern_resource.c.
References free().
Referenced by acct_disable(), acct_process(), exit1(), and kern_proc_setrlimit().
struct plimit* lim_hold | ( | struct plimit * | limp | ) |
Definition at line 1122 of file kern_resource.c.
Referenced by acct_process(), and lim_fork().
rlim_t lim_max | ( | struct proc * | p, |
int | which | ||
) |
Definition at line 1167 of file kern_resource.c.
References lim_rlimit().
Referenced by copyout_map(), and kern_shmat().
void lim_rlimit | ( | struct proc * | p, |
int | which, | ||
struct rlimit * | rlp | ||
) |
Definition at line 1193 of file kern_resource.c.
Referenced by lim_cb(), lim_cur(), lim_max(), note_procstat_rlimit(), sys_getrlimit(), and sysctl_kern_proc_rlimit().
|
static |
Definition at line 74 of file kern_resource.c.
|
static |
|
static |
void pri_to_rtp | ( | struct thread * | td, |
struct rtprio * | rtp | ||
) |
Definition at line 513 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 470 of file kern_resource.c.
References critical_enter(), critical_exit(), sched_class(), sched_prio(), sched_user_prio(), and umtx_pi_adjust().
Referenced by create_thread(), ksched_setscheduler(), poll_idle(), sys_rtprio(), and sys_rtprio_thread().
void ruadd | ( | struct rusage * | ru, |
struct rusage_ext * | rux, | ||
struct rusage * | ru2, | ||
struct rusage_ext * | rux2 | ||
) |
Definition at line 1028 of file kern_resource.c.
References rucollect().
Referenced by exit1(), and proc_reap().
void rucollect | ( | struct rusage * | ru, |
struct rusage * | ru2 | ||
) |
Definition at line 1014 of file kern_resource.c.
Referenced by ruadd(), rufetch(), and thread_exit().
void rufetch | ( | struct proc * | p, |
struct rusage * | ru | ||
) |
Definition at line 1076 of file kern_resource.c.
References rucollect(), and ruxagg().
Referenced by fill_kinfo_proc_only(), get_process_cputime(), proc0_post(), and rufetchcalc().
void rufetchcalc | ( | struct proc * | p, |
struct rusage * | ru, | ||
struct timeval * | up, | ||
struct timeval * | sp | ||
) |
Definition at line 1097 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 857 of file kern_resource.c.
References calcru1(), cpu_ticks, and ruxagg().
Referenced by fill_kinfo_thread(), and kern_getrusage().
void ruxagg | ( | struct proc * | p, |
struct thread * | td | ||
) |
Definition at line 1058 of file kern_resource.c.
References ruxagg_locked().
Referenced by calcru(), lim_cb(), rufetch(), rufetchtd(), and thread_exit().
|
static |
Definition at line 1046 of file kern_resource.c.
Referenced by ruxagg().
int sys_getpriority | ( | struct thread * | td, |
struct getpriority_args * | uap | ||
) |
Definition at line 93 of file kern_resource.c.
References allproc_lock, p_cansee(), pfind(), pgfind(), and proctree_lock.
int sys_getrlimit | ( | struct thread * | td, |
struct __getrlimit_args * | uap | ||
) |
Definition at line 786 of file kern_resource.c.
References lim_rlimit().
int sys_getrusage | ( | struct thread * | td, |
struct getrusage_args * | uap | ||
) |
Definition at line 965 of file kern_resource.c.
References kern_getrusage().
int sys_rtprio | ( | struct thread * | td, |
struct rtprio_args * | uap | ||
) |
Definition at line 374 of file kern_resource.c.
References p_cansched(), p_cansee(), pfind(), pri_to_rtp(), priv_check(), rtp_to_pri(), and unprivileged_idprio.
int sys_rtprio_thread | ( | struct thread * | td, |
struct rtprio_thread_args * | uap | ||
) |
Definition at line 292 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 178 of file kern_resource.c.
References allproc_lock, donice(), p_cansee(), pfind(), pgfind(), setpriority_args::prio, proctree_lock, setpriority_args::which, and setpriority_args::who.
int sys_setrlimit | ( | struct thread * | td, |
struct __setrlimit_args * | uap | ||
) |
Definition at line 604 of file kern_resource.c.
References kern_setrlimit().
SYSCTL_INT | ( | _security_bsd | , |
OID_AUTO | , | ||
unprivileged_idprio | , | ||
CTLFLAG_RW | , | ||
& | unprivileged_idprio, | ||
0 | , | ||
"Allow non-root users to set an idle priority" | |||
) |
void ui_racct_foreach | ( | void(*)(struct racct *racct, void *arg2, void *arg3) | callback, |
void * | arg2, | ||
void * | arg3 | ||
) |
Definition at line 1337 of file kern_resource.c.
References callback, and uihashtbl_lock.
struct uidinfo* uifind | ( | uid_t | uid | ) |
Definition at line 1238 of file kern_resource.c.
References free(), malloc(), mtx_init(), racct_create(), racct_destroy(), 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 1300 of file kern_resource.c.
References free(), mtx_destroy(), printf(), racct_destroy(), and uihashtbl_lock.
Referenced by change_euid(), change_ruid(), crfree(), do_execve(), sys_seteuid(), sys_setresuid(), sys_setreuid(), and sys_setuid().
void uihashinit | ( | ) |
Definition at line 1205 of file kern_resource.c.
References hashinit(), maxproc, and uihashtbl_lock.
Referenced by procinit().
void uihold | ( | struct uidinfo * | uip | ) |
Definition at line 1277 of file kern_resource.c.
Referenced by change_euid(), change_ruid(), crcopy(), and uifind().
|
static |
Definition at line 1217 of file kern_resource.c.
References UIHASH, and uihashtbl_lock.
Referenced by uifind().
|
static |
Definition at line 73 of file kern_resource.c.
Referenced by ui_racct_foreach(), uifind(), uifree(), uihashinit(), and uilookup().
|
static |
Definition at line 277 of file kern_resource.c.
Referenced by sys_rtprio(), and sys_rtprio_thread().