145ec3b38SPoul-Henning Kamp /*- 251369649SPedro F. Giffuni * SPDX-License-Identifier: BSD-3-Clause 351369649SPedro F. Giffuni * 445ec3b38SPoul-Henning Kamp * Copyright (c) 1982, 1986, 1989, 1993 545ec3b38SPoul-Henning Kamp * The Regents of the University of California. All rights reserved. 645ec3b38SPoul-Henning Kamp * 745ec3b38SPoul-Henning Kamp * This code is derived from software contributed to Berkeley by 845ec3b38SPoul-Henning Kamp * Mike Karels at Berkeley Software Design, Inc. 945ec3b38SPoul-Henning Kamp * 1045ec3b38SPoul-Henning Kamp * Quite extensively rewritten by Poul-Henning Kamp of the FreeBSD 1145ec3b38SPoul-Henning Kamp * project, to make these variables more userfriendly. 1245ec3b38SPoul-Henning Kamp * 1345ec3b38SPoul-Henning Kamp * Redistribution and use in source and binary forms, with or without 1445ec3b38SPoul-Henning Kamp * modification, are permitted provided that the following conditions 1545ec3b38SPoul-Henning Kamp * are met: 1645ec3b38SPoul-Henning Kamp * 1. Redistributions of source code must retain the above copyright 1745ec3b38SPoul-Henning Kamp * notice, this list of conditions and the following disclaimer. 1845ec3b38SPoul-Henning Kamp * 2. Redistributions in binary form must reproduce the above copyright 1945ec3b38SPoul-Henning Kamp * notice, this list of conditions and the following disclaimer in the 2045ec3b38SPoul-Henning Kamp * documentation and/or other materials provided with the distribution. 2169a28758SEd Maste * 3. Neither the name of the University nor the names of its contributors 2245ec3b38SPoul-Henning Kamp * may be used to endorse or promote products derived from this software 2345ec3b38SPoul-Henning Kamp * without specific prior written permission. 2445ec3b38SPoul-Henning Kamp * 2545ec3b38SPoul-Henning Kamp * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 2645ec3b38SPoul-Henning Kamp * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2745ec3b38SPoul-Henning Kamp * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2845ec3b38SPoul-Henning Kamp * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 2945ec3b38SPoul-Henning Kamp * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 3045ec3b38SPoul-Henning Kamp * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 3145ec3b38SPoul-Henning Kamp * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 3245ec3b38SPoul-Henning Kamp * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 3345ec3b38SPoul-Henning Kamp * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3445ec3b38SPoul-Henning Kamp * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3545ec3b38SPoul-Henning Kamp * SUCH DAMAGE. 3645ec3b38SPoul-Henning Kamp * 3745ec3b38SPoul-Henning Kamp * @(#)kern_sysctl.c 8.4 (Berkeley) 4/14/94 3845ec3b38SPoul-Henning Kamp */ 3945ec3b38SPoul-Henning Kamp 40677b542eSDavid E. O'Brien #include <sys/cdefs.h> 41677b542eSDavid E. O'Brien __FBSDID("$FreeBSD$"); 42677b542eSDavid E. O'Brien 43eacb362fSRobert Watson #include "opt_posix.h" 445f9974aeSWojciech A. Koszek #include "opt_config.h" 45c175d222SRobert Watson 4645ec3b38SPoul-Henning Kamp #include <sys/param.h> 47d1b06863SMark Murray #include <sys/jail.h> 4845ec3b38SPoul-Henning Kamp #include <sys/kernel.h> 497a6322e1SKonstantin Belousov #include <sys/limits.h> 5001137630SRobert Watson #include <sys/lock.h> 5101137630SRobert Watson #include <sys/mutex.h> 52d1b06863SMark Murray #include <sys/proc.h> 53d1b06863SMark Murray #include <sys/random.h> 54d1b06863SMark Murray #include <sys/sbuf.h> 556caa8a15SJohn Baldwin #include <sys/smp.h> 560304c731SJamie Gritton #include <sys/sx.h> 579ed01c32SGleb Smirnoff #include <sys/vmmeter.h> 58d1b06863SMark Murray #include <sys/sysctl.h> 59d1b06863SMark Murray #include <sys/systm.h> 60eeea998cSMike Barcroft #include <sys/unistd.h> 61662f9a69SKATO Takenori 62af3b2549SHans Petter Selasky SYSCTL_ROOT_NODE(0, sysctl, CTLFLAG_RW, 0, 6345ec3b38SPoul-Henning Kamp "Sysctl internal magic"); 64af3b2549SHans Petter Selasky SYSCTL_ROOT_NODE(CTL_KERN, kern, CTLFLAG_RW|CTLFLAG_CAPRD, 0, 6545ec3b38SPoul-Henning Kamp "High kernel, proc, limits &c"); 66af3b2549SHans Petter Selasky SYSCTL_ROOT_NODE(CTL_VM, vm, CTLFLAG_RW, 0, 6745ec3b38SPoul-Henning Kamp "Virtual memory"); 68af3b2549SHans Petter Selasky SYSCTL_ROOT_NODE(CTL_VFS, vfs, CTLFLAG_RW, 0, 6945ec3b38SPoul-Henning Kamp "File system"); 70af3b2549SHans Petter Selasky SYSCTL_ROOT_NODE(CTL_NET, net, CTLFLAG_RW, 0, 7145ec3b38SPoul-Henning Kamp "Network, (see socket.h)"); 72af3b2549SHans Petter Selasky SYSCTL_ROOT_NODE(CTL_DEBUG, debug, CTLFLAG_RW, 0, 7345ec3b38SPoul-Henning Kamp "Debugging"); 746f13bfc2SPoul-Henning Kamp SYSCTL_NODE(_debug, OID_AUTO, sizeof, CTLFLAG_RW, 0, 756f13bfc2SPoul-Henning Kamp "Sizeof various things"); 76af3b2549SHans Petter Selasky SYSCTL_ROOT_NODE(CTL_HW, hw, CTLFLAG_RW, 0, 7745ec3b38SPoul-Henning Kamp "hardware"); 78af3b2549SHans Petter Selasky SYSCTL_ROOT_NODE(CTL_MACHDEP, machdep, CTLFLAG_RW, 0, 7945ec3b38SPoul-Henning Kamp "machine dependent"); 80af3b2549SHans Petter Selasky SYSCTL_ROOT_NODE(CTL_USER, user, CTLFLAG_RW, 0, 8145ec3b38SPoul-Henning Kamp "user-level"); 82af3b2549SHans Petter Selasky SYSCTL_ROOT_NODE(CTL_P1003_1B, p1003_1b, CTLFLAG_RW, 0, 838a6472b7SPeter Dufault "p1003_1b, (see p1003_1b.h)"); 84644d85f4SPeter Dufault 85af3b2549SHans Petter Selasky SYSCTL_ROOT_NODE(OID_AUTO, compat, CTLFLAG_RW, 0, 86c6dfea0eSMarcel Moolenaar "Compatibility code"); 87af3b2549SHans Petter Selasky SYSCTL_ROOT_NODE(OID_AUTO, security, CTLFLAG_RW, 0, 88d0615c64SAndrew R. Reiter "Security"); 89eacb362fSRobert Watson #ifdef REGRESSION 90af3b2549SHans Petter Selasky SYSCTL_ROOT_NODE(OID_AUTO, regression, CTLFLAG_RW, 0, 91eacb362fSRobert Watson "Regression test MIB"); 92eacb362fSRobert Watson #endif 93c6dfea0eSMarcel Moolenaar 94f3b86a5fSEd Schouten SYSCTL_STRING(_kern, OID_AUTO, ident, CTLFLAG_RD|CTLFLAG_MPSAFE, 95c02d7621SJuli Mallett kern_ident, 0, "Kernel identifier"); 96da1186f2SJuli Mallett 97ff66f6a4SRobert Watson SYSCTL_INT(_kern, KERN_OSREV, osrevision, CTLFLAG_RD|CTLFLAG_CAPRD, 98f0188618SHans Petter Selasky SYSCTL_NULL_INT_PTR, BSD, "Operating system revision"); 9945ec3b38SPoul-Henning Kamp 100f3b86a5fSEd Schouten SYSCTL_STRING(_kern, KERN_VERSION, version, CTLFLAG_RD|CTLFLAG_MPSAFE, 1013d177f46SBill Fumerola version, 0, "Kernel version"); 10245ec3b38SPoul-Henning Kamp 1038eede5c4SAndriy Gapon SYSCTL_STRING(_kern, OID_AUTO, compiler_version, CTLFLAG_RD|CTLFLAG_MPSAFE, 104bfdcb3bcSAndriy Gapon compiler_version, 0, "Version of compiler used to compile kernel"); 105bfdcb3bcSAndriy Gapon 106ff66f6a4SRobert Watson SYSCTL_STRING(_kern, KERN_OSTYPE, ostype, CTLFLAG_RD|CTLFLAG_MPSAFE| 107ff66f6a4SRobert Watson CTLFLAG_CAPRD, ostype, 0, "Operating system type"); 10845ec3b38SPoul-Henning Kamp 109af3b2549SHans Petter Selasky SYSCTL_INT(_kern, KERN_MAXPROC, maxproc, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, 1103d177f46SBill Fumerola &maxproc, 0, "Maximum number of processes"); 11145ec3b38SPoul-Henning Kamp 1123d177f46SBill Fumerola SYSCTL_INT(_kern, KERN_MAXPROCPERUID, maxprocperuid, CTLFLAG_RW, 1133d177f46SBill Fumerola &maxprocperuid, 0, "Maximum processes allowed per userid"); 11445ec3b38SPoul-Henning Kamp 115af3b2549SHans Petter Selasky SYSCTL_INT(_kern, OID_AUTO, maxusers, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, 116ee342e1bSPeter Wemm &maxusers, 0, "Hint for kernel tuning"); 117ee342e1bSPeter Wemm 118ff66f6a4SRobert Watson SYSCTL_INT(_kern, KERN_ARGMAX, argmax, CTLFLAG_RD|CTLFLAG_CAPRD, 119f0188618SHans Petter Selasky SYSCTL_NULL_INT_PTR, ARG_MAX, "Maximum bytes of argument to execve(2)"); 12045ec3b38SPoul-Henning Kamp 121ff66f6a4SRobert Watson SYSCTL_INT(_kern, KERN_POSIX1, posix1version, CTLFLAG_RD|CTLFLAG_CAPRD, 122f0188618SHans Petter Selasky SYSCTL_NULL_INT_PTR, _POSIX_VERSION, "Version of POSIX attempting to comply to"); 12345ec3b38SPoul-Henning Kamp 124af3b2549SHans Petter Selasky SYSCTL_INT(_kern, KERN_NGROUPS, ngroups, CTLFLAG_RDTUN | 125af3b2549SHans Petter Selasky CTLFLAG_NOFETCH | CTLFLAG_CAPRD, &ngroups_max, 0, 1265feedc25SBrooks Davis "Maximum number of supplemental groups a user can belong to"); 12745ec3b38SPoul-Henning Kamp 128ff66f6a4SRobert Watson SYSCTL_INT(_kern, KERN_JOB_CONTROL, job_control, CTLFLAG_RD|CTLFLAG_CAPRD, 129f0188618SHans Petter Selasky SYSCTL_NULL_INT_PTR, 1, "Whether job control is available"); 13045ec3b38SPoul-Henning Kamp 13145ec3b38SPoul-Henning Kamp #ifdef _POSIX_SAVED_IDS 132ff66f6a4SRobert Watson SYSCTL_INT(_kern, KERN_SAVED_IDS, saved_ids, CTLFLAG_RD|CTLFLAG_CAPRD, 133f0188618SHans Petter Selasky SYSCTL_NULL_INT_PTR, 1, "Whether saved set-group/user ID is available"); 13445ec3b38SPoul-Henning Kamp #else 135ff66f6a4SRobert Watson SYSCTL_INT(_kern, KERN_SAVED_IDS, saved_ids, CTLFLAG_RD|CTLFLAG_CAPRD, 136f0188618SHans Petter Selasky SYSCTL_NULL_INT_PTR, 0, "Whether saved set-group/user ID is available"); 13745ec3b38SPoul-Henning Kamp #endif 13845ec3b38SPoul-Henning Kamp 139b25ce41eSOleksandr Tymoshenko char kernelname[MAXPATHLEN] = "/boot/kernel/kernel"; /* XXX bloat */ 14045ec3b38SPoul-Henning Kamp 14153dc58f2SMateusz Guzik SYSCTL_STRING(_kern, KERN_BOOTFILE, bootfile, CTLFLAG_RW | CTLFLAG_MPSAFE, 1423d177f46SBill Fumerola kernelname, sizeof kernelname, "Name of kernel file booted"); 14345ec3b38SPoul-Henning Kamp 1447ed6b78bSGleb Smirnoff SYSCTL_INT(_kern, KERN_MAXPHYS, maxphys, CTLFLAG_RD | CTLFLAG_CAPRD, 1457ed6b78bSGleb Smirnoff SYSCTL_NULL_INT_PTR, MAXPHYS, "Maximum block I/O access size"); 1467ed6b78bSGleb Smirnoff 147ff66f6a4SRobert Watson SYSCTL_INT(_hw, HW_NCPU, ncpu, CTLFLAG_RD|CTLFLAG_CAPRD, 1483d177f46SBill Fumerola &mp_ncpus, 0, "Number of active CPUs"); 14945ec3b38SPoul-Henning Kamp 150ff66f6a4SRobert Watson SYSCTL_INT(_hw, HW_BYTEORDER, byteorder, CTLFLAG_RD|CTLFLAG_CAPRD, 151f0188618SHans Petter Selasky SYSCTL_NULL_INT_PTR, BYTE_ORDER, "System byte order"); 15245ec3b38SPoul-Henning Kamp 153ff66f6a4SRobert Watson SYSCTL_INT(_hw, HW_PAGESIZE, pagesize, CTLFLAG_RD|CTLFLAG_CAPRD, 154f0188618SHans Petter Selasky SYSCTL_NULL_INT_PTR, PAGE_SIZE, "System memory page size"); 15545ec3b38SPoul-Henning Kamp 1560fca57b8SThomas Moestl static int 157ee9f4661SAlexander Kabaev sysctl_kern_arnd(SYSCTL_HANDLER_ARGS) 158ee9f4661SAlexander Kabaev { 159370f990dSAntoine Brodin char buf[256]; 160370f990dSAntoine Brodin size_t len; 161ee9f4661SAlexander Kabaev 162*13774e82SConrad Meyer len = MIN(req->oldlen, sizeof(buf)); 163*13774e82SConrad Meyer read_random(buf, len); 164370f990dSAntoine Brodin return (SYSCTL_OUT(req, buf, len)); 165ee9f4661SAlexander Kabaev } 166ee9f4661SAlexander Kabaev 167f3b86a5fSEd Schouten SYSCTL_PROC(_kern, KERN_ARND, arandom, 168ff66f6a4SRobert Watson CTLTYPE_OPAQUE | CTLFLAG_RD | CTLFLAG_MPSAFE | CTLFLAG_CAPRD, NULL, 0, 169f3b86a5fSEd Schouten sysctl_kern_arnd, "", "arc4rand"); 170ee9f4661SAlexander Kabaev 171ee9f4661SAlexander Kabaev static int 1720fca57b8SThomas Moestl sysctl_hw_physmem(SYSCTL_HANDLER_ARGS) 1730fca57b8SThomas Moestl { 1747a6322e1SKonstantin Belousov u_long val, p; 1750fca57b8SThomas Moestl 1767a6322e1SKonstantin Belousov p = SIZE_T_MAX >> PAGE_SHIFT; 1777a6322e1SKonstantin Belousov if (physmem < p) 1787a6322e1SKonstantin Belousov p = physmem; 1797a6322e1SKonstantin Belousov val = ctob(p); 1800fca57b8SThomas Moestl return (sysctl_handle_long(oidp, &val, 0, req)); 1810fca57b8SThomas Moestl } 1820fca57b8SThomas Moestl SYSCTL_PROC(_hw, HW_PHYSMEM, physmem, CTLTYPE_ULONG | CTLFLAG_RD, 183557e162fSRavi Pokala 0, 0, sysctl_hw_physmem, "LU", 184557e162fSRavi Pokala "Amount of physical memory (in bytes)"); 1850fca57b8SThomas Moestl 1860fca57b8SThomas Moestl static int 187a0915044SWes Peters sysctl_hw_realmem(SYSCTL_HANDLER_ARGS) 188a0915044SWes Peters { 1897a6322e1SKonstantin Belousov u_long val, p; 1907a6322e1SKonstantin Belousov 1917a6322e1SKonstantin Belousov p = SIZE_T_MAX >> PAGE_SHIFT; 1927a6322e1SKonstantin Belousov if (realmem < p) 1937a6322e1SKonstantin Belousov p = realmem; 1947a6322e1SKonstantin Belousov val = ctob(p); 195a0915044SWes Peters return (sysctl_handle_long(oidp, &val, 0, req)); 196a0915044SWes Peters } 197a0915044SWes Peters SYSCTL_PROC(_hw, HW_REALMEM, realmem, CTLTYPE_ULONG | CTLFLAG_RD, 198557e162fSRavi Pokala 0, 0, sysctl_hw_realmem, "LU", 199557e162fSRavi Pokala "Amount of memory (in bytes) reported by the firmware"); 2007a6322e1SKonstantin Belousov 201a0915044SWes Peters static int 2020fca57b8SThomas Moestl sysctl_hw_usermem(SYSCTL_HANDLER_ARGS) 2030fca57b8SThomas Moestl { 2047a6322e1SKonstantin Belousov u_long val, p, p1; 2050fca57b8SThomas Moestl 2067a6322e1SKonstantin Belousov p1 = physmem - vm_wire_count(); 2077a6322e1SKonstantin Belousov p = SIZE_T_MAX >> PAGE_SHIFT; 2087a6322e1SKonstantin Belousov if (p1 < p) 2097a6322e1SKonstantin Belousov p = p1; 2107a6322e1SKonstantin Belousov val = ctob(p); 2110fca57b8SThomas Moestl return (sysctl_handle_long(oidp, &val, 0, req)); 2120fca57b8SThomas Moestl } 2130fca57b8SThomas Moestl SYSCTL_PROC(_hw, HW_USERMEM, usermem, CTLTYPE_ULONG | CTLFLAG_RD, 214557e162fSRavi Pokala 0, 0, sysctl_hw_usermem, "LU", 215557e162fSRavi Pokala "Amount of memory (in bytes) which is not wired"); 2160fca57b8SThomas Moestl 217557e162fSRavi Pokala SYSCTL_LONG(_hw, OID_AUTO, availpages, CTLFLAG_RD, &physmem, 0, 218557e162fSRavi Pokala "Amount of physical memory (in pages)"); 2190fca57b8SThomas Moestl 220fe105d45SAlan Cox u_long pagesizes[MAXPAGESIZES] = { PAGE_SIZE }; 221fe105d45SAlan Cox 222fe105d45SAlan Cox static int 223fe105d45SAlan Cox sysctl_hw_pagesizes(SYSCTL_HANDLER_ARGS) 224fe105d45SAlan Cox { 225fe105d45SAlan Cox int error; 226fe105d45SAlan Cox #ifdef SCTL_MASK32 227fe105d45SAlan Cox int i; 228fe105d45SAlan Cox uint32_t pagesizes32[MAXPAGESIZES]; 229fe105d45SAlan Cox 230fe105d45SAlan Cox if (req->flags & SCTL_MASK32) { 231fe105d45SAlan Cox /* 232fe105d45SAlan Cox * Recreate the "pagesizes" array with 32-bit elements. Truncate 233fe105d45SAlan Cox * any page size greater than UINT32_MAX to zero. 234fe105d45SAlan Cox */ 235fe105d45SAlan Cox for (i = 0; i < MAXPAGESIZES; i++) 236fe105d45SAlan Cox pagesizes32[i] = (uint32_t)pagesizes[i]; 237fe105d45SAlan Cox 238fe105d45SAlan Cox error = SYSCTL_OUT(req, pagesizes32, sizeof(pagesizes32)); 239fe105d45SAlan Cox } else 240fe105d45SAlan Cox #endif 241fe105d45SAlan Cox error = SYSCTL_OUT(req, pagesizes, sizeof(pagesizes)); 242fe105d45SAlan Cox return (error); 243fe105d45SAlan Cox } 244fe105d45SAlan Cox SYSCTL_PROC(_hw, OID_AUTO, pagesizes, CTLTYPE_ULONG | CTLFLAG_RD, 245fe105d45SAlan Cox NULL, 0, sysctl_hw_pagesizes, "LU", "Supported page sizes"); 246fe105d45SAlan Cox 24787d45a03SKonstantin Belousov #ifdef SCTL_MASK32 24887d45a03SKonstantin Belousov int adaptive_machine_arch = 1; 24987d45a03SKonstantin Belousov SYSCTL_INT(_debug, OID_AUTO, adaptive_machine_arch, CTLFLAG_RW, 25087d45a03SKonstantin Belousov &adaptive_machine_arch, 1, 25187d45a03SKonstantin Belousov "Adapt reported machine architecture to the ABI of the binary"); 25287d45a03SKonstantin Belousov #endif 25387d45a03SKonstantin Belousov 25487d45a03SKonstantin Belousov static int 25587d45a03SKonstantin Belousov sysctl_hw_machine_arch(SYSCTL_HANDLER_ARGS) 25687d45a03SKonstantin Belousov { 25787d45a03SKonstantin Belousov int error; 25887d45a03SKonstantin Belousov static const char machine_arch[] = MACHINE_ARCH; 25987d45a03SKonstantin Belousov #ifdef SCTL_MASK32 26087d45a03SKonstantin Belousov static const char machine_arch32[] = MACHINE_ARCH32; 26187d45a03SKonstantin Belousov 26287d45a03SKonstantin Belousov if ((req->flags & SCTL_MASK32) != 0 && adaptive_machine_arch) 26387d45a03SKonstantin Belousov error = SYSCTL_OUT(req, machine_arch32, sizeof(machine_arch32)); 26487d45a03SKonstantin Belousov else 26587d45a03SKonstantin Belousov #endif 26687d45a03SKonstantin Belousov error = SYSCTL_OUT(req, machine_arch, sizeof(machine_arch)); 26787d45a03SKonstantin Belousov return (error); 26887d45a03SKonstantin Belousov 26987d45a03SKonstantin Belousov } 27053dc58f2SMateusz Guzik SYSCTL_PROC(_hw, HW_MACHINE_ARCH, machine_arch, CTLTYPE_STRING | CTLFLAG_RD | 27153dc58f2SMateusz Guzik CTLFLAG_MPSAFE, NULL, 0, sysctl_hw_machine_arch, "A", 27253dc58f2SMateusz Guzik "System architecture"); 273664f8517SKATO Takenori 274fec27435SNathan Whitehorn SYSCTL_STRING(_kern, OID_AUTO, supported_archs, CTLFLAG_RD | CTLFLAG_MPSAFE, 2753cb6654dSNathan Whitehorn #ifdef COMPAT_FREEBSD32 276fec27435SNathan Whitehorn MACHINE_ARCH " " MACHINE_ARCH32, 0, "Supported architectures for binaries"); 2773cb6654dSNathan Whitehorn #else 278fec27435SNathan Whitehorn MACHINE_ARCH, 0, "Supported architectures for binaries"); 2793cb6654dSNathan Whitehorn #endif 2803cb6654dSNathan Whitehorn 28175c13541SPoul-Henning Kamp static int 28282d9ae4eSPoul-Henning Kamp sysctl_hostname(SYSCTL_HANDLER_ARGS) 28375c13541SPoul-Henning Kamp { 28476ca6f88SJamie Gritton struct prison *pr, *cpr; 28576ca6f88SJamie Gritton size_t pr_offset; 28676ca6f88SJamie Gritton char tmpname[MAXHOSTNAMELEN]; 28776ca6f88SJamie Gritton int descend, error, len; 28876ca6f88SJamie Gritton 28976ca6f88SJamie Gritton /* 29076ca6f88SJamie Gritton * This function can set: hostname domainname hostuuid. 29176ca6f88SJamie Gritton * Keep that in mind when comments say "hostname". 29276ca6f88SJamie Gritton */ 29376ca6f88SJamie Gritton pr_offset = (size_t)arg1; 29476ca6f88SJamie Gritton len = arg2; 29576ca6f88SJamie Gritton KASSERT(len <= sizeof(tmpname), 29676ca6f88SJamie Gritton ("length %d too long for %s", len, __func__)); 29775c13541SPoul-Henning Kamp 298a854ed98SJohn Baldwin pr = req->td->td_ucred->cr_prison; 2990304c731SJamie Gritton if (!(pr->pr_allow & PR_ALLOW_SET_HOSTNAME) && req->newptr) 3006c144e75SRobert Watson return (EPERM); 30101137630SRobert Watson /* 30276ca6f88SJamie Gritton * Make a local copy of hostname to get/set so we don't have to hold 30376ca6f88SJamie Gritton * the jail mutex during the sysctl copyin/copyout activities. 30401137630SRobert Watson */ 30501137630SRobert Watson mtx_lock(&pr->pr_mtx); 30676ca6f88SJamie Gritton bcopy((char *)pr + pr_offset, tmpname, len); 30701137630SRobert Watson mtx_unlock(&pr->pr_mtx); 30801137630SRobert Watson 30976ca6f88SJamie Gritton error = sysctl_handle_string(oidp, tmpname, len, req); 31001137630SRobert Watson 31101137630SRobert Watson if (req->newptr != NULL && error == 0) { 31201137630SRobert Watson /* 31376ca6f88SJamie Gritton * Copy the locally set hostname to all jails that share 31476ca6f88SJamie Gritton * this host info. 31501137630SRobert Watson */ 31676ca6f88SJamie Gritton sx_slock(&allprison_lock); 31776ca6f88SJamie Gritton while (!(pr->pr_flags & PR_HOST)) 31876ca6f88SJamie Gritton pr = pr->pr_parent; 31901137630SRobert Watson mtx_lock(&pr->pr_mtx); 32076ca6f88SJamie Gritton bcopy(tmpname, (char *)pr + pr_offset, len); 32176ca6f88SJamie Gritton FOREACH_PRISON_DESCENDANT_LOCKED(pr, cpr, descend) 32276ca6f88SJamie Gritton if (cpr->pr_flags & PR_HOST) 32376ca6f88SJamie Gritton descend = 0; 32476ca6f88SJamie Gritton else 32576ca6f88SJamie Gritton bcopy(tmpname, (char *)cpr + pr_offset, len); 32601137630SRobert Watson mtx_unlock(&pr->pr_mtx); 32776ca6f88SJamie Gritton sx_sunlock(&allprison_lock); 3284f7d1876SRobert Watson } 32975c13541SPoul-Henning Kamp return (error); 33075c13541SPoul-Henning Kamp } 33175c13541SPoul-Henning Kamp 33275c13541SPoul-Henning Kamp SYSCTL_PROC(_kern, KERN_HOSTNAME, hostname, 3330176ca2eSAllan Jude CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_PRISON | CTLFLAG_CAPRD | CTLFLAG_MPSAFE, 334c1f19219SJamie Gritton (void *)(offsetof(struct prison, pr_hostname)), MAXHOSTNAMELEN, 33576ca6f88SJamie Gritton sysctl_hostname, "A", "Hostname"); 33676ca6f88SJamie Gritton SYSCTL_PROC(_kern, KERN_NISDOMAINNAME, domainname, 3370176ca2eSAllan Jude CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_PRISON | CTLFLAG_CAPRD | CTLFLAG_MPSAFE, 338c1f19219SJamie Gritton (void *)(offsetof(struct prison, pr_domainname)), MAXHOSTNAMELEN, 33976ca6f88SJamie Gritton sysctl_hostname, "A", "Name of the current YP/NIS domain"); 34076ca6f88SJamie Gritton SYSCTL_PROC(_kern, KERN_HOSTUUID, hostuuid, 3410176ca2eSAllan Jude CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_PRISON | CTLFLAG_CAPRD | CTLFLAG_MPSAFE, 342c1f19219SJamie Gritton (void *)(offsetof(struct prison, pr_hostuuid)), HOSTUUIDLEN, 34376ca6f88SJamie Gritton sysctl_hostname, "A", "Host UUID"); 34445ec3b38SPoul-Henning Kamp 345eacb362fSRobert Watson static int regression_securelevel_nonmonotonic = 0; 346c175d222SRobert Watson 3471e4b531bSRobert Watson #ifdef REGRESSION 348c175d222SRobert Watson SYSCTL_INT(_regression, OID_AUTO, securelevel_nonmonotonic, CTLFLAG_RW, 349c175d222SRobert Watson ®ression_securelevel_nonmonotonic, 0, "securelevel may be lowered"); 350eacb362fSRobert Watson #endif 351c175d222SRobert Watson 35245ec3b38SPoul-Henning Kamp static int 35382d9ae4eSPoul-Henning Kamp sysctl_kern_securelvl(SYSCTL_HANDLER_ARGS) 35445ec3b38SPoul-Henning Kamp { 3550304c731SJamie Gritton struct prison *pr, *cpr; 3560304c731SJamie Gritton int descend, error, level; 35745ec3b38SPoul-Henning Kamp 358a854ed98SJohn Baldwin pr = req->td->td_ucred->cr_prison; 359d3c9fa04SRobert Watson 3608a528812SRobert Watson /* 3610304c731SJamie Gritton * Reading the securelevel is easy, since the current jail's level 3620304c731SJamie Gritton * is known to be at least as secure as any higher levels. Perform 3630304c731SJamie Gritton * a lockless read since the securelevel is an integer. 3648a528812SRobert Watson */ 3650304c731SJamie Gritton level = pr->pr_securelevel; 36645ec3b38SPoul-Henning Kamp error = sysctl_handle_int(oidp, &level, 0, req); 36745ec3b38SPoul-Henning Kamp if (error || !req->newptr) 36845ec3b38SPoul-Henning Kamp return (error); 3690304c731SJamie Gritton /* Permit update only if the new securelevel exceeds the old. */ 3700304c731SJamie Gritton sx_slock(&allprison_lock); 37101137630SRobert Watson mtx_lock(&pr->pr_mtx); 3721e4b531bSRobert Watson if (!regression_securelevel_nonmonotonic && 3730304c731SJamie Gritton level < pr->pr_securelevel) { 37401137630SRobert Watson mtx_unlock(&pr->pr_mtx); 3750304c731SJamie Gritton sx_sunlock(&allprison_lock); 3768a528812SRobert Watson return (EPERM); 37701137630SRobert Watson } 378d3c9fa04SRobert Watson pr->pr_securelevel = level; 3790304c731SJamie Gritton /* 3800304c731SJamie Gritton * Set all child jails to be at least this level, but do not lower 3810304c731SJamie Gritton * them (even if regression_securelevel_nonmonotonic). 3820304c731SJamie Gritton */ 3830304c731SJamie Gritton FOREACH_PRISON_DESCENDANT_LOCKED(pr, cpr, descend) { 3840304c731SJamie Gritton if (cpr->pr_securelevel < level) 3850304c731SJamie Gritton cpr->pr_securelevel = level; 3860304c731SJamie Gritton } 38701137630SRobert Watson mtx_unlock(&pr->pr_mtx); 3880304c731SJamie Gritton sx_sunlock(&allprison_lock); 38945ec3b38SPoul-Henning Kamp return (error); 39045ec3b38SPoul-Henning Kamp } 39145ec3b38SPoul-Henning Kamp 3928a528812SRobert Watson SYSCTL_PROC(_kern, KERN_SECURELVL, securelevel, 3938a528812SRobert Watson CTLTYPE_INT|CTLFLAG_RW|CTLFLAG_PRISON, 0, 0, sysctl_kern_securelvl, 3948a528812SRobert Watson "I", "Current secure level"); 395e812e491SRobert Watson 3965f9974aeSWojciech A. Koszek #ifdef INCLUDE_CONFIG_FILE 397744b947eSWojciech A. Koszek /* Actual kernel configuration options. */ 398744b947eSWojciech A. Koszek extern char kernconfstring[]; 399744b947eSWojciech A. Koszek 40053dc58f2SMateusz Guzik SYSCTL_STRING(_kern, OID_AUTO, conftxt, CTLFLAG_RD | CTLFLAG_MPSAFE, 40153dc58f2SMateusz Guzik kernconfstring, 0, "Kernel configuration file"); 4023627f737SWarner Losh #endif 403744b947eSWojciech A. Koszek 4044f7d1876SRobert Watson static int 40576ca6f88SJamie Gritton sysctl_hostid(SYSCTL_HANDLER_ARGS) 4064f7d1876SRobert Watson { 40776ca6f88SJamie Gritton struct prison *pr, *cpr; 40876ca6f88SJamie Gritton u_long tmpid; 40976ca6f88SJamie Gritton int descend, error; 4104f7d1876SRobert Watson 41176ca6f88SJamie Gritton /* 41276ca6f88SJamie Gritton * Like sysctl_hostname, except it operates on a u_long 41376ca6f88SJamie Gritton * instead of a string, and is used only for hostid. 41476ca6f88SJamie Gritton */ 41576ca6f88SJamie Gritton pr = req->td->td_ucred->cr_prison; 41676ca6f88SJamie Gritton if (!(pr->pr_allow & PR_ALLOW_SET_HOSTNAME) && req->newptr) 41776ca6f88SJamie Gritton return (EPERM); 41876ca6f88SJamie Gritton tmpid = pr->pr_hostid; 41976ca6f88SJamie Gritton error = sysctl_handle_long(oidp, &tmpid, 0, req); 42076ca6f88SJamie Gritton 4214f7d1876SRobert Watson if (req->newptr != NULL && error == 0) { 42276ca6f88SJamie Gritton sx_slock(&allprison_lock); 42376ca6f88SJamie Gritton while (!(pr->pr_flags & PR_HOST)) 42476ca6f88SJamie Gritton pr = pr->pr_parent; 42576ca6f88SJamie Gritton mtx_lock(&pr->pr_mtx); 42676ca6f88SJamie Gritton pr->pr_hostid = tmpid; 42776ca6f88SJamie Gritton FOREACH_PRISON_DESCENDANT_LOCKED(pr, cpr, descend) 42876ca6f88SJamie Gritton if (cpr->pr_flags & PR_HOST) 42976ca6f88SJamie Gritton descend = 0; 43076ca6f88SJamie Gritton else 43176ca6f88SJamie Gritton cpr->pr_hostid = tmpid; 43276ca6f88SJamie Gritton mtx_unlock(&pr->pr_mtx); 43376ca6f88SJamie Gritton sx_sunlock(&allprison_lock); 4344f7d1876SRobert Watson } 4354f7d1876SRobert Watson return (error); 4364f7d1876SRobert Watson } 4374f7d1876SRobert Watson 43876ca6f88SJamie Gritton SYSCTL_PROC(_kern, KERN_HOSTID, hostid, 439200241b5SBryan Drewery CTLTYPE_ULONG | CTLFLAG_RW | CTLFLAG_PRISON | CTLFLAG_MPSAFE | CTLFLAG_CAPRD, 44076ca6f88SJamie Gritton NULL, 0, sysctl_hostid, "LU", "Host ID"); 44145ec3b38SPoul-Henning Kamp 442b96bd95bSIan Lepore /* 443b96bd95bSIan Lepore * The osrelease string is copied from the global (osrelease in vers.c) into 444b96bd95bSIan Lepore * prison0 by a sysinit and is inherited by child jails if not changed at jail 445b96bd95bSIan Lepore * creation, so we always return the copy from the current prison data. 446b96bd95bSIan Lepore */ 447b96bd95bSIan Lepore static int 448b96bd95bSIan Lepore sysctl_osrelease(SYSCTL_HANDLER_ARGS) 449b96bd95bSIan Lepore { 450b96bd95bSIan Lepore struct prison *pr; 451b96bd95bSIan Lepore 452b96bd95bSIan Lepore pr = req->td->td_ucred->cr_prison; 453b96bd95bSIan Lepore return (SYSCTL_OUT(req, pr->pr_osrelease, strlen(pr->pr_osrelease) + 1)); 454b96bd95bSIan Lepore 455b96bd95bSIan Lepore } 456b96bd95bSIan Lepore 457b96bd95bSIan Lepore SYSCTL_PROC(_kern, KERN_OSRELEASE, osrelease, 458b96bd95bSIan Lepore CTLTYPE_STRING | CTLFLAG_CAPRD | CTLFLAG_RD | CTLFLAG_MPSAFE, 459b96bd95bSIan Lepore NULL, 0, sysctl_osrelease, "A", "Operating system release"); 460b96bd95bSIan Lepore 461b96bd95bSIan Lepore /* 462b96bd95bSIan Lepore * The osreldate number is copied from the global (osreldate in vers.c) into 463b96bd95bSIan Lepore * prison0 by a sysinit and is inherited by child jails if not changed at jail 464b96bd95bSIan Lepore * creation, so we always return the value from the current prison data. 465b96bd95bSIan Lepore */ 466b96bd95bSIan Lepore static int 467b96bd95bSIan Lepore sysctl_osreldate(SYSCTL_HANDLER_ARGS) 468b96bd95bSIan Lepore { 469b96bd95bSIan Lepore struct prison *pr; 470b96bd95bSIan Lepore 471b96bd95bSIan Lepore pr = req->td->td_ucred->cr_prison; 472b96bd95bSIan Lepore return (SYSCTL_OUT(req, &pr->pr_osreldate, sizeof(pr->pr_osreldate))); 473b96bd95bSIan Lepore 474b96bd95bSIan Lepore } 475b96bd95bSIan Lepore 476b96bd95bSIan Lepore /* 477b96bd95bSIan Lepore * NOTICE: The *userland* release date is available in 478b96bd95bSIan Lepore * /usr/include/osreldate.h 479b96bd95bSIan Lepore */ 480b96bd95bSIan Lepore SYSCTL_PROC(_kern, KERN_OSRELDATE, osreldate, 481b96bd95bSIan Lepore CTLTYPE_INT | CTLFLAG_CAPRD | CTLFLAG_RD | CTLFLAG_MPSAFE, 482b96bd95bSIan Lepore NULL, 0, sysctl_osreldate, "I", "Kernel release date"); 483b96bd95bSIan Lepore 4840deabe7eSJohn Baldwin SYSCTL_NODE(_kern, OID_AUTO, features, CTLFLAG_RD, 0, "Kernel Features"); 4850deabe7eSJohn Baldwin 4862c179010SJohn Baldwin #ifdef COMPAT_FREEBSD4 4872c179010SJohn Baldwin FEATURE(compat_freebsd4, "Compatible with FreeBSD 4"); 4882c179010SJohn Baldwin #endif 4892c179010SJohn Baldwin 4902c179010SJohn Baldwin #ifdef COMPAT_FREEBSD5 4912c179010SJohn Baldwin FEATURE(compat_freebsd5, "Compatible with FreeBSD 5"); 4922c179010SJohn Baldwin #endif 4932c179010SJohn Baldwin 4942c179010SJohn Baldwin #ifdef COMPAT_FREEBSD6 4952c179010SJohn Baldwin FEATURE(compat_freebsd6, "Compatible with FreeBSD 6"); 4962c179010SJohn Baldwin #endif 4972c179010SJohn Baldwin 4982c179010SJohn Baldwin #ifdef COMPAT_FREEBSD7 4992c179010SJohn Baldwin FEATURE(compat_freebsd7, "Compatible with FreeBSD 7"); 5002c179010SJohn Baldwin #endif 5012c179010SJohn Baldwin 50245ec3b38SPoul-Henning Kamp /* 50345ec3b38SPoul-Henning Kamp * This is really cheating. These actually live in the libc, something 50445ec3b38SPoul-Henning Kamp * which I'm not quite sure is a good idea anyway, but in order for 50545ec3b38SPoul-Henning Kamp * getnext and friends to actually work, we define dummies here. 506ff66f6a4SRobert Watson * 507ff66f6a4SRobert Watson * XXXRW: These probably should be CTLFLAG_CAPRD. 50845ec3b38SPoul-Henning Kamp */ 5093d177f46SBill Fumerola SYSCTL_STRING(_user, USER_CS_PATH, cs_path, CTLFLAG_RD, 5103d177f46SBill Fumerola "", 0, "PATH that finds all the standard utilities"); 5113d177f46SBill Fumerola SYSCTL_INT(_user, USER_BC_BASE_MAX, bc_base_max, CTLFLAG_RD, 512f0188618SHans Petter Selasky SYSCTL_NULL_INT_PTR, 0, "Max ibase/obase values in bc(1)"); 5133d177f46SBill Fumerola SYSCTL_INT(_user, USER_BC_DIM_MAX, bc_dim_max, CTLFLAG_RD, 514f0188618SHans Petter Selasky SYSCTL_NULL_INT_PTR, 0, "Max array size in bc(1)"); 5153d177f46SBill Fumerola SYSCTL_INT(_user, USER_BC_SCALE_MAX, bc_scale_max, CTLFLAG_RD, 516f0188618SHans Petter Selasky SYSCTL_NULL_INT_PTR, 0, "Max scale value in bc(1)"); 5173d177f46SBill Fumerola SYSCTL_INT(_user, USER_BC_STRING_MAX, bc_string_max, CTLFLAG_RD, 518f0188618SHans Petter Selasky SYSCTL_NULL_INT_PTR, 0, "Max string length in bc(1)"); 5193d177f46SBill Fumerola SYSCTL_INT(_user, USER_COLL_WEIGHTS_MAX, coll_weights_max, CTLFLAG_RD, 520f0188618SHans Petter Selasky SYSCTL_NULL_INT_PTR, 0, "Maximum number of weights assigned to an LC_COLLATE locale entry"); 521f0188618SHans Petter Selasky SYSCTL_INT(_user, USER_EXPR_NEST_MAX, expr_nest_max, CTLFLAG_RD, 522f0188618SHans Petter Selasky SYSCTL_NULL_INT_PTR, 0, ""); 5233d177f46SBill Fumerola SYSCTL_INT(_user, USER_LINE_MAX, line_max, CTLFLAG_RD, 524f0188618SHans Petter Selasky SYSCTL_NULL_INT_PTR, 0, "Max length (bytes) of a text-processing utility's input line"); 5253d177f46SBill Fumerola SYSCTL_INT(_user, USER_RE_DUP_MAX, re_dup_max, CTLFLAG_RD, 526f0188618SHans Petter Selasky SYSCTL_NULL_INT_PTR, 0, "Maximum number of repeats of a regexp permitted"); 5273d177f46SBill Fumerola SYSCTL_INT(_user, USER_POSIX2_VERSION, posix2_version, CTLFLAG_RD, 528f0188618SHans Petter Selasky SYSCTL_NULL_INT_PTR, 0, 5293d177f46SBill Fumerola "The version of POSIX 1003.2 with which the system attempts to comply"); 5303d177f46SBill Fumerola SYSCTL_INT(_user, USER_POSIX2_C_BIND, posix2_c_bind, CTLFLAG_RD, 531f0188618SHans Petter Selasky SYSCTL_NULL_INT_PTR, 0, "Whether C development supports the C bindings option"); 5323d177f46SBill Fumerola SYSCTL_INT(_user, USER_POSIX2_C_DEV, posix2_c_dev, CTLFLAG_RD, 533f0188618SHans Petter Selasky SYSCTL_NULL_INT_PTR, 0, "Whether system supports the C development utilities option"); 5343d177f46SBill Fumerola SYSCTL_INT(_user, USER_POSIX2_CHAR_TERM, posix2_char_term, CTLFLAG_RD, 535f0188618SHans Petter Selasky SYSCTL_NULL_INT_PTR, 0, ""); 5363d177f46SBill Fumerola SYSCTL_INT(_user, USER_POSIX2_FORT_DEV, posix2_fort_dev, CTLFLAG_RD, 537f0188618SHans Petter Selasky SYSCTL_NULL_INT_PTR, 0, "Whether system supports FORTRAN development utilities"); 5383d177f46SBill Fumerola SYSCTL_INT(_user, USER_POSIX2_FORT_RUN, posix2_fort_run, CTLFLAG_RD, 539f0188618SHans Petter Selasky SYSCTL_NULL_INT_PTR, 0, "Whether system supports FORTRAN runtime utilities"); 5403d177f46SBill Fumerola SYSCTL_INT(_user, USER_POSIX2_LOCALEDEF, posix2_localedef, CTLFLAG_RD, 541f0188618SHans Petter Selasky SYSCTL_NULL_INT_PTR, 0, "Whether system supports creation of locales"); 5423d177f46SBill Fumerola SYSCTL_INT(_user, USER_POSIX2_SW_DEV, posix2_sw_dev, CTLFLAG_RD, 543f0188618SHans Petter Selasky SYSCTL_NULL_INT_PTR, 0, "Whether system supports software development utilities"); 5443d177f46SBill Fumerola SYSCTL_INT(_user, USER_POSIX2_UPE, posix2_upe, CTLFLAG_RD, 545f0188618SHans Petter Selasky SYSCTL_NULL_INT_PTR, 0, "Whether system supports the user portability utilities"); 5463d177f46SBill Fumerola SYSCTL_INT(_user, USER_STREAM_MAX, stream_max, CTLFLAG_RD, 547f0188618SHans Petter Selasky SYSCTL_NULL_INT_PTR, 0, "Min Maximum number of streams a process may have open at one time"); 5483d177f46SBill Fumerola SYSCTL_INT(_user, USER_TZNAME_MAX, tzname_max, CTLFLAG_RD, 549f0188618SHans Petter Selasky SYSCTL_NULL_INT_PTR, 0, "Min Maximum number of types supported for timezone names"); 5506f13bfc2SPoul-Henning Kamp 5516f13bfc2SPoul-Henning Kamp #include <sys/vnode.h> 5526f13bfc2SPoul-Henning Kamp SYSCTL_INT(_debug_sizeof, OID_AUTO, vnode, CTLFLAG_RD, 553f0188618SHans Petter Selasky SYSCTL_NULL_INT_PTR, sizeof(struct vnode), "sizeof(struct vnode)"); 5546f13bfc2SPoul-Henning Kamp 5556f13bfc2SPoul-Henning Kamp SYSCTL_INT(_debug_sizeof, OID_AUTO, proc, CTLFLAG_RD, 556f0188618SHans Petter Selasky SYSCTL_NULL_INT_PTR, sizeof(struct proc), "sizeof(struct proc)"); 557d7bf417dSPoul-Henning Kamp 55802c6fc21SKonstantin Belousov static int 55902c6fc21SKonstantin Belousov sysctl_kern_pid_max(SYSCTL_HANDLER_ARGS) 56002c6fc21SKonstantin Belousov { 56102c6fc21SKonstantin Belousov int error, pm; 56202c6fc21SKonstantin Belousov 56302c6fc21SKonstantin Belousov pm = pid_max; 56402c6fc21SKonstantin Belousov error = sysctl_handle_int(oidp, &pm, 0, req); 56502c6fc21SKonstantin Belousov if (error || !req->newptr) 56602c6fc21SKonstantin Belousov return (error); 56702c6fc21SKonstantin Belousov sx_xlock(&proctree_lock); 56802c6fc21SKonstantin Belousov sx_xlock(&allproc_lock); 5693fa615bcSKonstantin Belousov 5703fa615bcSKonstantin Belousov /* 5713fa615bcSKonstantin Belousov * Only permit the values less then PID_MAX. 5723fa615bcSKonstantin Belousov * As a safety measure, do not allow to limit the pid_max too much. 5733fa615bcSKonstantin Belousov */ 5743fa615bcSKonstantin Belousov if (pm < 300 || pm > PID_MAX) 57502c6fc21SKonstantin Belousov error = EINVAL; 57602c6fc21SKonstantin Belousov else 57702c6fc21SKonstantin Belousov pid_max = pm; 57802c6fc21SKonstantin Belousov sx_xunlock(&allproc_lock); 57902c6fc21SKonstantin Belousov sx_xunlock(&proctree_lock); 58002c6fc21SKonstantin Belousov return (error); 58102c6fc21SKonstantin Belousov } 582af3b2549SHans Petter Selasky SYSCTL_PROC(_kern, OID_AUTO, pid_max, CTLTYPE_INT | 583af3b2549SHans Petter Selasky CTLFLAG_RWTUN | CTLFLAG_NOFETCH | CTLFLAG_MPSAFE, 584af3b2549SHans Petter Selasky 0, 0, sysctl_kern_pid_max, "I", "Maximum allowed pid"); 58502c6fc21SKonstantin Belousov 5869626b608SPoul-Henning Kamp #include <sys/bio.h> 5878c125869SPoul-Henning Kamp #include <sys/buf.h> 5888c125869SPoul-Henning Kamp SYSCTL_INT(_debug_sizeof, OID_AUTO, bio, CTLFLAG_RD, 589f0188618SHans Petter Selasky SYSCTL_NULL_INT_PTR, sizeof(struct bio), "sizeof(struct bio)"); 5908c125869SPoul-Henning Kamp SYSCTL_INT(_debug_sizeof, OID_AUTO, buf, CTLFLAG_RD, 591f0188618SHans Petter Selasky SYSCTL_NULL_INT_PTR, sizeof(struct buf), "sizeof(struct buf)"); 592d5a08a60SJake Burkholder 593d5a08a60SJake Burkholder #include <sys/user.h> 594d5a08a60SJake Burkholder SYSCTL_INT(_debug_sizeof, OID_AUTO, kinfo_proc, CTLFLAG_RD, 595f0188618SHans Petter Selasky SYSCTL_NULL_INT_PTR, sizeof(struct kinfo_proc), "sizeof(struct kinfo_proc)"); 596a360a43dSJake Burkholder 597645743eaSJohn Baldwin /* Used by kernel debuggers. */ 598645743eaSJohn Baldwin const int pcb_size = sizeof(struct pcb); 599645743eaSJohn Baldwin SYSCTL_INT(_debug_sizeof, OID_AUTO, pcb, CTLFLAG_RD, 600645743eaSJohn Baldwin SYSCTL_NULL_INT_PTR, sizeof(struct pcb), "sizeof(struct pcb)"); 601645743eaSJohn Baldwin 602e548a1d4SJake Burkholder /* XXX compatibility, remove for 6.0 */ 603e548a1d4SJake Burkholder #include <sys/imgact.h> 604e548a1d4SJake Burkholder #include <sys/imgact_elf.h> 605e548a1d4SJake Burkholder SYSCTL_INT(_kern, OID_AUTO, fallback_elf_brand, CTLFLAG_RW, 606e548a1d4SJake Burkholder &__elfN(fallback_brand), sizeof(__elfN(fallback_brand)), 607e548a1d4SJake Burkholder "compatibility for kern.fallback_elf_brand"); 608