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> 47af9727f6SWarner Losh #include <sys/boot.h> 48d1b06863SMark Murray #include <sys/jail.h> 4945ec3b38SPoul-Henning Kamp #include <sys/kernel.h> 507a6322e1SKonstantin Belousov #include <sys/limits.h> 5101137630SRobert Watson #include <sys/lock.h> 5201137630SRobert Watson #include <sys/mutex.h> 53d1b06863SMark Murray #include <sys/proc.h> 54d1b06863SMark Murray #include <sys/random.h> 55d1b06863SMark Murray #include <sys/sbuf.h> 566caa8a15SJohn Baldwin #include <sys/smp.h> 570304c731SJamie Gritton #include <sys/sx.h> 589ed01c32SGleb Smirnoff #include <sys/vmmeter.h> 59d1b06863SMark Murray #include <sys/sysctl.h> 60d1b06863SMark Murray #include <sys/systm.h> 61eeea998cSMike Barcroft #include <sys/unistd.h> 62662f9a69SKATO Takenori 63*7029da5cSPawel Biernacki SYSCTL_ROOT_NODE(0, sysctl, CTLFLAG_RW | CTLFLAG_MPSAFE, 0, 6445ec3b38SPoul-Henning Kamp "Sysctl internal magic"); 65*7029da5cSPawel Biernacki SYSCTL_ROOT_NODE(CTL_KERN, kern, CTLFLAG_RW | CTLFLAG_CAPRD | CTLFLAG_MPSAFE, 0, 6645ec3b38SPoul-Henning Kamp "High kernel, proc, limits &c"); 67*7029da5cSPawel Biernacki SYSCTL_ROOT_NODE(CTL_VM, vm, CTLFLAG_RW | CTLFLAG_MPSAFE, 0, 6845ec3b38SPoul-Henning Kamp "Virtual memory"); 69*7029da5cSPawel Biernacki SYSCTL_ROOT_NODE(CTL_VFS, vfs, CTLFLAG_RW | CTLFLAG_MPSAFE, 0, 7045ec3b38SPoul-Henning Kamp "File system"); 71*7029da5cSPawel Biernacki SYSCTL_ROOT_NODE(CTL_NET, net, CTLFLAG_RW | CTLFLAG_MPSAFE, 0, 7245ec3b38SPoul-Henning Kamp "Network, (see socket.h)"); 73*7029da5cSPawel Biernacki SYSCTL_ROOT_NODE(CTL_DEBUG, debug, CTLFLAG_RW | CTLFLAG_MPSAFE, 0, 7445ec3b38SPoul-Henning Kamp "Debugging"); 75*7029da5cSPawel Biernacki SYSCTL_NODE(_debug, OID_AUTO, sizeof, CTLFLAG_RW | CTLFLAG_MPSAFE, 0, 766f13bfc2SPoul-Henning Kamp "Sizeof various things"); 77*7029da5cSPawel Biernacki SYSCTL_ROOT_NODE(CTL_HW, hw, CTLFLAG_RW | CTLFLAG_MPSAFE, 0, 7845ec3b38SPoul-Henning Kamp "hardware"); 79*7029da5cSPawel Biernacki SYSCTL_ROOT_NODE(CTL_MACHDEP, machdep, CTLFLAG_RW | CTLFLAG_MPSAFE, 0, 8045ec3b38SPoul-Henning Kamp "machine dependent"); 81*7029da5cSPawel Biernacki SYSCTL_NODE(_machdep, OID_AUTO, mitigations, CTLFLAG_RW | CTLFLAG_MPSAFE, 0, 82de890ea4SScott Long "Machine dependent platform mitigations."); 83*7029da5cSPawel Biernacki SYSCTL_ROOT_NODE(CTL_USER, user, CTLFLAG_RW | CTLFLAG_MPSAFE, 0, 8445ec3b38SPoul-Henning Kamp "user-level"); 85*7029da5cSPawel Biernacki SYSCTL_ROOT_NODE(CTL_P1003_1B, p1003_1b, CTLFLAG_RW | CTLFLAG_MPSAFE, 0, 868a6472b7SPeter Dufault "p1003_1b, (see p1003_1b.h)"); 87644d85f4SPeter Dufault 88*7029da5cSPawel Biernacki SYSCTL_ROOT_NODE(OID_AUTO, compat, CTLFLAG_RW | CTLFLAG_MPSAFE, 0, 89c6dfea0eSMarcel Moolenaar "Compatibility code"); 90*7029da5cSPawel Biernacki SYSCTL_ROOT_NODE(OID_AUTO, security, CTLFLAG_RW | CTLFLAG_MPSAFE, 0, 91d0615c64SAndrew R. Reiter "Security"); 92eacb362fSRobert Watson #ifdef REGRESSION 93*7029da5cSPawel Biernacki SYSCTL_ROOT_NODE(OID_AUTO, regression, CTLFLAG_RW | CTLFLAG_MPSAFE, 0, 94eacb362fSRobert Watson "Regression test MIB"); 95eacb362fSRobert Watson #endif 96c6dfea0eSMarcel Moolenaar 97f3b86a5fSEd Schouten SYSCTL_STRING(_kern, OID_AUTO, ident, CTLFLAG_RD|CTLFLAG_MPSAFE, 98c02d7621SJuli Mallett kern_ident, 0, "Kernel identifier"); 99da1186f2SJuli Mallett 100ff66f6a4SRobert Watson SYSCTL_INT(_kern, KERN_OSREV, osrevision, CTLFLAG_RD|CTLFLAG_CAPRD, 101f0188618SHans Petter Selasky SYSCTL_NULL_INT_PTR, BSD, "Operating system revision"); 10245ec3b38SPoul-Henning Kamp 103f3b86a5fSEd Schouten SYSCTL_STRING(_kern, KERN_VERSION, version, CTLFLAG_RD|CTLFLAG_MPSAFE, 1043d177f46SBill Fumerola version, 0, "Kernel version"); 10545ec3b38SPoul-Henning Kamp 1068eede5c4SAndriy Gapon SYSCTL_STRING(_kern, OID_AUTO, compiler_version, CTLFLAG_RD|CTLFLAG_MPSAFE, 107bfdcb3bcSAndriy Gapon compiler_version, 0, "Version of compiler used to compile kernel"); 108bfdcb3bcSAndriy Gapon 109ff66f6a4SRobert Watson SYSCTL_STRING(_kern, KERN_OSTYPE, ostype, CTLFLAG_RD|CTLFLAG_MPSAFE| 110ff66f6a4SRobert Watson CTLFLAG_CAPRD, ostype, 0, "Operating system type"); 11145ec3b38SPoul-Henning Kamp 112af3b2549SHans Petter Selasky SYSCTL_INT(_kern, KERN_MAXPROC, maxproc, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, 1133d177f46SBill Fumerola &maxproc, 0, "Maximum number of processes"); 11445ec3b38SPoul-Henning Kamp 1153d177f46SBill Fumerola SYSCTL_INT(_kern, KERN_MAXPROCPERUID, maxprocperuid, CTLFLAG_RW, 1163d177f46SBill Fumerola &maxprocperuid, 0, "Maximum processes allowed per userid"); 11745ec3b38SPoul-Henning Kamp 118af3b2549SHans Petter Selasky SYSCTL_INT(_kern, OID_AUTO, maxusers, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, 119ee342e1bSPeter Wemm &maxusers, 0, "Hint for kernel tuning"); 120ee342e1bSPeter Wemm 121ff66f6a4SRobert Watson SYSCTL_INT(_kern, KERN_ARGMAX, argmax, CTLFLAG_RD|CTLFLAG_CAPRD, 122f0188618SHans Petter Selasky SYSCTL_NULL_INT_PTR, ARG_MAX, "Maximum bytes of argument to execve(2)"); 12345ec3b38SPoul-Henning Kamp 124ff66f6a4SRobert Watson SYSCTL_INT(_kern, KERN_POSIX1, posix1version, CTLFLAG_RD|CTLFLAG_CAPRD, 125f0188618SHans Petter Selasky SYSCTL_NULL_INT_PTR, _POSIX_VERSION, "Version of POSIX attempting to comply to"); 12645ec3b38SPoul-Henning Kamp 127af3b2549SHans Petter Selasky SYSCTL_INT(_kern, KERN_NGROUPS, ngroups, CTLFLAG_RDTUN | 128af3b2549SHans Petter Selasky CTLFLAG_NOFETCH | CTLFLAG_CAPRD, &ngroups_max, 0, 1295feedc25SBrooks Davis "Maximum number of supplemental groups a user can belong to"); 13045ec3b38SPoul-Henning Kamp 131ff66f6a4SRobert Watson SYSCTL_INT(_kern, KERN_JOB_CONTROL, job_control, CTLFLAG_RD|CTLFLAG_CAPRD, 132f0188618SHans Petter Selasky SYSCTL_NULL_INT_PTR, 1, "Whether job control is available"); 13345ec3b38SPoul-Henning Kamp 13445ec3b38SPoul-Henning Kamp #ifdef _POSIX_SAVED_IDS 135ff66f6a4SRobert Watson SYSCTL_INT(_kern, KERN_SAVED_IDS, saved_ids, CTLFLAG_RD|CTLFLAG_CAPRD, 136f0188618SHans Petter Selasky SYSCTL_NULL_INT_PTR, 1, "Whether saved set-group/user ID is available"); 13745ec3b38SPoul-Henning Kamp #else 138ff66f6a4SRobert Watson SYSCTL_INT(_kern, KERN_SAVED_IDS, saved_ids, CTLFLAG_RD|CTLFLAG_CAPRD, 139f0188618SHans Petter Selasky SYSCTL_NULL_INT_PTR, 0, "Whether saved set-group/user ID is available"); 14045ec3b38SPoul-Henning Kamp #endif 14145ec3b38SPoul-Henning Kamp 142ec9abc18SWarner Losh char kernelname[MAXPATHLEN] = PATH_KERNEL; /* XXX bloat */ 14345ec3b38SPoul-Henning Kamp 14453dc58f2SMateusz Guzik SYSCTL_STRING(_kern, KERN_BOOTFILE, bootfile, CTLFLAG_RW | CTLFLAG_MPSAFE, 1453d177f46SBill Fumerola kernelname, sizeof kernelname, "Name of kernel file booted"); 14645ec3b38SPoul-Henning Kamp 1477ed6b78bSGleb Smirnoff SYSCTL_INT(_kern, KERN_MAXPHYS, maxphys, CTLFLAG_RD | CTLFLAG_CAPRD, 1487ed6b78bSGleb Smirnoff SYSCTL_NULL_INT_PTR, MAXPHYS, "Maximum block I/O access size"); 1497ed6b78bSGleb Smirnoff 150ff66f6a4SRobert Watson SYSCTL_INT(_hw, HW_NCPU, ncpu, CTLFLAG_RD|CTLFLAG_CAPRD, 1513d177f46SBill Fumerola &mp_ncpus, 0, "Number of active CPUs"); 15245ec3b38SPoul-Henning Kamp 153ff66f6a4SRobert Watson SYSCTL_INT(_hw, HW_BYTEORDER, byteorder, CTLFLAG_RD|CTLFLAG_CAPRD, 154f0188618SHans Petter Selasky SYSCTL_NULL_INT_PTR, BYTE_ORDER, "System byte order"); 15545ec3b38SPoul-Henning Kamp 156ff66f6a4SRobert Watson SYSCTL_INT(_hw, HW_PAGESIZE, pagesize, CTLFLAG_RD|CTLFLAG_CAPRD, 157f0188618SHans Petter Selasky SYSCTL_NULL_INT_PTR, PAGE_SIZE, "System memory page size"); 15845ec3b38SPoul-Henning Kamp 1590fca57b8SThomas Moestl static int 160ee9f4661SAlexander Kabaev sysctl_kern_arnd(SYSCTL_HANDLER_ARGS) 161ee9f4661SAlexander Kabaev { 162370f990dSAntoine Brodin char buf[256]; 163370f990dSAntoine Brodin size_t len; 164ee9f4661SAlexander Kabaev 16513774e82SConrad Meyer len = MIN(req->oldlen, sizeof(buf)); 16613774e82SConrad Meyer read_random(buf, len); 167370f990dSAntoine Brodin return (SYSCTL_OUT(req, buf, len)); 168ee9f4661SAlexander Kabaev } 169ee9f4661SAlexander Kabaev 170f3b86a5fSEd Schouten SYSCTL_PROC(_kern, KERN_ARND, arandom, 171ff66f6a4SRobert Watson CTLTYPE_OPAQUE | CTLFLAG_RD | CTLFLAG_MPSAFE | CTLFLAG_CAPRD, NULL, 0, 172f3b86a5fSEd Schouten sysctl_kern_arnd, "", "arc4rand"); 173ee9f4661SAlexander Kabaev 174ee9f4661SAlexander Kabaev static int 1750fca57b8SThomas Moestl sysctl_hw_physmem(SYSCTL_HANDLER_ARGS) 1760fca57b8SThomas Moestl { 1777a6322e1SKonstantin Belousov u_long val, p; 1780fca57b8SThomas Moestl 1797a6322e1SKonstantin Belousov p = SIZE_T_MAX >> PAGE_SHIFT; 1807a6322e1SKonstantin Belousov if (physmem < p) 1817a6322e1SKonstantin Belousov p = physmem; 1827a6322e1SKonstantin Belousov val = ctob(p); 1830fca57b8SThomas Moestl return (sysctl_handle_long(oidp, &val, 0, req)); 1840fca57b8SThomas Moestl } 185*7029da5cSPawel Biernacki SYSCTL_PROC(_hw, HW_PHYSMEM, physmem, 186*7029da5cSPawel Biernacki CTLTYPE_ULONG | CTLFLAG_RD | CTLFLAG_MPSAFE, 0, 0, 187*7029da5cSPawel Biernacki sysctl_hw_physmem, "LU", 188557e162fSRavi Pokala "Amount of physical memory (in bytes)"); 1890fca57b8SThomas Moestl 1900fca57b8SThomas Moestl static int 191a0915044SWes Peters sysctl_hw_realmem(SYSCTL_HANDLER_ARGS) 192a0915044SWes Peters { 1937a6322e1SKonstantin Belousov u_long val, p; 1947a6322e1SKonstantin Belousov 1957a6322e1SKonstantin Belousov p = SIZE_T_MAX >> PAGE_SHIFT; 1967a6322e1SKonstantin Belousov if (realmem < p) 1977a6322e1SKonstantin Belousov p = realmem; 1987a6322e1SKonstantin Belousov val = ctob(p); 199a0915044SWes Peters return (sysctl_handle_long(oidp, &val, 0, req)); 200a0915044SWes Peters } 201*7029da5cSPawel Biernacki SYSCTL_PROC(_hw, HW_REALMEM, realmem, 202*7029da5cSPawel Biernacki CTLTYPE_ULONG | CTLFLAG_RD | CTLFLAG_MPSAFE, 0, 0, 203*7029da5cSPawel Biernacki sysctl_hw_realmem, "LU", 204557e162fSRavi Pokala "Amount of memory (in bytes) reported by the firmware"); 2057a6322e1SKonstantin Belousov 206a0915044SWes Peters static int 2070fca57b8SThomas Moestl sysctl_hw_usermem(SYSCTL_HANDLER_ARGS) 2080fca57b8SThomas Moestl { 2097a6322e1SKonstantin Belousov u_long val, p, p1; 2100fca57b8SThomas Moestl 2117a6322e1SKonstantin Belousov p1 = physmem - vm_wire_count(); 2127a6322e1SKonstantin Belousov p = SIZE_T_MAX >> PAGE_SHIFT; 2137a6322e1SKonstantin Belousov if (p1 < p) 2147a6322e1SKonstantin Belousov p = p1; 2157a6322e1SKonstantin Belousov val = ctob(p); 2160fca57b8SThomas Moestl return (sysctl_handle_long(oidp, &val, 0, req)); 2170fca57b8SThomas Moestl } 218*7029da5cSPawel Biernacki SYSCTL_PROC(_hw, HW_USERMEM, usermem, 219*7029da5cSPawel Biernacki CTLTYPE_ULONG | CTLFLAG_RD | CTLFLAG_MPSAFE, 0, 0, 220*7029da5cSPawel Biernacki sysctl_hw_usermem, "LU", 221557e162fSRavi Pokala "Amount of memory (in bytes) which is not wired"); 2220fca57b8SThomas Moestl 223557e162fSRavi Pokala SYSCTL_LONG(_hw, OID_AUTO, availpages, CTLFLAG_RD, &physmem, 0, 224557e162fSRavi Pokala "Amount of physical memory (in pages)"); 2250fca57b8SThomas Moestl 226fe105d45SAlan Cox u_long pagesizes[MAXPAGESIZES] = { PAGE_SIZE }; 227fe105d45SAlan Cox 228fe105d45SAlan Cox static int 229fe105d45SAlan Cox sysctl_hw_pagesizes(SYSCTL_HANDLER_ARGS) 230fe105d45SAlan Cox { 231fe105d45SAlan Cox int error; 232fe105d45SAlan Cox #ifdef SCTL_MASK32 233fe105d45SAlan Cox int i; 234fe105d45SAlan Cox uint32_t pagesizes32[MAXPAGESIZES]; 235fe105d45SAlan Cox 236fe105d45SAlan Cox if (req->flags & SCTL_MASK32) { 237fe105d45SAlan Cox /* 238fe105d45SAlan Cox * Recreate the "pagesizes" array with 32-bit elements. Truncate 239fe105d45SAlan Cox * any page size greater than UINT32_MAX to zero. 240fe105d45SAlan Cox */ 241fe105d45SAlan Cox for (i = 0; i < MAXPAGESIZES; i++) 242fe105d45SAlan Cox pagesizes32[i] = (uint32_t)pagesizes[i]; 243fe105d45SAlan Cox 244fe105d45SAlan Cox error = SYSCTL_OUT(req, pagesizes32, sizeof(pagesizes32)); 245fe105d45SAlan Cox } else 246fe105d45SAlan Cox #endif 247fe105d45SAlan Cox error = SYSCTL_OUT(req, pagesizes, sizeof(pagesizes)); 248fe105d45SAlan Cox return (error); 249fe105d45SAlan Cox } 250*7029da5cSPawel Biernacki SYSCTL_PROC(_hw, OID_AUTO, pagesizes, 251*7029da5cSPawel Biernacki CTLTYPE_ULONG | CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, 0, 252*7029da5cSPawel Biernacki sysctl_hw_pagesizes, "LU", 253*7029da5cSPawel Biernacki "Supported page sizes"); 254fe105d45SAlan Cox 25587d45a03SKonstantin Belousov #ifdef SCTL_MASK32 25687d45a03SKonstantin Belousov int adaptive_machine_arch = 1; 25787d45a03SKonstantin Belousov SYSCTL_INT(_debug, OID_AUTO, adaptive_machine_arch, CTLFLAG_RW, 25887d45a03SKonstantin Belousov &adaptive_machine_arch, 1, 25987d45a03SKonstantin Belousov "Adapt reported machine architecture to the ABI of the binary"); 26087d45a03SKonstantin Belousov #endif 26187d45a03SKonstantin Belousov 26287d45a03SKonstantin Belousov static int 26387d45a03SKonstantin Belousov sysctl_hw_machine_arch(SYSCTL_HANDLER_ARGS) 26487d45a03SKonstantin Belousov { 26587d45a03SKonstantin Belousov int error; 26687d45a03SKonstantin Belousov static const char machine_arch[] = MACHINE_ARCH; 26787d45a03SKonstantin Belousov #ifdef SCTL_MASK32 26887d45a03SKonstantin Belousov static const char machine_arch32[] = MACHINE_ARCH32; 26987d45a03SKonstantin Belousov 27087d45a03SKonstantin Belousov if ((req->flags & SCTL_MASK32) != 0 && adaptive_machine_arch) 27187d45a03SKonstantin Belousov error = SYSCTL_OUT(req, machine_arch32, sizeof(machine_arch32)); 27287d45a03SKonstantin Belousov else 27387d45a03SKonstantin Belousov #endif 27487d45a03SKonstantin Belousov error = SYSCTL_OUT(req, machine_arch, sizeof(machine_arch)); 27587d45a03SKonstantin Belousov return (error); 27687d45a03SKonstantin Belousov 27787d45a03SKonstantin Belousov } 27853dc58f2SMateusz Guzik SYSCTL_PROC(_hw, HW_MACHINE_ARCH, machine_arch, CTLTYPE_STRING | CTLFLAG_RD | 27953dc58f2SMateusz Guzik CTLFLAG_MPSAFE, NULL, 0, sysctl_hw_machine_arch, "A", 28053dc58f2SMateusz Guzik "System architecture"); 281664f8517SKATO Takenori 282fec27435SNathan Whitehorn SYSCTL_STRING(_kern, OID_AUTO, supported_archs, CTLFLAG_RD | CTLFLAG_MPSAFE, 2833cb6654dSNathan Whitehorn #ifdef COMPAT_FREEBSD32 284fec27435SNathan Whitehorn MACHINE_ARCH " " MACHINE_ARCH32, 0, "Supported architectures for binaries"); 2853cb6654dSNathan Whitehorn #else 286fec27435SNathan Whitehorn MACHINE_ARCH, 0, "Supported architectures for binaries"); 2873cb6654dSNathan Whitehorn #endif 2883cb6654dSNathan Whitehorn 28975c13541SPoul-Henning Kamp static int 29082d9ae4eSPoul-Henning Kamp sysctl_hostname(SYSCTL_HANDLER_ARGS) 29175c13541SPoul-Henning Kamp { 29276ca6f88SJamie Gritton struct prison *pr, *cpr; 29376ca6f88SJamie Gritton size_t pr_offset; 29476ca6f88SJamie Gritton char tmpname[MAXHOSTNAMELEN]; 29576ca6f88SJamie Gritton int descend, error, len; 29676ca6f88SJamie Gritton 29776ca6f88SJamie Gritton /* 29876ca6f88SJamie Gritton * This function can set: hostname domainname hostuuid. 29976ca6f88SJamie Gritton * Keep that in mind when comments say "hostname". 30076ca6f88SJamie Gritton */ 30176ca6f88SJamie Gritton pr_offset = (size_t)arg1; 30276ca6f88SJamie Gritton len = arg2; 30376ca6f88SJamie Gritton KASSERT(len <= sizeof(tmpname), 30476ca6f88SJamie Gritton ("length %d too long for %s", len, __func__)); 30575c13541SPoul-Henning Kamp 306a854ed98SJohn Baldwin pr = req->td->td_ucred->cr_prison; 3070304c731SJamie Gritton if (!(pr->pr_allow & PR_ALLOW_SET_HOSTNAME) && req->newptr) 3086c144e75SRobert Watson return (EPERM); 30901137630SRobert Watson /* 31076ca6f88SJamie Gritton * Make a local copy of hostname to get/set so we don't have to hold 31176ca6f88SJamie Gritton * the jail mutex during the sysctl copyin/copyout activities. 31201137630SRobert Watson */ 31301137630SRobert Watson mtx_lock(&pr->pr_mtx); 31476ca6f88SJamie Gritton bcopy((char *)pr + pr_offset, tmpname, len); 31501137630SRobert Watson mtx_unlock(&pr->pr_mtx); 31601137630SRobert Watson 31776ca6f88SJamie Gritton error = sysctl_handle_string(oidp, tmpname, len, req); 31801137630SRobert Watson 31901137630SRobert Watson if (req->newptr != NULL && error == 0) { 32001137630SRobert Watson /* 32176ca6f88SJamie Gritton * Copy the locally set hostname to all jails that share 32276ca6f88SJamie Gritton * this host info. 32301137630SRobert Watson */ 32476ca6f88SJamie Gritton sx_slock(&allprison_lock); 32576ca6f88SJamie Gritton while (!(pr->pr_flags & PR_HOST)) 32676ca6f88SJamie Gritton pr = pr->pr_parent; 32701137630SRobert Watson mtx_lock(&pr->pr_mtx); 32876ca6f88SJamie Gritton bcopy(tmpname, (char *)pr + pr_offset, len); 32976ca6f88SJamie Gritton FOREACH_PRISON_DESCENDANT_LOCKED(pr, cpr, descend) 33076ca6f88SJamie Gritton if (cpr->pr_flags & PR_HOST) 33176ca6f88SJamie Gritton descend = 0; 33276ca6f88SJamie Gritton else 33376ca6f88SJamie Gritton bcopy(tmpname, (char *)cpr + pr_offset, len); 33401137630SRobert Watson mtx_unlock(&pr->pr_mtx); 33576ca6f88SJamie Gritton sx_sunlock(&allprison_lock); 3364f7d1876SRobert Watson } 33775c13541SPoul-Henning Kamp return (error); 33875c13541SPoul-Henning Kamp } 33975c13541SPoul-Henning Kamp 34075c13541SPoul-Henning Kamp SYSCTL_PROC(_kern, KERN_HOSTNAME, hostname, 3410176ca2eSAllan Jude CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_PRISON | CTLFLAG_CAPRD | CTLFLAG_MPSAFE, 342c1f19219SJamie Gritton (void *)(offsetof(struct prison, pr_hostname)), MAXHOSTNAMELEN, 34376ca6f88SJamie Gritton sysctl_hostname, "A", "Hostname"); 34476ca6f88SJamie Gritton SYSCTL_PROC(_kern, KERN_NISDOMAINNAME, domainname, 3450176ca2eSAllan Jude CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_PRISON | CTLFLAG_CAPRD | CTLFLAG_MPSAFE, 346c1f19219SJamie Gritton (void *)(offsetof(struct prison, pr_domainname)), MAXHOSTNAMELEN, 34776ca6f88SJamie Gritton sysctl_hostname, "A", "Name of the current YP/NIS domain"); 34876ca6f88SJamie Gritton SYSCTL_PROC(_kern, KERN_HOSTUUID, hostuuid, 3490176ca2eSAllan Jude CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_PRISON | CTLFLAG_CAPRD | CTLFLAG_MPSAFE, 350c1f19219SJamie Gritton (void *)(offsetof(struct prison, pr_hostuuid)), HOSTUUIDLEN, 35176ca6f88SJamie Gritton sysctl_hostname, "A", "Host UUID"); 35245ec3b38SPoul-Henning Kamp 353eacb362fSRobert Watson static int regression_securelevel_nonmonotonic = 0; 354c175d222SRobert Watson 3551e4b531bSRobert Watson #ifdef REGRESSION 356c175d222SRobert Watson SYSCTL_INT(_regression, OID_AUTO, securelevel_nonmonotonic, CTLFLAG_RW, 357c175d222SRobert Watson ®ression_securelevel_nonmonotonic, 0, "securelevel may be lowered"); 358eacb362fSRobert Watson #endif 359c175d222SRobert Watson 36045ec3b38SPoul-Henning Kamp static int 36182d9ae4eSPoul-Henning Kamp sysctl_kern_securelvl(SYSCTL_HANDLER_ARGS) 36245ec3b38SPoul-Henning Kamp { 3630304c731SJamie Gritton struct prison *pr, *cpr; 3640304c731SJamie Gritton int descend, error, level; 36545ec3b38SPoul-Henning Kamp 366a854ed98SJohn Baldwin pr = req->td->td_ucred->cr_prison; 367d3c9fa04SRobert Watson 3688a528812SRobert Watson /* 3690304c731SJamie Gritton * Reading the securelevel is easy, since the current jail's level 3700304c731SJamie Gritton * is known to be at least as secure as any higher levels. Perform 3710304c731SJamie Gritton * a lockless read since the securelevel is an integer. 3728a528812SRobert Watson */ 3730304c731SJamie Gritton level = pr->pr_securelevel; 37445ec3b38SPoul-Henning Kamp error = sysctl_handle_int(oidp, &level, 0, req); 37545ec3b38SPoul-Henning Kamp if (error || !req->newptr) 37645ec3b38SPoul-Henning Kamp return (error); 3770304c731SJamie Gritton /* Permit update only if the new securelevel exceeds the old. */ 3780304c731SJamie Gritton sx_slock(&allprison_lock); 37901137630SRobert Watson mtx_lock(&pr->pr_mtx); 3801e4b531bSRobert Watson if (!regression_securelevel_nonmonotonic && 3810304c731SJamie Gritton level < pr->pr_securelevel) { 38201137630SRobert Watson mtx_unlock(&pr->pr_mtx); 3830304c731SJamie Gritton sx_sunlock(&allprison_lock); 3848a528812SRobert Watson return (EPERM); 38501137630SRobert Watson } 386d3c9fa04SRobert Watson pr->pr_securelevel = level; 3870304c731SJamie Gritton /* 3880304c731SJamie Gritton * Set all child jails to be at least this level, but do not lower 3890304c731SJamie Gritton * them (even if regression_securelevel_nonmonotonic). 3900304c731SJamie Gritton */ 3910304c731SJamie Gritton FOREACH_PRISON_DESCENDANT_LOCKED(pr, cpr, descend) { 3920304c731SJamie Gritton if (cpr->pr_securelevel < level) 3930304c731SJamie Gritton cpr->pr_securelevel = level; 3940304c731SJamie Gritton } 39501137630SRobert Watson mtx_unlock(&pr->pr_mtx); 3960304c731SJamie Gritton sx_sunlock(&allprison_lock); 39745ec3b38SPoul-Henning Kamp return (error); 39845ec3b38SPoul-Henning Kamp } 39945ec3b38SPoul-Henning Kamp 4008a528812SRobert Watson SYSCTL_PROC(_kern, KERN_SECURELVL, securelevel, 401*7029da5cSPawel Biernacki CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_PRISON | CTLFLAG_MPSAFE, 0, 0, 402*7029da5cSPawel Biernacki sysctl_kern_securelvl, "I", 403*7029da5cSPawel Biernacki "Current secure level"); 404e812e491SRobert Watson 4055f9974aeSWojciech A. Koszek #ifdef INCLUDE_CONFIG_FILE 406744b947eSWojciech A. Koszek /* Actual kernel configuration options. */ 407744b947eSWojciech A. Koszek extern char kernconfstring[]; 408744b947eSWojciech A. Koszek 40953dc58f2SMateusz Guzik SYSCTL_STRING(_kern, OID_AUTO, conftxt, CTLFLAG_RD | CTLFLAG_MPSAFE, 41053dc58f2SMateusz Guzik kernconfstring, 0, "Kernel configuration file"); 4113627f737SWarner Losh #endif 412744b947eSWojciech A. Koszek 4134f7d1876SRobert Watson static int 41476ca6f88SJamie Gritton sysctl_hostid(SYSCTL_HANDLER_ARGS) 4154f7d1876SRobert Watson { 41676ca6f88SJamie Gritton struct prison *pr, *cpr; 41776ca6f88SJamie Gritton u_long tmpid; 41876ca6f88SJamie Gritton int descend, error; 4194f7d1876SRobert Watson 42076ca6f88SJamie Gritton /* 42176ca6f88SJamie Gritton * Like sysctl_hostname, except it operates on a u_long 42276ca6f88SJamie Gritton * instead of a string, and is used only for hostid. 42376ca6f88SJamie Gritton */ 42476ca6f88SJamie Gritton pr = req->td->td_ucred->cr_prison; 42576ca6f88SJamie Gritton if (!(pr->pr_allow & PR_ALLOW_SET_HOSTNAME) && req->newptr) 42676ca6f88SJamie Gritton return (EPERM); 42776ca6f88SJamie Gritton tmpid = pr->pr_hostid; 42876ca6f88SJamie Gritton error = sysctl_handle_long(oidp, &tmpid, 0, req); 42976ca6f88SJamie Gritton 4304f7d1876SRobert Watson if (req->newptr != NULL && error == 0) { 43176ca6f88SJamie Gritton sx_slock(&allprison_lock); 43276ca6f88SJamie Gritton while (!(pr->pr_flags & PR_HOST)) 43376ca6f88SJamie Gritton pr = pr->pr_parent; 43476ca6f88SJamie Gritton mtx_lock(&pr->pr_mtx); 43576ca6f88SJamie Gritton pr->pr_hostid = tmpid; 43676ca6f88SJamie Gritton FOREACH_PRISON_DESCENDANT_LOCKED(pr, cpr, descend) 43776ca6f88SJamie Gritton if (cpr->pr_flags & PR_HOST) 43876ca6f88SJamie Gritton descend = 0; 43976ca6f88SJamie Gritton else 44076ca6f88SJamie Gritton cpr->pr_hostid = tmpid; 44176ca6f88SJamie Gritton mtx_unlock(&pr->pr_mtx); 44276ca6f88SJamie Gritton sx_sunlock(&allprison_lock); 4434f7d1876SRobert Watson } 4444f7d1876SRobert Watson return (error); 4454f7d1876SRobert Watson } 4464f7d1876SRobert Watson 44776ca6f88SJamie Gritton SYSCTL_PROC(_kern, KERN_HOSTID, hostid, 448200241b5SBryan Drewery CTLTYPE_ULONG | CTLFLAG_RW | CTLFLAG_PRISON | CTLFLAG_MPSAFE | CTLFLAG_CAPRD, 44976ca6f88SJamie Gritton NULL, 0, sysctl_hostid, "LU", "Host ID"); 45045ec3b38SPoul-Henning Kamp 451b96bd95bSIan Lepore /* 452b96bd95bSIan Lepore * The osrelease string is copied from the global (osrelease in vers.c) into 453b96bd95bSIan Lepore * prison0 by a sysinit and is inherited by child jails if not changed at jail 454b96bd95bSIan Lepore * creation, so we always return the copy from the current prison data. 455b96bd95bSIan Lepore */ 456b96bd95bSIan Lepore static int 457b96bd95bSIan Lepore sysctl_osrelease(SYSCTL_HANDLER_ARGS) 458b96bd95bSIan Lepore { 459b96bd95bSIan Lepore struct prison *pr; 460b96bd95bSIan Lepore 461b96bd95bSIan Lepore pr = req->td->td_ucred->cr_prison; 462b96bd95bSIan Lepore return (SYSCTL_OUT(req, pr->pr_osrelease, strlen(pr->pr_osrelease) + 1)); 463b96bd95bSIan Lepore 464b96bd95bSIan Lepore } 465b96bd95bSIan Lepore 466b96bd95bSIan Lepore SYSCTL_PROC(_kern, KERN_OSRELEASE, osrelease, 467b96bd95bSIan Lepore CTLTYPE_STRING | CTLFLAG_CAPRD | CTLFLAG_RD | CTLFLAG_MPSAFE, 468b96bd95bSIan Lepore NULL, 0, sysctl_osrelease, "A", "Operating system release"); 469b96bd95bSIan Lepore 470b96bd95bSIan Lepore /* 471b96bd95bSIan Lepore * The osreldate number is copied from the global (osreldate in vers.c) into 472b96bd95bSIan Lepore * prison0 by a sysinit and is inherited by child jails if not changed at jail 473b96bd95bSIan Lepore * creation, so we always return the value from the current prison data. 474b96bd95bSIan Lepore */ 475b96bd95bSIan Lepore static int 476b96bd95bSIan Lepore sysctl_osreldate(SYSCTL_HANDLER_ARGS) 477b96bd95bSIan Lepore { 478b96bd95bSIan Lepore struct prison *pr; 479b96bd95bSIan Lepore 480b96bd95bSIan Lepore pr = req->td->td_ucred->cr_prison; 481b96bd95bSIan Lepore return (SYSCTL_OUT(req, &pr->pr_osreldate, sizeof(pr->pr_osreldate))); 482b96bd95bSIan Lepore 483b96bd95bSIan Lepore } 484b96bd95bSIan Lepore 485b96bd95bSIan Lepore /* 486b96bd95bSIan Lepore * NOTICE: The *userland* release date is available in 487b96bd95bSIan Lepore * /usr/include/osreldate.h 488b96bd95bSIan Lepore */ 489b96bd95bSIan Lepore SYSCTL_PROC(_kern, KERN_OSRELDATE, osreldate, 490b96bd95bSIan Lepore CTLTYPE_INT | CTLFLAG_CAPRD | CTLFLAG_RD | CTLFLAG_MPSAFE, 491b96bd95bSIan Lepore NULL, 0, sysctl_osreldate, "I", "Kernel release date"); 492b96bd95bSIan Lepore 49374cd06b4SEd Maste /* 49474cd06b4SEd Maste * The build-id is copied from the ELF section .note.gnu.build-id. The linker 49574cd06b4SEd Maste * script defines two variables to expose the beginning and end. LLVM 49674cd06b4SEd Maste * currently uses a SHA-1 hash, but other formats can be supported by checking 49774cd06b4SEd Maste * the length of the section. 49874cd06b4SEd Maste */ 49974cd06b4SEd Maste 50074cd06b4SEd Maste extern char __build_id_start[]; 50174cd06b4SEd Maste extern char __build_id_end[]; 50274cd06b4SEd Maste 50374cd06b4SEd Maste #define BUILD_ID_HEADER_LEN 0x10 50474cd06b4SEd Maste #define BUILD_ID_HASH_MAXLEN 0x14 50574cd06b4SEd Maste 50674cd06b4SEd Maste static int 50774cd06b4SEd Maste sysctl_build_id(SYSCTL_HANDLER_ARGS) 50874cd06b4SEd Maste { 50974cd06b4SEd Maste uintptr_t sectionlen = (uintptr_t)(__build_id_end - __build_id_start); 51074cd06b4SEd Maste int hashlen; 51174cd06b4SEd Maste char buf[2*BUILD_ID_HASH_MAXLEN+1]; 51274cd06b4SEd Maste 51374cd06b4SEd Maste /* 51474cd06b4SEd Maste * The ELF note section has a four byte length for the vendor name, 51574cd06b4SEd Maste * four byte length for the value, and a four byte vendor specific 51674cd06b4SEd Maste * type. The name for the build id is "GNU\0". We skip the first 16 51774cd06b4SEd Maste * bytes to read the build hash. We will return the remaining bytes up 51874cd06b4SEd Maste * to 20 (SHA-1) hash size. If the hash happens to be a custom number 51974cd06b4SEd Maste * of bytes we will pad the value with zeros, as the section should be 52074cd06b4SEd Maste * four byte aligned. 52174cd06b4SEd Maste */ 52274cd06b4SEd Maste if (sectionlen <= BUILD_ID_HEADER_LEN || 52374cd06b4SEd Maste sectionlen > (BUILD_ID_HEADER_LEN + BUILD_ID_HASH_MAXLEN)) { 52474cd06b4SEd Maste return (ENOENT); 52574cd06b4SEd Maste } 52674cd06b4SEd Maste 52774cd06b4SEd Maste hashlen = sectionlen - BUILD_ID_HEADER_LEN; 52874cd06b4SEd Maste for (int i = 0; i < hashlen; i++) { 52974cd06b4SEd Maste uint8_t c = __build_id_start[i+BUILD_ID_HEADER_LEN]; 53074cd06b4SEd Maste snprintf(&buf[2*i], 3, "%02x", c); 53174cd06b4SEd Maste } 53274cd06b4SEd Maste 53374cd06b4SEd Maste return (SYSCTL_OUT(req, buf, strlen(buf) + 1)); 53474cd06b4SEd Maste } 53574cd06b4SEd Maste 53674cd06b4SEd Maste SYSCTL_PROC(_kern, OID_AUTO, build_id, 53774cd06b4SEd Maste CTLTYPE_STRING | CTLFLAG_CAPRD | CTLFLAG_RD | CTLFLAG_MPSAFE, 53874cd06b4SEd Maste NULL, 0, sysctl_build_id, "A", "Operating system build-id"); 53974cd06b4SEd Maste 540*7029da5cSPawel Biernacki SYSCTL_NODE(_kern, OID_AUTO, features, CTLFLAG_RD | CTLFLAG_MPSAFE, 0, 541*7029da5cSPawel Biernacki "Kernel Features"); 5420deabe7eSJohn Baldwin 5432c179010SJohn Baldwin #ifdef COMPAT_FREEBSD4 5442c179010SJohn Baldwin FEATURE(compat_freebsd4, "Compatible with FreeBSD 4"); 5452c179010SJohn Baldwin #endif 5462c179010SJohn Baldwin 5472c179010SJohn Baldwin #ifdef COMPAT_FREEBSD5 5482c179010SJohn Baldwin FEATURE(compat_freebsd5, "Compatible with FreeBSD 5"); 5492c179010SJohn Baldwin #endif 5502c179010SJohn Baldwin 5512c179010SJohn Baldwin #ifdef COMPAT_FREEBSD6 5522c179010SJohn Baldwin FEATURE(compat_freebsd6, "Compatible with FreeBSD 6"); 5532c179010SJohn Baldwin #endif 5542c179010SJohn Baldwin 5552c179010SJohn Baldwin #ifdef COMPAT_FREEBSD7 5562c179010SJohn Baldwin FEATURE(compat_freebsd7, "Compatible with FreeBSD 7"); 5572c179010SJohn Baldwin #endif 5582c179010SJohn Baldwin 55945ec3b38SPoul-Henning Kamp /* 56045ec3b38SPoul-Henning Kamp * This is really cheating. These actually live in the libc, something 56145ec3b38SPoul-Henning Kamp * which I'm not quite sure is a good idea anyway, but in order for 56245ec3b38SPoul-Henning Kamp * getnext and friends to actually work, we define dummies here. 563ff66f6a4SRobert Watson * 564ff66f6a4SRobert Watson * XXXRW: These probably should be CTLFLAG_CAPRD. 56545ec3b38SPoul-Henning Kamp */ 5663d177f46SBill Fumerola SYSCTL_STRING(_user, USER_CS_PATH, cs_path, CTLFLAG_RD, 5673d177f46SBill Fumerola "", 0, "PATH that finds all the standard utilities"); 5683d177f46SBill Fumerola SYSCTL_INT(_user, USER_BC_BASE_MAX, bc_base_max, CTLFLAG_RD, 569f0188618SHans Petter Selasky SYSCTL_NULL_INT_PTR, 0, "Max ibase/obase values in bc(1)"); 5703d177f46SBill Fumerola SYSCTL_INT(_user, USER_BC_DIM_MAX, bc_dim_max, CTLFLAG_RD, 571f0188618SHans Petter Selasky SYSCTL_NULL_INT_PTR, 0, "Max array size in bc(1)"); 5723d177f46SBill Fumerola SYSCTL_INT(_user, USER_BC_SCALE_MAX, bc_scale_max, CTLFLAG_RD, 573f0188618SHans Petter Selasky SYSCTL_NULL_INT_PTR, 0, "Max scale value in bc(1)"); 5743d177f46SBill Fumerola SYSCTL_INT(_user, USER_BC_STRING_MAX, bc_string_max, CTLFLAG_RD, 575f0188618SHans Petter Selasky SYSCTL_NULL_INT_PTR, 0, "Max string length in bc(1)"); 5763d177f46SBill Fumerola SYSCTL_INT(_user, USER_COLL_WEIGHTS_MAX, coll_weights_max, CTLFLAG_RD, 577f0188618SHans Petter Selasky SYSCTL_NULL_INT_PTR, 0, "Maximum number of weights assigned to an LC_COLLATE locale entry"); 578f0188618SHans Petter Selasky SYSCTL_INT(_user, USER_EXPR_NEST_MAX, expr_nest_max, CTLFLAG_RD, 579f0188618SHans Petter Selasky SYSCTL_NULL_INT_PTR, 0, ""); 5803d177f46SBill Fumerola SYSCTL_INT(_user, USER_LINE_MAX, line_max, CTLFLAG_RD, 581f0188618SHans Petter Selasky SYSCTL_NULL_INT_PTR, 0, "Max length (bytes) of a text-processing utility's input line"); 5823d177f46SBill Fumerola SYSCTL_INT(_user, USER_RE_DUP_MAX, re_dup_max, CTLFLAG_RD, 583f0188618SHans Petter Selasky SYSCTL_NULL_INT_PTR, 0, "Maximum number of repeats of a regexp permitted"); 5843d177f46SBill Fumerola SYSCTL_INT(_user, USER_POSIX2_VERSION, posix2_version, CTLFLAG_RD, 585f0188618SHans Petter Selasky SYSCTL_NULL_INT_PTR, 0, 5863d177f46SBill Fumerola "The version of POSIX 1003.2 with which the system attempts to comply"); 5873d177f46SBill Fumerola SYSCTL_INT(_user, USER_POSIX2_C_BIND, posix2_c_bind, CTLFLAG_RD, 588f0188618SHans Petter Selasky SYSCTL_NULL_INT_PTR, 0, "Whether C development supports the C bindings option"); 5893d177f46SBill Fumerola SYSCTL_INT(_user, USER_POSIX2_C_DEV, posix2_c_dev, CTLFLAG_RD, 590f0188618SHans Petter Selasky SYSCTL_NULL_INT_PTR, 0, "Whether system supports the C development utilities option"); 5913d177f46SBill Fumerola SYSCTL_INT(_user, USER_POSIX2_CHAR_TERM, posix2_char_term, CTLFLAG_RD, 592f0188618SHans Petter Selasky SYSCTL_NULL_INT_PTR, 0, ""); 5933d177f46SBill Fumerola SYSCTL_INT(_user, USER_POSIX2_FORT_DEV, posix2_fort_dev, CTLFLAG_RD, 594f0188618SHans Petter Selasky SYSCTL_NULL_INT_PTR, 0, "Whether system supports FORTRAN development utilities"); 5953d177f46SBill Fumerola SYSCTL_INT(_user, USER_POSIX2_FORT_RUN, posix2_fort_run, CTLFLAG_RD, 596f0188618SHans Petter Selasky SYSCTL_NULL_INT_PTR, 0, "Whether system supports FORTRAN runtime utilities"); 5973d177f46SBill Fumerola SYSCTL_INT(_user, USER_POSIX2_LOCALEDEF, posix2_localedef, CTLFLAG_RD, 598f0188618SHans Petter Selasky SYSCTL_NULL_INT_PTR, 0, "Whether system supports creation of locales"); 5993d177f46SBill Fumerola SYSCTL_INT(_user, USER_POSIX2_SW_DEV, posix2_sw_dev, CTLFLAG_RD, 600f0188618SHans Petter Selasky SYSCTL_NULL_INT_PTR, 0, "Whether system supports software development utilities"); 6013d177f46SBill Fumerola SYSCTL_INT(_user, USER_POSIX2_UPE, posix2_upe, CTLFLAG_RD, 602f0188618SHans Petter Selasky SYSCTL_NULL_INT_PTR, 0, "Whether system supports the user portability utilities"); 6033d177f46SBill Fumerola SYSCTL_INT(_user, USER_STREAM_MAX, stream_max, CTLFLAG_RD, 604f0188618SHans Petter Selasky SYSCTL_NULL_INT_PTR, 0, "Min Maximum number of streams a process may have open at one time"); 6053d177f46SBill Fumerola SYSCTL_INT(_user, USER_TZNAME_MAX, tzname_max, CTLFLAG_RD, 606f0188618SHans Petter Selasky SYSCTL_NULL_INT_PTR, 0, "Min Maximum number of types supported for timezone names"); 6076f13bfc2SPoul-Henning Kamp 6086f13bfc2SPoul-Henning Kamp #include <sys/vnode.h> 6096f13bfc2SPoul-Henning Kamp SYSCTL_INT(_debug_sizeof, OID_AUTO, vnode, CTLFLAG_RD, 610f0188618SHans Petter Selasky SYSCTL_NULL_INT_PTR, sizeof(struct vnode), "sizeof(struct vnode)"); 6116f13bfc2SPoul-Henning Kamp 6126f13bfc2SPoul-Henning Kamp SYSCTL_INT(_debug_sizeof, OID_AUTO, proc, CTLFLAG_RD, 613f0188618SHans Petter Selasky SYSCTL_NULL_INT_PTR, sizeof(struct proc), "sizeof(struct proc)"); 614d7bf417dSPoul-Henning Kamp 61502c6fc21SKonstantin Belousov static int 61602c6fc21SKonstantin Belousov sysctl_kern_pid_max(SYSCTL_HANDLER_ARGS) 61702c6fc21SKonstantin Belousov { 61802c6fc21SKonstantin Belousov int error, pm; 61902c6fc21SKonstantin Belousov 62002c6fc21SKonstantin Belousov pm = pid_max; 62102c6fc21SKonstantin Belousov error = sysctl_handle_int(oidp, &pm, 0, req); 62202c6fc21SKonstantin Belousov if (error || !req->newptr) 62302c6fc21SKonstantin Belousov return (error); 62402c6fc21SKonstantin Belousov sx_xlock(&proctree_lock); 62502c6fc21SKonstantin Belousov sx_xlock(&allproc_lock); 6263fa615bcSKonstantin Belousov 6273fa615bcSKonstantin Belousov /* 6283fa615bcSKonstantin Belousov * Only permit the values less then PID_MAX. 6293fa615bcSKonstantin Belousov * As a safety measure, do not allow to limit the pid_max too much. 6303fa615bcSKonstantin Belousov */ 6313fa615bcSKonstantin Belousov if (pm < 300 || pm > PID_MAX) 63202c6fc21SKonstantin Belousov error = EINVAL; 63302c6fc21SKonstantin Belousov else 63402c6fc21SKonstantin Belousov pid_max = pm; 63502c6fc21SKonstantin Belousov sx_xunlock(&allproc_lock); 63602c6fc21SKonstantin Belousov sx_xunlock(&proctree_lock); 63702c6fc21SKonstantin Belousov return (error); 63802c6fc21SKonstantin Belousov } 639af3b2549SHans Petter Selasky SYSCTL_PROC(_kern, OID_AUTO, pid_max, CTLTYPE_INT | 640af3b2549SHans Petter Selasky CTLFLAG_RWTUN | CTLFLAG_NOFETCH | CTLFLAG_MPSAFE, 641af3b2549SHans Petter Selasky 0, 0, sysctl_kern_pid_max, "I", "Maximum allowed pid"); 64202c6fc21SKonstantin Belousov 6439626b608SPoul-Henning Kamp #include <sys/bio.h> 6448c125869SPoul-Henning Kamp #include <sys/buf.h> 6458c125869SPoul-Henning Kamp SYSCTL_INT(_debug_sizeof, OID_AUTO, bio, CTLFLAG_RD, 646f0188618SHans Petter Selasky SYSCTL_NULL_INT_PTR, sizeof(struct bio), "sizeof(struct bio)"); 6478c125869SPoul-Henning Kamp SYSCTL_INT(_debug_sizeof, OID_AUTO, buf, CTLFLAG_RD, 648f0188618SHans Petter Selasky SYSCTL_NULL_INT_PTR, sizeof(struct buf), "sizeof(struct buf)"); 649d5a08a60SJake Burkholder 650d5a08a60SJake Burkholder #include <sys/user.h> 651d5a08a60SJake Burkholder SYSCTL_INT(_debug_sizeof, OID_AUTO, kinfo_proc, CTLFLAG_RD, 652f0188618SHans Petter Selasky SYSCTL_NULL_INT_PTR, sizeof(struct kinfo_proc), "sizeof(struct kinfo_proc)"); 653a360a43dSJake Burkholder 654645743eaSJohn Baldwin /* Used by kernel debuggers. */ 655645743eaSJohn Baldwin const int pcb_size = sizeof(struct pcb); 656645743eaSJohn Baldwin SYSCTL_INT(_debug_sizeof, OID_AUTO, pcb, CTLFLAG_RD, 657645743eaSJohn Baldwin SYSCTL_NULL_INT_PTR, sizeof(struct pcb), "sizeof(struct pcb)"); 658645743eaSJohn Baldwin 659e548a1d4SJake Burkholder /* XXX compatibility, remove for 6.0 */ 660e548a1d4SJake Burkholder #include <sys/imgact.h> 661e548a1d4SJake Burkholder #include <sys/imgact_elf.h> 662e548a1d4SJake Burkholder SYSCTL_INT(_kern, OID_AUTO, fallback_elf_brand, CTLFLAG_RW, 663e548a1d4SJake Burkholder &__elfN(fallback_brand), sizeof(__elfN(fallback_brand)), 664e548a1d4SJake Burkholder "compatibility for kern.fallback_elf_brand"); 665