FreeBSD kernel kern code
|
#include <sys/cdefs.h>
#include "opt_capsicum.h"
#include "opt_compat.h"
#include "opt_ktrace.h"
#include <sys/param.h>
#include <sys/fail.h>
#include <sys/systm.h>
#include <sys/capability.h>
#include <sys/kernel.h>
#include <sys/sysctl.h>
#include <sys/malloc.h>
#include <sys/priv.h>
#include <sys/proc.h>
#include <sys/jail.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/sbuf.h>
#include <sys/sx.h>
#include <sys/sysproto.h>
#include <sys/uio.h>
#include <net/vnet.h>
#include <security/mac/mac_framework.h>
#include <vm/vm.h>
#include <vm/vm_extern.h>
Go to the source code of this file.
Data Structures | |
struct | sysctl_args |
Macros | |
#define | SYSCTL_XLOCK() sx_xlock(&sysctllock) |
#define | SYSCTL_XUNLOCK() sx_xunlock(&sysctllock) |
#define | SYSCTL_ASSERT_XLOCKED() sx_assert(&sysctllock, SA_XLOCKED) |
#define | SYSCTL_INIT() sx_init(&sysctllock, "sysctl lock") |
#define | SYSCTL_SLEEP(ch, wmesg, timo) sx_sleep(ch, &sysctllock, 0, wmesg, timo) |
Functions | |
__FBSDID ("$BSDSUniX$") | |
static | MALLOC_DEFINE (M_SYSCTL,"sysctl","sysctl internal magic") |
static | MALLOC_DEFINE (M_SYSCTLOID,"sysctloid","sysctl dynamic oids") |
static | MALLOC_DEFINE (M_SYSCTLTMP,"sysctltmp","sysctl temp output buffer") |
static int | sysctl_root (SYSCTL_HANDLER_ARGS) |
static int | sysctl_remove_oid_locked (struct sysctl_oid *oidp, int del, int recurse) |
static struct sysctl_oid * | sysctl_find_oidname (const char *name, struct sysctl_oid_list *list) |
void | sysctl_lock (void) |
void | sysctl_unlock (void) |
void | sysctl_register_oid (struct sysctl_oid *oidp) |
void | sysctl_unregister_oid (struct sysctl_oid *oidp) |
int | sysctl_ctx_init (struct sysctl_ctx_list *c) |
int | sysctl_ctx_free (struct sysctl_ctx_list *clist) |
struct sysctl_ctx_entry * | sysctl_ctx_entry_add (struct sysctl_ctx_list *clist, struct sysctl_oid *oidp) |
struct sysctl_ctx_entry * | sysctl_ctx_entry_find (struct sysctl_ctx_list *clist, struct sysctl_oid *oidp) |
int | sysctl_ctx_entry_del (struct sysctl_ctx_list *clist, struct sysctl_oid *oidp) |
int | sysctl_remove_oid (struct sysctl_oid *oidp, int del, int recurse) |
int | sysctl_remove_name (struct sysctl_oid *parent, const char *name, int del, int recurse) |
struct sysctl_oid * | sysctl_add_oid (struct sysctl_ctx_list *clist, struct sysctl_oid_list *parent, int number, const char *name, int kind, void *arg1, intptr_t arg2, int(*handler)(SYSCTL_HANDLER_ARGS), const char *fmt, const char *descr) |
void | sysctl_rename_oid (struct sysctl_oid *oidp, const char *name) |
int | sysctl_move_oid (struct sysctl_oid *oid, struct sysctl_oid_list *parent) |
SET_DECLARE (sysctl_set, struct sysctl_oid) | |
static void | sysctl_register_all (void *arg) |
SYSINIT (sysctl, SI_SUB_KMEM, SI_ORDER_ANY, sysctl_register_all, 0) | |
static int | sysctl_sysctl_name (SYSCTL_HANDLER_ARGS) |
static | SYSCTL_NODE (_sysctl, 1, name, CTLFLAG_RD|CTLFLAG_CAPRD, sysctl_sysctl_name,"") |
static int | sysctl_sysctl_next_ls (struct sysctl_oid_list *lsp, int *name, u_int namelen, int *next, int *len, int level, struct sysctl_oid **oidpp) |
static int | sysctl_sysctl_next (SYSCTL_HANDLER_ARGS) |
static | SYSCTL_NODE (_sysctl, 2, next, CTLFLAG_RD|CTLFLAG_CAPRD, sysctl_sysctl_next,"") |
static int | name2oid (char *name, int *oid, int *len, struct sysctl_oid **oidpp) |
static int | sysctl_sysctl_name2oid (SYSCTL_HANDLER_ARGS) |
SYSCTL_PROC (_sysctl, 3, name2oid, CTLTYPE_INT|CTLFLAG_RW|CTLFLAG_ANYBODY|CTLFLAG_MPSAFE|CTLFLAG_CAPRW, 0, 0, sysctl_sysctl_name2oid,"I","") | |
static int | sysctl_sysctl_oidfmt (SYSCTL_HANDLER_ARGS) |
static | SYSCTL_NODE (_sysctl, 4, oidfmt, CTLFLAG_RD|CTLFLAG_MPSAFE|CTLFLAG_CAPRD, sysctl_sysctl_oidfmt,"") |
static int | sysctl_sysctl_oiddescr (SYSCTL_HANDLER_ARGS) |
static | SYSCTL_NODE (_sysctl, 5, oiddescr, CTLFLAG_RD|CTLFLAG_CAPRD, sysctl_sysctl_oiddescr,"") |
int | sysctl_handle_int (SYSCTL_HANDLER_ARGS) |
int | sysctl_msec_to_ticks (SYSCTL_HANDLER_ARGS) |
int | sysctl_handle_long (SYSCTL_HANDLER_ARGS) |
int | sysctl_handle_64 (SYSCTL_HANDLER_ARGS) |
int | sysctl_handle_string (SYSCTL_HANDLER_ARGS) |
int | sysctl_handle_opaque (SYSCTL_HANDLER_ARGS) |
static int | sysctl_old_kernel (struct sysctl_req *req, const void *p, size_t l) |
static int | sysctl_new_kernel (struct sysctl_req *req, void *p, size_t l) |
int | kernel_sysctl (struct thread *td, int *name, u_int namelen, void *old, size_t *oldlenp, void *new, size_t newlen, size_t *retval, int flags) |
int | kernel_sysctlbyname (struct thread *td, char *name, void *old, size_t *oldlenp, void *new, size_t newlen, size_t *retval, int flags) |
static int | sysctl_old_user (struct sysctl_req *req, const void *p, size_t l) |
static int | sysctl_new_user (struct sysctl_req *req, void *p, size_t l) |
int | sysctl_wire_old_buffer (struct sysctl_req *req, size_t len) |
int | sysctl_find_oid (int *name, u_int namelen, struct sysctl_oid **noid, int *nindx, struct sysctl_req *req) |
int | sys___sysctl (struct thread *td, struct sysctl_args *uap) |
int | userland_sysctl (struct thread *td, int *name, u_int namelen, void *old, size_t *oldlenp, int inkernel, void *new, size_t newlen, size_t *retval, int flags) |
static int | sbuf_sysctl_drain (void *arg, const char *data, int len) |
struct sbuf * | sbuf_new_for_sysctl (struct sbuf *s, char *buf, int length, struct sysctl_req *req) |
Variables | |
static struct sx | sysctllock |
static struct sx | sysctlmemlock |
struct sysctl_oid_list | sysctl__children |
#define SYSCTL_ASSERT_XLOCKED | ( | ) | sx_assert(&sysctllock, SA_XLOCKED) |
Definition at line 94 of file kern_sysctl.c.
Referenced by name2oid(), sysctl_ctx_entry_add(), sysctl_ctx_entry_find(), sysctl_find_oid(), sysctl_find_oidname(), sysctl_register_oid(), sysctl_remove_oid_locked(), sysctl_root(), sysctl_sysctl_next_ls(), and sysctl_unregister_oid().
#define SYSCTL_INIT | ( | ) | sx_init(&sysctllock, "sysctl lock") |
Definition at line 95 of file kern_sysctl.c.
Referenced by sysctl_register_all().
#define SYSCTL_SLEEP | ( | ch, | |
wmesg, | |||
timo | |||
) | sx_sleep(ch, &sysctllock, 0, wmesg, timo) |
Definition at line 96 of file kern_sysctl.c.
Referenced by sysctl_remove_oid_locked().
#define SYSCTL_XLOCK | ( | ) | sx_xlock(&sysctllock) |
Definition at line 92 of file kern_sysctl.c.
Referenced by kernel_sysctl(), sysctl_add_oid(), sysctl_ctx_entry_del(), sysctl_ctx_free(), sysctl_lock(), sysctl_move_oid(), sysctl_register_all(), sysctl_remove_name(), sysctl_remove_oid(), sysctl_rename_oid(), sysctl_root(), sysctl_sysctl_name(), sysctl_sysctl_name2oid(), sysctl_sysctl_next(), sysctl_sysctl_oiddescr(), sysctl_sysctl_oidfmt(), and userland_sysctl().
#define SYSCTL_XUNLOCK | ( | ) | sx_xunlock(&sysctllock) |
Definition at line 93 of file kern_sysctl.c.
Referenced by kernel_sysctl(), sysctl_add_oid(), sysctl_ctx_entry_del(), sysctl_ctx_free(), sysctl_move_oid(), sysctl_register_all(), sysctl_remove_name(), sysctl_remove_oid(), sysctl_rename_oid(), sysctl_root(), sysctl_sysctl_name(), sysctl_sysctl_name2oid(), sysctl_sysctl_next(), sysctl_sysctl_oiddescr(), sysctl_sysctl_oidfmt(), sysctl_unlock(), and userland_sysctl().
__FBSDID | ( | "$BSDSUniX$" | ) |
int kernel_sysctl | ( | struct thread * | td, |
int * | name, | ||
u_int | namelen, | ||
void * | old, | ||
size_t * | oldlenp, | ||
void * | new, | ||
size_t | newlen, | ||
size_t * | retval, | ||
int | flags | ||
) |
Definition at line 1232 of file kern_sysctl.c.
References sysctl_new_kernel(), sysctl_old_kernel(), sysctl_root(), SYSCTL_XLOCK, and SYSCTL_XUNLOCK.
Referenced by kernel_sysctlbyname().
int kernel_sysctlbyname | ( | struct thread * | td, |
char * | name, | ||
void * | old, | ||
size_t * | oldlenp, | ||
void * | new, | ||
size_t | newlen, | ||
size_t * | retval, | ||
int | flags | ||
) |
Definition at line 1281 of file kern_sysctl.c.
References kernel_sysctl().
|
static |
|
static |
|
static |
|
static |
Definition at line 841 of file kern_sysctl.c.
References sysctl__children, and SYSCTL_ASSERT_XLOCKED.
Referenced by sysctl_sysctl_name2oid().
struct sbuf* sbuf_new_for_sysctl | ( | struct sbuf * | s, |
char * | buf, | ||
int | length, | ||
struct sysctl_req * | req | ||
) |
Definition at line 1676 of file kern_sysctl.c.
References sbuf_new(), sbuf_set_drain(), and sbuf_sysctl_drain().
Referenced by kdb_sysctl_available(), sysctl_debug_witness_fullgraph(), sysctl_kern_malloc_stats(), sysctl_kern_proc_args(), sysctl_kern_proc_auxv(), sysctl_kern_proc_env(), sysctl_kern_proc_filedesc(), sysctl_kern_proc_vmmap(), and sysctl_out_proc().
|
static |
Definition at line 1665 of file kern_sysctl.c.
Referenced by sbuf_new_for_sysctl().
SET_DECLARE | ( | sysctl_set | , |
struct sysctl_oid | |||
) |
int sys___sysctl | ( | struct thread * | td, |
struct sysctl_args * | uap | ||
) |
Definition at line 1548 of file kern_sysctl.c.
References sysctl_args::name, sysctl_args::namelen, sysctl_args::new, sysctl_args::newlen, sysctl_args::old, sysctl_args::oldlenp, and userland_sysctl().
struct sysctl_oid* sysctl_add_oid | ( | struct sysctl_ctx_list * | clist, |
struct sysctl_oid_list * | parent, | ||
int | number, | ||
const char * | name, | ||
int | kind, | ||
void * | arg1, | ||
intptr_t | arg2, | ||
int(*)(SYSCTL_HANDLER_ARGS) | handler, | ||
const char * | fmt, | ||
const char * | descr | ||
) |
Definition at line 491 of file kern_sysctl.c.
References malloc(), parent, printf(), sysctl_ctx_entry_add(), sysctl_find_oidname(), sysctl_register_oid(), SYSCTL_XLOCK, and SYSCTL_XUNLOCK.
struct sysctl_ctx_entry* sysctl_ctx_entry_add | ( | struct sysctl_ctx_list * | clist, |
struct sysctl_oid * | oidp | ||
) |
Definition at line 330 of file kern_sysctl.c.
References malloc(), and SYSCTL_ASSERT_XLOCKED.
Referenced by sysctl_add_oid().
int sysctl_ctx_entry_del | ( | struct sysctl_ctx_list * | clist, |
struct sysctl_oid * | oidp | ||
) |
Definition at line 365 of file kern_sysctl.c.
References free(), sysctl_ctx_entry_find(), SYSCTL_XLOCK, and SYSCTL_XUNLOCK.
struct sysctl_ctx_entry* sysctl_ctx_entry_find | ( | struct sysctl_ctx_list * | clist, |
struct sysctl_oid * | oidp | ||
) |
Definition at line 345 of file kern_sysctl.c.
References SYSCTL_ASSERT_XLOCKED.
Referenced by sysctl_ctx_entry_del().
int sysctl_ctx_free | ( | struct sysctl_ctx_list * | clist | ) |
Definition at line 278 of file kern_sysctl.c.
References free(), panic(), sysctl_register_oid(), sysctl_remove_oid_locked(), SYSCTL_XLOCK, and SYSCTL_XUNLOCK.
Referenced by cpufreq_detach(), and device_sysctl_fini().
int sysctl_ctx_init | ( | struct sysctl_ctx_list * | c | ) |
Definition at line 260 of file kern_sysctl.c.
Referenced by cpufreq_attach(), devclass_sysctl_init(), and device_sysctl_init().
int sysctl_find_oid | ( | int * | name, |
u_int | namelen, | ||
struct sysctl_oid ** | noid, | ||
int * | nindx, | ||
struct sysctl_req * | req | ||
) |
Definition at line 1388 of file kern_sysctl.c.
References sysctl__children, and SYSCTL_ASSERT_XLOCKED.
Referenced by sysctl_root(), sysctl_sysctl_oiddescr(), and sysctl_sysctl_oidfmt().
|
static |
Definition at line 107 of file kern_sysctl.c.
References SYSCTL_ASSERT_XLOCKED.
Referenced by sysctl_add_oid(), sysctl_move_oid(), and sysctl_register_oid().
int sysctl_handle_64 | ( | SYSCTL_HANDLER_ARGS | ) |
Definition at line 1089 of file kern_sysctl.c.
Referenced by sysctl_kern_timecounter_freq().
int sysctl_handle_int | ( | SYSCTL_HANDLER_ARGS | ) |
Definition at line 986 of file kern_sysctl.c.
Referenced by cpufreq_curr_sysctl(), kdb_sysctl_enter(), kdb_sysctl_panic(), kdb_sysctl_trap(), kdb_sysctl_trap_code(), p31b_sysctl_proc(), poll_burst_max_sysctl(), poll_each_burst_sysctl(), reg_frac_sysctl(), sysctl_debug_ktr_clear(), sysctl_debug_num_cores_check(), sysctl_debug_witness_watch(), sysctl_devctl_disable(), sysctl_devctl_queue(), sysctl_fast_gettime(), sysctl_jail_default_allow(), sysctl_jail_default_level(), sysctl_kern_consmute(), sysctl_kern_eventtimer_periodic(), sysctl_kern_msgbuf_clear(), sysctl_kern_pid_max(), sysctl_kern_quantum(), sysctl_kern_randompid(), sysctl_kern_securelvl(), sysctl_kern_timecounter_get(), sysctl_machdep_adjkerntz(), sysctl_maxsockets(), sysctl_msec_to_ticks(), sysctl_nmbclusters(), sysctl_nmbjumbo16(), sysctl_nmbjumbo9(), sysctl_nmbjumbop(), sysctl_nmbufs(), sysctl_resettodr_period(), sysctl_somaxconn(), and user_frac_sysctl().
int sysctl_handle_long | ( | SYSCTL_HANDLER_ARGS | ) |
Definition at line 1043 of file kern_sysctl.c.
Referenced by sysctl_handle_sb_max(), sysctl_hostid(), sysctl_hw_physmem(), sysctl_hw_realmem(), sysctl_hw_usermem(), sysctl_kmem_map_free(), and sysctl_kmem_map_size().
int sysctl_handle_opaque | ( | SYSCTL_HANDLER_ARGS | ) |
Definition at line 1163 of file kern_sysctl.c.
Referenced by ntp_sysctl(), sysctl_intrcnt(), sysctl_intrnames(), sysctl_kern_clockrate(), and sysctl_kern_msgbuf().
int sysctl_handle_string | ( | SYSCTL_HANDLER_ARGS | ) |
Definition at line 1121 of file kern_sysctl.c.
References free(), and malloc().
Referenced by cpufreq_levels_sysctl(), cpufreq_settings_sysctl(), kdb_sysctl_current(), sysctl_debug_ktr_cpumask(), sysctl_hostname(), sysctl_jail_param(), sysctl_kern_console(), sysctl_kern_eventtimer_timer(), sysctl_kern_proc_sv_name(), and sysctl_kern_timecounter_hardware().
void sysctl_lock | ( | void | ) |
Definition at line 126 of file kern_sysctl.c.
References SYSCTL_XLOCK.
Referenced by linker_file_register_sysctls(), linker_file_unregister_sysctls(), and vfs_register().
int sysctl_move_oid | ( | struct sysctl_oid * | oid, |
struct sysctl_oid_list * | parent | ||
) |
Definition at line 568 of file kern_sysctl.c.
References parent, sysctl_find_oidname(), sysctl_register_oid(), sysctl_unregister_oid(), SYSCTL_XLOCK, and SYSCTL_XUNLOCK.
int sysctl_msec_to_ticks | ( | SYSCTL_HANDLER_ARGS | ) |
Definition at line 1015 of file kern_sysctl.c.
References hz, and sysctl_handle_int().
|
static |
Definition at line 1220 of file kern_sysctl.c.
Referenced by kernel_sysctl().
|
static |
Definition at line 1344 of file kern_sysctl.c.
Referenced by userland_sysctl().
|
static |
|
static |
|
static |
|
static |
|
static |
Definition at line 1199 of file kern_sysctl.c.
Referenced by kernel_sysctl().
|
static |
Definition at line 1306 of file kern_sysctl.c.
References copyout_nofault().
Referenced by sysctl_wire_old_buffer(), and userland_sysctl().
SYSCTL_PROC | ( | _sysctl | , |
3 | , | ||
name2oid | , | ||
CTLTYPE_INT|CTLFLAG_RW|CTLFLAG_ANYBODY|CTLFLAG_MPSAFE| | CTLFLAG_CAPRW, | ||
0 | , | ||
0 | , | ||
sysctl_sysctl_name2oid | , | ||
"I" | , | ||
"" | |||
) |
|
static |
Definition at line 596 of file kern_sysctl.c.
References SYSCTL_INIT, sysctl_register_oid(), SYSCTL_XLOCK, SYSCTL_XUNLOCK, and sysctlmemlock.
void sysctl_register_oid | ( | struct sysctl_oid * | oidp | ) |
Definition at line 140 of file kern_sysctl.c.
References panic(), parent, printf(), SYSCTL_ASSERT_XLOCKED, sysctl_find_oidname(), and timeout().
Referenced by linker_file_register_sysctls(), sysctl_add_oid(), sysctl_ctx_free(), sysctl_move_oid(), sysctl_register_all(), and vfs_register().
int sysctl_remove_name | ( | struct sysctl_oid * | parent, |
const char * | name, | ||
int | del, | ||
int | recurse | ||
) |
Definition at line 402 of file kern_sysctl.c.
References sysctl_remove_oid_locked(), SYSCTL_XLOCK, and SYSCTL_XUNLOCK.
int sysctl_remove_oid | ( | struct sysctl_oid * | oidp, |
int | del, | ||
int | recurse | ||
) |
Definition at line 391 of file kern_sysctl.c.
References sysctl_remove_oid_locked(), SYSCTL_XLOCK, and SYSCTL_XUNLOCK.
Referenced by et_deregister().
|
static |
Definition at line 423 of file kern_sysctl.c.
References free(), printf(), SYSCTL_ASSERT_XLOCKED, SYSCTL_SLEEP, and sysctl_unregister_oid().
Referenced by sysctl_ctx_free(), sysctl_remove_name(), and sysctl_remove_oid().
void sysctl_rename_oid | ( | struct sysctl_oid * | oidp, |
const char * | name | ||
) |
Definition at line 551 of file kern_sysctl.c.
References free(), SYSCTL_XLOCK, and SYSCTL_XUNLOCK.
Referenced by device_sysctl_update().
|
static |
Definition at line 1437 of file kern_sysctl.c.
References Giant, priv_check(), securelevel_gt(), SYSCTL_ASSERT_XLOCKED, sysctl_find_oid(), SYSCTL_XLOCK, SYSCTL_XUNLOCK, and wakeup().
Referenced by kernel_sysctl(), and userland_sysctl().
|
static |
Definition at line 691 of file kern_sysctl.c.
References buf, snprintf(), sysctl__children, SYSCTL_XLOCK, and SYSCTL_XUNLOCK.
|
static |
Definition at line 880 of file kern_sysctl.c.
References free(), malloc(), name2oid(), SYSCTL_XLOCK, and SYSCTL_XUNLOCK.
|
static |
Definition at line 815 of file kern_sysctl.c.
References sysctl__children, sysctl_sysctl_next_ls(), SYSCTL_XLOCK, and SYSCTL_XUNLOCK.
|
static |
Definition at line 755 of file kern_sysctl.c.
References level, and SYSCTL_ASSERT_XLOCKED.
Referenced by sysctl_sysctl_next().
|
static |
Definition at line 951 of file kern_sysctl.c.
References sysctl_find_oid(), SYSCTL_XLOCK, and SYSCTL_XUNLOCK.
|
static |
Definition at line 923 of file kern_sysctl.c.
References sysctl_find_oid(), SYSCTL_XLOCK, and SYSCTL_XUNLOCK.
void sysctl_unlock | ( | void | ) |
Definition at line 133 of file kern_sysctl.c.
References SYSCTL_XUNLOCK.
Referenced by linker_file_register_sysctls(), linker_file_unregister_sysctls(), and vfs_register().
void sysctl_unregister_oid | ( | struct sysctl_oid * | oidp | ) |
Definition at line 229 of file kern_sysctl.c.
References printf(), and SYSCTL_ASSERT_XLOCKED.
Referenced by linker_file_unregister_sysctls(), sysctl_move_oid(), sysctl_remove_oid_locked(), and vfs_register().
int sysctl_wire_old_buffer | ( | struct sysctl_req * | req, |
size_t | len | ||
) |
Definition at line 1364 of file kern_sysctl.c.
References sysctl_old_user().
Referenced by kdb_sysctl_enter(), kdb_sysctl_panic(), kdb_sysctl_trap(), kdb_sysctl_trap_code(), sysctl_debug_witness_fullgraph(), sysctl_kern_file(), sysctl_kern_function_list(), sysctl_kern_malloc_stats(), sysctl_kern_proc(), and sysctl_kern_randompid().
SYSINIT | ( | sysctl | , |
SI_SUB_KMEM | , | ||
SI_ORDER_ANY | , | ||
sysctl_register_all | , | ||
0 | |||
) |
int userland_sysctl | ( | struct thread * | td, |
int * | name, | ||
u_int | namelen, | ||
void * | old, | ||
size_t * | oldlenp, | ||
int | inkernel, | ||
void * | new, | ||
size_t | newlen, | ||
size_t * | retval, | ||
int | flags | ||
) |
Definition at line 1578 of file kern_sysctl.c.
References kern_yield(), sysctl_new_user(), sysctl_old_user(), sysctl_root(), SYSCTL_XLOCK, SYSCTL_XUNLOCK, and sysctlmemlock.
Referenced by sys___sysctl().
struct sysctl_oid_list sysctl__children |
Definition at line 101 of file kern_sysctl.c.
Referenced by name2oid(), sysctl_find_oid(), sysctl_sysctl_name(), and sysctl_sysctl_next().
|
static |
Definition at line 89 of file kern_sysctl.c.
|
static |
Definition at line 90 of file kern_sysctl.c.
Referenced by sysctl_register_all(), and userland_sysctl().