38 #include <sys/cdefs.h>
41 #include "opt_capsicum.h"
42 #include "opt_compat.h"
43 #include "opt_ktrace.h"
45 #include <sys/param.h>
47 #include <sys/systm.h>
48 #include <sys/capability.h>
49 #include <sys/kernel.h>
50 #include <sys/sysctl.h>
51 #include <sys/malloc.h>
56 #include <sys/mutex.h>
59 #include <sys/sysproto.h>
62 #include <sys/ktrace.h>
67 #include <security/mac/mac_framework.h>
70 #include <vm/vm_extern.h>
72 static MALLOC_DEFINE(M_SYSCTL,
"sysctl",
"sysctl internal magic");
73 static MALLOC_DEFINE(M_SYSCTLOID,
"sysctloid",
"sysctl dynamic oids");
74 static MALLOC_DEFINE(M_SYSCTLTMP,
"sysctltmp",
"sysctl temp output buffer");
92 #define SYSCTL_XLOCK() sx_xlock(&sysctllock)
93 #define SYSCTL_XUNLOCK() sx_xunlock(&sysctllock)
94 #define SYSCTL_ASSERT_XLOCKED() sx_assert(&sysctllock, SA_XLOCKED)
95 #define SYSCTL_INIT() sx_init(&sysctllock, "sysctl lock")
96 #define SYSCTL_SLEEP(ch, wmesg, timo) \
97 sx_sleep(ch, &sysctllock, 0, wmesg, timo)
106 static struct sysctl_oid *
109 struct sysctl_oid *oidp;
112 SLIST_FOREACH(oidp, list, oid_link) {
113 if (strcmp(oidp->oid_name, name) == 0) {
142 struct sysctl_oid_list *
parent = oidp->oid_parent;
143 struct sysctl_oid *p;
144 struct sysctl_oid *q;
155 if ((p->oid_kind & CTLTYPE) == CTLTYPE_NODE) {
159 printf(
"can't re-use a leaf (%s)!\n", p->oid_name);
164 oid_number = oidp->oid_number;
167 #error "OID_AUTO is expected to be a negative value"
177 if (oid_number < 0) {
184 if (--newoid < CTL_AUTO_START)
195 SLIST_FOREACH(p, parent, oid_link) {
197 if (oid_number == p->oid_number) {
199 if (oid_number < CTL_AUTO_START ||
200 oid_number == 0x7fffffff) {
202 oid_number = CTL_AUTO_START;
205 panic(
"sysctl: Out of OID numbers\n");
210 }
else if (oid_number < p->oid_number)
215 if (oidp->oid_number >= 0 && oidp->oid_number < CTL_AUTO_START &&
216 oid_number >= CTL_AUTO_START) {
217 printf(
"sysctl: OID number(%d) is already in use for '%s'\n",
218 oidp->oid_number, oidp->oid_name);
221 oidp->oid_number = oid_number;
223 SLIST_INSERT_AFTER(q, oidp, oid_link);
225 SLIST_INSERT_HEAD(parent, oidp, oid_link);
231 struct sysctl_oid *p;
236 if (oidp->oid_number == OID_AUTO) {
239 SLIST_FOREACH(p, oidp->oid_parent, oid_link) {
241 SLIST_REMOVE(oidp->oid_parent, oidp,
242 sysctl_oid, oid_link);
255 printf(
"%s: failed to unregister sysctl\n", __func__);
280 struct sysctl_ctx_entry *e, *e1;
291 TAILQ_FOREACH(e, clist, link) {
302 e1 = TAILQ_PREV(e, sysctl_ctx_list, link);
304 e1 = TAILQ_LAST(clist, sysctl_ctx_list);
307 e1 = TAILQ_PREV(e1, sysctl_ctx_list, link);
314 e = TAILQ_FIRST(clist);
316 e1 = TAILQ_NEXT(e, link);
319 panic(
"sysctl_remove_oid: corrupt tree, entry: %s",
321 free(e, M_SYSCTLOID);
329 struct sysctl_ctx_entry *
332 struct sysctl_ctx_entry *e;
335 if (clist == NULL || oidp == NULL)
337 e =
malloc(
sizeof(
struct sysctl_ctx_entry), M_SYSCTLOID, M_WAITOK);
339 TAILQ_INSERT_HEAD(clist, e, link);
344 struct sysctl_ctx_entry *
347 struct sysctl_ctx_entry *e;
350 if (clist == NULL || oidp == NULL)
352 TAILQ_FOREACH(e, clist, link) {
367 struct sysctl_ctx_entry *e;
369 if (clist == NULL || oidp == NULL)
374 TAILQ_REMOVE(clist, e, link);
376 free(e, M_SYSCTLOID);
403 int del,
int recurse)
405 struct sysctl_oid *p, *tmp;
410 SLIST_FOREACH_SAFE(p, SYSCTL_CHILDREN(parent), oid_link, tmp) {
411 if (strcmp(p->oid_name, name) == 0) {
425 struct sysctl_oid *p, *tmp;
431 if ((oidp->oid_kind & CTLFLAG_DYN) == 0) {
432 printf(
"can't remove non-dynamic nodes!\n");
442 if ((oidp->oid_kind & CTLTYPE) == CTLTYPE_NODE) {
443 if (oidp->oid_refcnt == 1) {
444 SLIST_FOREACH_SAFE(p,
445 SYSCTL_CHILDREN(oidp), oid_link, tmp) {
454 free(SYSCTL_CHILDREN(oidp), M_SYSCTLOID);
457 if (oidp->oid_refcnt > 1 ) {
460 if (oidp->oid_refcnt == 0) {
461 printf(
"Warning: bad oid_refcnt=%u (%s)!\n",
462 oidp->oid_refcnt, oidp->oid_name);
473 while (oidp->oid_running > 0) {
474 oidp->oid_kind |= CTLFLAG_DYING;
478 free(__DECONST(
char *, oidp->oid_descr),
480 free(__DECONST(
char *, oidp->oid_name), M_SYSCTLOID);
481 free(oidp, M_SYSCTLOID);
492 int number,
const char *
name,
int kind,
void *arg1, intptr_t arg2,
493 int (*handler)(SYSCTL_HANDLER_ARGS),
const char *fmt,
const char *descr)
495 struct sysctl_oid *oidp;
504 if ((oidp->oid_kind & CTLTYPE) == CTLTYPE_NODE) {
513 printf(
"can't re-use a leaf (%s)!\n", name);
517 oidp =
malloc(
sizeof(
struct sysctl_oid), M_SYSCTLOID, M_WAITOK|M_ZERO);
518 oidp->oid_parent =
parent;
519 SLIST_NEXT(oidp, oid_link) = NULL;
520 oidp->oid_number = number;
521 oidp->oid_refcnt = 1;
522 oidp->oid_name = strdup(name, M_SYSCTLOID);
523 oidp->oid_handler = handler;
524 oidp->oid_kind = CTLFLAG_DYN | kind;
525 if ((kind & CTLTYPE) == CTLTYPE_NODE) {
527 SYSCTL_CHILDREN_SET(oidp,
malloc(
sizeof(
struct sysctl_oid_list),
528 M_SYSCTLOID, M_WAITOK));
529 SLIST_INIT(SYSCTL_CHILDREN(oidp));
530 oidp->oid_arg2 = arg2;
532 oidp->oid_arg1 = arg1;
533 oidp->oid_arg2 = arg2;
537 oidp->oid_descr = strdup(descr, M_SYSCTLOID);
556 newname = strdup(name, M_SYSCTLOID);
558 oldname = __DECONST(
char *, oidp->oid_name);
559 oidp->oid_name = newname;
561 free(oldname, M_SYSCTLOID);
570 struct sysctl_oid *oidp;
573 if (oid->oid_parent == parent) {
584 oid->oid_number = OID_AUTO;
598 struct sysctl_oid **oidp;
603 SET_FOREACH(oidp, sysctl_set)
630 sysctl_sysctl_debug_dump_node(
struct sysctl_oid_list *l,
int i)
633 struct sysctl_oid *oidp;
636 SLIST_FOREACH(oidp, l, oid_link) {
641 printf(
"%d %s ", oidp->oid_number, oidp->oid_name);
644 oidp->oid_kind & CTLFLAG_RD ?
'R':
' ',
645 oidp->oid_kind & CTLFLAG_WR ?
'W':
' ');
647 if (oidp->oid_handler)
650 switch (oidp->oid_kind & CTLTYPE) {
653 if (!oidp->oid_handler) {
654 sysctl_sysctl_debug_dump_node(
655 oidp->oid_arg1, i+2);
658 case CTLTYPE_INT:
printf(
" Int\n");
break;
659 case CTLTYPE_UINT:
printf(
" u_int\n");
break;
660 case CTLTYPE_LONG:
printf(
" Long\n");
break;
661 case CTLTYPE_ULONG:
printf(
" u_long\n");
break;
662 case CTLTYPE_STRING:
printf(
" String\n");
break;
663 case CTLTYPE_U64:
printf(
" uint64_t\n");
break;
664 case CTLTYPE_S64:
printf(
" int64_t\n");
break;
665 case CTLTYPE_OPAQUE:
printf(
" Opaque/struct\n");
break;
673 sysctl_sysctl_debug(SYSCTL_HANDLER_ARGS)
677 error =
priv_check(req->td, PRIV_SYSCTL_DEBUG);
686 SYSCTL_PROC(_sysctl, 0, debug, CTLTYPE_STRING|CTLFLAG_RD,
687 0, 0, sysctl_sysctl_debug,
"-",
"");
693 int *name = (
int *) arg1;
694 u_int namelen = arg2;
696 struct sysctl_oid *oid;
703 snprintf(buf,
sizeof(buf),
"%d",*name);
705 error = SYSCTL_OUT(req,
".", 1);
707 error = SYSCTL_OUT(req, buf, strlen(buf));
715 SLIST_FOREACH(oid, lsp, oid_link) {
716 if (oid->oid_number != *name)
720 error = SYSCTL_OUT(req,
".", 1);
722 error = SYSCTL_OUT(req, oid->oid_name,
723 strlen(oid->oid_name));
730 if ((oid->oid_kind & CTLTYPE) != CTLTYPE_NODE)
733 if (oid->oid_handler)
736 lsp2 = SYSCTL_CHILDREN(oid);
741 error = SYSCTL_OUT(req,
"", 1);
751 static SYSCTL_NODE(_sysctl, 1, name, CTLFLAG_RD | CTLFLAG_CAPRD,
756 int *next,
int *len,
int level,
struct sysctl_oid **oidpp)
758 struct sysctl_oid *oidp;
762 SLIST_FOREACH(oidp, lsp, oid_link) {
763 *next = oidp->oid_number;
766 if (oidp->oid_kind & CTLFLAG_SKIP)
770 if ((oidp->oid_kind & CTLTYPE) != CTLTYPE_NODE)
772 if (oidp->oid_handler)
775 lsp = SYSCTL_CHILDREN(oidp);
777 len, level+1, oidpp))
782 if (oidp->oid_number < *name)
785 if (oidp->oid_number > *name) {
786 if ((oidp->oid_kind & CTLTYPE) != CTLTYPE_NODE)
788 if (oidp->oid_handler)
790 lsp = SYSCTL_CHILDREN(oidp);
792 next+1, len, level+1, oidpp))
796 if ((oidp->oid_kind & CTLTYPE) != CTLTYPE_NODE)
799 if (oidp->oid_handler)
802 lsp = SYSCTL_CHILDREN(oidp);
804 len, level+1, oidpp))
817 int *name = (
int *) arg1;
818 u_int namelen = arg2;
820 struct sysctl_oid *oid;
822 int newoid[CTL_MAXNAME];
829 error = SYSCTL_OUT(req, newoid, j *
sizeof (
int));
837 static SYSCTL_NODE(_sysctl, 2, next, CTLFLAG_RD | CTLFLAG_CAPRD,
841 name2oid(
char *name,
int *oid,
int *len,
struct sysctl_oid **oidpp)
843 struct sysctl_oid *oidp;
849 for (*len = 0; *len < CTL_MAXNAME;) {
850 p = strsep(&name,
".");
852 oidp = SLIST_FIRST(lsp);
853 for (;; oidp = SLIST_NEXT(oidp, oid_link)) {
856 if (strcmp(p, oidp->oid_name) == 0)
859 *oid++ = oidp->oid_number;
862 if (name == NULL || *name ==
'\0') {
868 if ((oidp->oid_kind & CTLTYPE) != CTLTYPE_NODE)
871 if (oidp->oid_handler)
874 lsp = SYSCTL_CHILDREN(oidp);
883 int error, oid[CTL_MAXNAME], len = 0;
884 struct sysctl_oid *op = 0;
888 if (req->newlen >= MAXPATHLEN)
889 return (ENAMETOOLONG);
891 p =
malloc(req->newlen+1, M_SYSCTL, M_WAITOK);
893 error = SYSCTL_IN(req, p, req->newlen);
899 p [req->newlen] =
'\0';
902 error =
name2oid(p, oid, &len, &op);
910 error = SYSCTL_OUT(req, oid, len *
sizeof *oid);
919 CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_ANYBODY | CTLFLAG_MPSAFE
925 struct sysctl_oid *oid;
933 if (oid->oid_fmt == NULL) {
937 error = SYSCTL_OUT(req, &oid->oid_kind,
sizeof(oid->oid_kind));
940 error = SYSCTL_OUT(req, oid->oid_fmt, strlen(oid->oid_fmt) + 1);
947 static SYSCTL_NODE(_sysctl, 4, oidfmt, CTLFLAG_RD|CTLFLAG_MPSAFE|CTLFLAG_CAPRD,
953 struct sysctl_oid *oid;
961 if (oid->oid_descr == NULL) {
965 error = SYSCTL_OUT(req, oid->oid_descr, strlen(oid->oid_descr) + 1);
971 static SYSCTL_NODE(_sysctl, 5, oiddescr, CTLFLAG_RD|CTLFLAG_CAPRD,
988 int tmpout, error = 0;
994 tmpout = *(
int *)arg1;
997 error = SYSCTL_OUT(req, &tmpout,
sizeof(
int));
999 if (error || !req->newptr)
1005 error = SYSCTL_IN(req, arg1,
sizeof(
int));
1020 s = (int)((int64_t)tt * 1000 /
hz);
1023 if (error || !req->newptr)
1026 tt = (int)((int64_t)s *
hz / 1000);
1055 tmplong = *(
long *)arg1;
1059 if (req->flags & SCTL_MASK32) {
1061 error = SYSCTL_OUT(req, &tmpint,
sizeof(
int));
1064 error = SYSCTL_OUT(req, &tmplong,
sizeof(
long));
1066 if (error || !req->newptr)
1072 else if (req->flags & SCTL_MASK32) {
1073 error = SYSCTL_IN(req, &tmpint,
sizeof(
int));
1074 *(
long *)arg1 = (
long)tmpint;
1078 error = SYSCTL_IN(req, arg1,
sizeof(
long));
1098 tmpout = *(uint64_t *)arg1;
1101 error = SYSCTL_OUT(req, &tmpout,
sizeof(uint64_t));
1103 if (error || !req->newptr)
1109 error = SYSCTL_IN(req, arg1,
sizeof(uint64_t));
1132 outlen = strlen((
char *)arg1)+1;
1133 tmparg =
malloc(outlen, M_SYSCTLTMP, M_WAITOK);
1135 if (strlcpy(tmparg, (
char *)arg1, outlen) >= outlen) {
1136 free(tmparg, M_SYSCTLTMP);
1140 error = SYSCTL_OUT(req, tmparg, outlen);
1141 free(tmparg, M_SYSCTLTMP);
1143 if (error || !req->newptr)
1146 if ((req->newlen - req->newidx) >= arg2) {
1149 arg2 = (req->newlen - req->newidx);
1150 error = SYSCTL_IN(req, arg1, arg2);
1151 ((
char *)arg1)[arg2] =
'\0';
1167 struct sysctl_req req2;
1179 generation = curthread->td_generation;
1180 error = SYSCTL_OUT(req, arg1, arg2);
1184 if (generation != curthread->td_generation && tries < 3) {
1189 error = SYSCTL_IN(req, arg1, arg2);
1205 if (req->oldlen <= req->oldidx)
1208 if (i > req->oldlen - req->oldidx)
1209 i = req->oldlen - req->oldidx;
1211 bcopy(p, (
char *)req->oldptr + req->oldidx, i);
1214 if (req->oldptr && i != l)
1224 if (req->newlen - req->newidx < l)
1226 bcopy((
char *)req->newptr + req->newidx, p, l);
1233 size_t *oldlenp,
void *
new,
size_t newlen,
size_t *retval,
int flags)
1236 struct sysctl_req req;
1238 bzero(&req,
sizeof req);
1244 req.oldlen = *oldlenp;
1246 req.validlen = req.oldlen;
1253 req.newlen = newlen;
1259 req.lock = REQ_UNWIRED;
1265 if (req.lock == REQ_WIRED && req.validlen > 0)
1266 vsunlock(req.oldptr, req.validlen);
1268 if (error && error != ENOMEM)
1272 if (req.oldptr && req.oldidx > req.validlen)
1273 *retval = req.validlen;
1275 *retval = req.oldidx;
1282 void *
new,
size_t newlen,
size_t *retval,
int flags)
1284 int oid[CTL_MAXNAME];
1285 size_t oidlen, plen;
1290 oidlen =
sizeof(oid);
1293 (
void *)name, strlen(name), &plen, flags);
1297 error =
kernel_sysctl(td, oid, plen /
sizeof(
int), old, oldlenp,
1298 new, newlen, retval, flags);
1308 size_t i, len, origidx;
1311 origidx = req->oldidx;
1313 if (req->oldptr == NULL)
1320 if (req->lock != REQ_WIRED)
1321 WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL,
1322 "sysctl_old_user()");
1324 len = req->validlen;
1328 if (i > len - origidx)
1330 if (req->lock == REQ_WIRED) {
1334 error = copyout(p, (
char *)req->oldptr + origidx, i);
1350 if (req->newlen - req->newidx < l)
1352 WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL,
1353 "sysctl_new_user()");
1354 error = copyin((
char *)req->newptr + req->newidx, p, l);
1369 wiredlen = (len > 0 && len < req->oldlen) ? len : req->oldlen;
1371 if (req->lock != REQ_WIRED && req->oldptr &&
1373 if (wiredlen != 0) {
1374 ret = vslock(req->oldptr, wiredlen);
1381 req->lock = REQ_WIRED;
1382 req->validlen = wiredlen;
1389 int *nindx,
struct sysctl_req *req)
1391 struct sysctl_oid_list *lsp;
1392 struct sysctl_oid *oid;
1398 while (indx < CTL_MAXNAME) {
1399 SLIST_FOREACH(oid, lsp, oid_link) {
1400 if (oid->oid_number == name[indx])
1407 if ((oid->oid_kind & CTLTYPE) == CTLTYPE_NODE) {
1408 if (oid->oid_handler != NULL || indx == namelen) {
1412 KASSERT((oid->oid_kind & CTLFLAG_DYING) == 0,
1413 (
"%s found DYING node %p", __func__, oid));
1416 lsp = SYSCTL_CHILDREN(oid);
1417 }
else if (indx == namelen) {
1421 KASSERT((oid->oid_kind & CTLFLAG_DYING) == 0,
1422 (
"%s found DYING node %p", __func__, oid));
1439 struct sysctl_oid *oid;
1440 int error, indx, lvl;
1448 if ((oid->oid_kind & CTLTYPE) == CTLTYPE_NODE) {
1454 if (oid->oid_handler == NULL)
1459 if (req->newptr && !(oid->oid_kind & CTLFLAG_WR))
1462 KASSERT(req->td != NULL, (
"sysctl_root(): req->td == NULL"));
1464 #ifdef CAPABILITY_MODE
1469 if (IN_CAPABILITY_MODE(req->td)) {
1470 if (req->oldptr && !(oid->oid_kind & CTLFLAG_CAPRD))
1472 if (req->newptr && !(oid->oid_kind & CTLFLAG_CAPWR))
1478 if (req->newptr && (oid->oid_kind & CTLFLAG_SECURE)) {
1479 lvl = (oid->oid_kind & CTLMASK_SECURE) >> CTLSHIFT_SECURE;
1486 if (req->newptr && !(oid->oid_kind & CTLFLAG_ANYBODY)) {
1489 if (oid->oid_kind & CTLFLAG_PRISON)
1490 priv = PRIV_SYSCTL_WRITEJAIL;
1492 else if ((oid->oid_kind & CTLFLAG_VNET) &&
1493 prison_owns_vnet(req->td->td_ucred))
1494 priv = PRIV_SYSCTL_WRITEJAIL;
1497 priv = PRIV_SYSCTL_WRITE;
1503 if (!oid->oid_handler)
1506 if ((oid->oid_kind & CTLTYPE) == CTLTYPE_NODE) {
1507 arg1 = (
int *)arg1 + indx;
1510 arg1 = oid->oid_arg1;
1511 arg2 = oid->oid_arg2;
1514 error = mac_system_check_sysctl(req->td->td_ucred, oid, arg1, arg2,
1522 if (!(oid->oid_kind & CTLFLAG_MPSAFE))
1524 error = oid->oid_handler(oid, arg1, arg2, req);
1525 if (!(oid->oid_kind & CTLFLAG_MPSAFE))
1528 KFAIL_POINT_ERROR(_debug_fail_point, sysctl_running, error);
1532 if (oid->oid_running == 0 && (oid->oid_kind & CTLFLAG_DYING) != 0)
1533 wakeup(&oid->oid_running);
1537 #ifndef _SYS_SYSPROTO_H_
1550 int error, i, name[CTL_MAXNAME];
1556 error = copyin(uap->
name, &name, uap->
namelen *
sizeof(
int));
1563 if (error && error != ENOMEM)
1566 i = copyout(&j, uap->
oldlenp,
sizeof(j));
1579 size_t *oldlenp,
int inkernel,
void *
new,
size_t newlen,
size_t *retval,
1582 int error = 0, memlocked;
1583 struct sysctl_req req;
1585 bzero(&req,
sizeof req);
1592 req.oldlen = *oldlenp;
1594 error = copyin(oldlenp, &req.oldlen,
sizeof(*oldlenp));
1599 req.validlen = req.oldlen;
1602 if (!useracc(old, req.oldlen, VM_PROT_WRITE))
1608 if (!useracc(
new, newlen, VM_PROT_READ))
1610 req.newlen = newlen;
1616 req.lock = REQ_UNWIRED;
1619 if (KTRPOINT(curthread, KTR_SYSCTL))
1620 ktrsysctl(name, namelen);
1623 if (req.oldlen > PAGE_SIZE) {
1628 CURVNET_SET(TD_TO_VNET(td));
1636 if (error != EAGAIN)
1643 if (req.lock == REQ_WIRED && req.validlen > 0)
1644 vsunlock(req.oldptr, req.validlen);
1648 if (error && error != ENOMEM)
1652 if (req.oldptr && req.oldidx > req.validlen)
1653 *retval = req.validlen;
1655 *retval = req.oldidx;
1667 struct sysctl_req *req = arg;
1670 error = SYSCTL_OUT(req, data, len);
1671 KASSERT(error >= 0, (
"Got unexpected negative value %d", error));
1672 return (error == 0 ? len : -error);
1677 struct sysctl_req *req)
1680 s =
sbuf_new(s, buf, length, SBUF_FIXEDLEN);
#define SYSCTL_ASSERT_XLOCKED()
SET_DECLARE(sysctl_set, struct sysctl_oid)
struct callout_handle timeout(timeout_t *ftn, void *arg, int to_ticks)
static int sysctl_sysctl_next(SYSCTL_HANDLER_ARGS)
static int sysctl_sysctl_name2oid(SYSCTL_HANDLER_ARGS)
static struct sx sysctllock
int snprintf(char *str, size_t size, const char *format,...)
static int sysctl_old_user(struct sysctl_req *req, const void *p, size_t l)
static int sbuf_sysctl_drain(void *arg, const char *data, int len)
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)
void * malloc(unsigned long size, struct malloc_type *mtp, int flags)
static int sysctl_sysctl_name(SYSCTL_HANDLER_ARGS)
int sysctl_ctx_entry_del(struct sysctl_ctx_list *clist, struct sysctl_oid *oidp)
void sysctl_register_oid(struct sysctl_oid *oidp)
void panic(const char *fmt,...)
static int sysctl_remove_oid_locked(struct sysctl_oid *oidp, 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)
int kernel_sysctlbyname(struct thread *td, char *name, void *old, size_t *oldlenp, void *new, size_t newlen, size_t *retval, int flags)
int sys___sysctl(struct thread *td, struct sysctl_args *uap)
int sysctl_remove_name(struct sysctl_oid *parent, const char *name, int del, int recurse)
int sysctl_handle_string(SYSCTL_HANDLER_ARGS)
static int sysctl_old_kernel(struct sysctl_req *req, const void *p, size_t l)
static int sysctl_sysctl_oiddescr(SYSCTL_HANDLER_ARGS)
int priv_check(struct thread *td, int priv)
void sysctl_rename_oid(struct sysctl_oid *oidp, const char *name)
struct sysctl_ctx_entry * sysctl_ctx_entry_add(struct sysctl_ctx_list *clist, struct sysctl_oid *oidp)
int sysctl_msec_to_ticks(SYSCTL_HANDLER_ARGS)
#define SYSCTL_SLEEP(ch, wmesg, timo)
struct sysctl_oid_list sysctl__children
SYSCTL_PROC(_sysctl, 3, name2oid, CTLTYPE_INT|CTLFLAG_RW|CTLFLAG_ANYBODY|CTLFLAG_MPSAFE|CTLFLAG_CAPRW, 0, 0, sysctl_sysctl_name2oid,"I","")
int sysctl_handle_opaque(SYSCTL_HANDLER_ARGS)
static struct sysctl_oid * sysctl_find_oidname(const char *name, struct sysctl_oid_list *list)
void sbuf_set_drain(struct sbuf *s, sbuf_drain_func *func, void *ctx)
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)
struct sysctl_ctx_entry * sysctl_ctx_entry_find(struct sysctl_ctx_list *clist, struct sysctl_oid *oidp)
int copyout_nofault(const void *kaddr, void *udaddr, size_t len)
int sysctl_handle_int(SYSCTL_HANDLER_ARGS)
int sysctl_handle_64(SYSCTL_HANDLER_ARGS)
struct sbuf * sbuf_new(struct sbuf *s, char *buf, int length, int flags)
int sysctl_move_oid(struct sysctl_oid *oid, struct sysctl_oid_list *parent)
void free(void *addr, struct malloc_type *mtp)
int printf(const char *fmt,...)
void kern_yield(int prio)
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)
static int sysctl_new_kernel(struct sysctl_req *req, void *p, size_t l)
static int sysctl_root(SYSCTL_HANDLER_ARGS)
int sysctl_find_oid(int *name, u_int namelen, struct sysctl_oid **noid, int *nindx, struct sysctl_req *req)
static SYSCTL_NODE(_sysctl, 1, name, CTLFLAG_RD|CTLFLAG_CAPRD, sysctl_sysctl_name,"")
static int name2oid(char *name, int *oid, int *len, struct sysctl_oid **oidpp)
void sysctl_unregister_oid(struct sysctl_oid *oidp)
int securelevel_gt(struct ucred *cr, int level)
int sysctl_ctx_free(struct sysctl_ctx_list *clist)
static int sysctl_sysctl_oidfmt(SYSCTL_HANDLER_ARGS)
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)
int sysctl_handle_long(SYSCTL_HANDLER_ARGS)
static void sysctl_register_all(void *arg)
static struct sx sysctlmemlock
int sysctl_remove_oid(struct sysctl_oid *oidp, int del, int recurse)
static MALLOC_DEFINE(M_SYSCTL,"sysctl","sysctl internal magic")
SYSINIT(sysctl, SI_SUB_KMEM, SI_ORDER_ANY, sysctl_register_all, 0)
struct sbuf * sbuf_new_for_sysctl(struct sbuf *s, char *buf, int length, struct sysctl_req *req)
const struct cf_level * level
int sysctl_ctx_init(struct sysctl_ctx_list *c)