summaryrefslogtreecommitdiff
path: root/sys/kern/kern_sysctl.c
AgeCommit message (Collapse)Author
2017-08-11Remove NET_LOCK()'s argument.Martin Pieuchot
Tested by Hrvoje Popovski, ok bluhm@
2017-06-20Do not touch file pointers for which FILE_IS_USABLE() is false.Gerhard Roth
They're might not be fully constructed. ok mpi@ deraadt@ bluhm@
2017-06-14tweak sysctl_string and sysctl_tstring to use size_t for lengths, not intDavid Gwynne
theyre both wrappers around sysctl__string, which is where half the fix is too.
2017-06-13use size_t for the size of things in memory, not int.David Gwynne
this tweaks the len argument to sysctl_rdstring, sysctl_struct, and sysctl_rdstruct. there's probably more to fix. ok millert@
2017-05-06Do not export the protocol PCB pointer from kernel to non-root usersAlexander Bluhm
also in the IPv6 case. This fixes "netstat -An -f inet6 -p tcp" and shows 0x0. report and OK dhill@
2017-04-27Enforce that sysctl kern.somaxconn and sominconn can only be setAlexander Bluhm
to valid values. The so_qlimit is type short. report Dillon Jay Pena; OK deraadt@
2017-04-05timeval has trailing padding on powerpc and m88k, so memset it beforePhilip Guenther
copyout to avoid leaking kernel stack ok deraadt@
2017-04-05Here at OpenBSD we change ABIs at the fling of a hat. Just in case aTheo de Raadt
future disk info sysctl has pads in the structures, use M_ZERO when allocating the storage to avoid leaking kernel memory.
2017-03-07Enforce that tcbtable and udbtable must be accessed with the NET_LOCK().Martin Pieuchot
Get rid of the old splnet()/splx() dances. What's protecting them right now is the KERNEL_LOCK(). but since pf(4) look at these tables we want to protect them in another way, hence the NET_LOCK(), at least as hint. ok bluhm@
2017-01-21p_comm is the process's command and isn't per thread, so move it fromPhilip Guenther
struct proc to struct process. ok deraadt@ kettenis@
2016-11-11Export p_cpuid via sysctl for all processes; ok guentherMike Belopuhov
2016-11-07Split PID from TID, giving processes a PID unrelated to the TID of theirPhilip Guenther
initial thread ok jsing@ kettenis@
2016-10-24move the mbstat structure to percpu countersDavid Gwynne
each cpus counters still have to be protected by splnet, but this is better thana single set of counters protected by a global mutex. ok bluhm@
2016-10-22Factor out pr->ps_vmspace into a local variable for fill_kproc()Philip Guenther
ok jsing@ kettenis@
2016-10-08upon further review, port numbers go all the way up to ushort maxTed Unangst
2016-10-08initialize the port variable before sysctl, since it's also read out.Ted Unangst
2016-10-07introduce a sysctl to hijack dns sockets. when set to a port number,Ted Unangst
all dns socket connections will be redirected to localhost:port. this could be a sockopt on the listening socket, but sysctl is an easier interface to work with right now. ok deraadt
2016-10-02Add va_nlink information to struct kinfo_file (so bump the shlib minor)Philip Guenther
from Sebastien Marie
2016-09-25Make a move towards ending 4 decades of kernel snooping.Theo de Raadt
Add sysctl kern.allowkmem (default 0) which controls the ability to open /dev/mem or /dev/kmem at securelevel > 0. Over 15 years we converted 99% of utilities in the tree to operate on sysctl-nodes (either by themselves or via code hiding in the guts of -lkvm). pstat -d and -v & procmap are affected and continued use of them will require kern.allowkmem=1 in /etc/sysctl.conf. acpidump (and it's buddy sendbug) are affected, but we'll work out a solution soon. There will be some impact in ports. ok kettenis guenther
2016-09-21sysctl KERN_ARND is no longer used (in ports, it only occurs in fallbackTheo de Raadt
paths of libevent). This interface was the first generation of what eventually became getentropy(2) and arc4random(3) -- june 1997! Ports scan by sthen, general agreement guenther
2016-09-18option INSECURE is obsoleteTheo de Raadt
2016-09-07Remove usermount remnants. ok teduMartin Natano
2016-09-04Introduce Dynamic Profiling, a ddb(4) based & gprof compatible kernelMartin Pieuchot
profiling framework. Code patching is used to enable probes when entering functions. The probes will call a mcount()-like function to match the behavior of a GPROF kernel. Currently only available on amd64 and guarded under DDBPROF. Support for other archs will follow soon. A new sysctl knob, ddb.console, need to be set to 1 in securelevel 0 to be able to use this feature. Inputs and ok guenther@
2016-08-23rename nfiles to numfiles to avoid shadowing and stretch out the name.Ted Unangst
ok deraadt
2016-07-14kern.usermount=1 is unsafe for everyone, since it allows any non-pledgedTheo de Raadt
program to call the mount/umount system calls. There is no way any user can be expected to keep their system safe / reliable with this feature. Ignore setting to =1, and after release we'll delete the sysctl entirely. ok lots of people
2016-05-27W^X violations are no longer permitted by default. A kernel log messageTheo de Raadt
is generated, and mprotect/mmap return ENOTSUP. If the sysctl(8) flag kern.wxabort is set then a SIGABRT occurs instead, for gdb use or coredump creation. W^X violating programs can be permitted on a ffs/nfs filesystem-basis, using the "wxallowed" mount option. One day far in the future upstream software developers will understand that W^X violations are a tremendously risky practice and that style of programming will be banished outright. Until then, we recommend most users need to use the wxallowed option on their /usr/local filesystem. At least your other filesystems don't permit such programs. ok jca kettenis mlarkin natano
2016-05-23remove the sysctl kern.random counters, since none of the remainingTheo de Raadt
ones are capable of giving valuable works vs does-not-work evidence. ok tedu
2016-05-21Cleanup some of the DUID code and refactor for readability.Joel Sing
ok krw@ kettenis@
2016-05-04Make KERN_FILE_BYPID return ESRCH when PID not found, both in sysctl andVadim Zhukov
offline paths. More polishing to come. Input and okay bluhm@ & kettenis@.
2016-04-25boom goes the dynamiteTed Unangst
2016-02-29delete the kern.emul/KERN_EMUL sysctl bits since there are noChristian Weisgerber
emulations left; ok millert@ deraadt@, jmc@ (man pages)
2015-12-05Make sure we use the same cpu numbering for the kern.cptime2 sysctl as weMark Kettenis
do for kern.proc. Fixes the issue in top(1) where a cpu would seem to be idle even though a thread was reported to be running on it. ok mpi@, tedu@, deraadt@
2015-11-01refactor pledge_*_check and pledge_fail functionsSebastien Marie
- rename _check function without suffix: a "pledge" function called from anywhere is a "check" function. - makes pledge_fail call the responsability to the _check function. remove it from caller. - make proper use of (potential) returned error of _check() functions. - adds pledge_kill() and pledge_protexec() with and OK deraadt@
2015-10-25Fold "malloc" into "stdio" and -- recognizing that no program so far hasTheo de Raadt
used less than "stdio" -- include all the "self" operations. Instead of different defines, use regular PLEDGE_* in the "p_pledgenote" variable (which indicates the operation subtype a system call is performing). Many checks before easier to understand. p_pledgenote can often be passed directly to ktrace, so that kdump says: 15565 test CALL pledge(0xa9a3f804c51,0) 15565 test STRU pledge request="stdio" 15565 test RET pledge 0 15565 test CALL open(0xa9a3f804c57,0x2<O_RDWR>) 15565 test NAMI "/tmp/testfile" 15565 test PLDG open, "wpath", errno 1 Operation not permitted with help from semarie, ok guenther
2015-10-09Rename tame() to pledge(). This fairly interface has evolved to be moreTheo de Raadt
strict than anticipated. It allows a programmer to pledge/promise/covenant that their program will operate within an easily defined subset of the Unix environment, or it pays the price.
2015-09-28track sizes for free in sysctl_diskinit(); ok krwTheo de Raadt
2015-09-13Rename __sysctl syscall to just sysctl, as the userland wrapper is no longerPhilip Guenther
necessary ok deraadt@ jsing@
2015-09-11Convert _TM_ flags to TAME_ flags, collapsing the entire mappingTheo de Raadt
layer because the strings select the right options. Mechanical conversion. ok guenther
2015-09-11Only include <sys/tame.h> in the .c files that need itPhilip Guenther
ok deraadt@ miod@
2015-09-10sizes for free(); ok sthenTheo de Raadt
2015-09-03Fix !INET6 build.Martin Pieuchot
2015-08-28Rework the UNIX domain socket garbage collector, including ideas fromPhilip Guenther
{Free,Net}BSD - when a socket is closed with fds in its input, defer closing them to a task to avoid recursing. This eliminates the complicated extra reference taking which had a 37 line(!) comment explanation - move flags, counts, and links only needed for this from struct file to struct unpcb - document the flow of the mark/sweep collector much help from claudio@ who made me explain the GC to him until we trusted it ok claudio@ mpi@ deraadt@
2015-08-22Move to tame(int flags, char *paths[]) API/ABI.Theo de Raadt
The pathlist is a whitelist of dirs and files; anything else returns ENOENT. Recommendation is to use a narrowly defined list. Also add TAME_FATTR, which permits explicit change operations against "struct stat" fields. Some other TAME_ flags are refined slightly. Not cranking libc now, since nothing commited in base uses this and the timing is uncomfortable for others. Discussed with many; thanks for a few bug fixes from semarie, doug, guenther. ok guenther
2015-08-03Unfortunately netstat did not show sockets without file descriptorsAlexander Bluhm
since it had been converted from kvm to sysctl. This was hiding a bunch of TCP states which are important for network debugging. Loop over the internet PCB tables to fill the network information into the KERN_FILE_BYFILE sysctl result. Skip internet sockets when looping over the file desciptors. From markus@; OK guenther@; Go for it deraadt@
2015-07-19tame(2) is a subsystem which restricts programs into a "reduced featureTheo de Raadt
operating model". This is the kernel component; various changes should proceed in-tree for a while before userland programs start using it. ok miod, discussions and help from many
2015-05-18For each file in sysctl(KERN_FILE_BYFILE), FILLIT() calls fill_file(),Alexander Bluhm
which calls VOP_GETATTR(). For NFS, that leads to nfs_getattr(). If the node's attributes are not in NFS's cache, nfs_getattr() will invoke nfs_request() and the latter will sleep, allowing the file pointer to disappear while we traverse the list. This results in kernel crashes while running netstat or pstat -f. Grab a reference to the file descriptor before calling FILLIT(), and release it afterwards. This way the file descriptor cannot disappear while we sleep in nfs_getattr(). Analysis and fix from Pedro Martelletto; input and OK guenther@ mpi@
2015-03-28Replace the hand-crafted list of datagram unix domain sockets withAlexander Bluhm
a SLIST. OK mpi@ benno@
2015-02-11Extend struct kinfo_file a bit so that netstat has all the info it needs.Claudio Jeker
OK guenther@
2015-02-11Prefer arg != 0 over arg for non-boolean. nitted kettenis@Philip Guenther
2015-02-11sysctl({CTL_KERN, KERN_FILE, KERN_FILE_BYFILE}) previously requiredPhilip Guenther
the extra argument to be zero; instead, make it filter on the file type (DTYPE_*) when non-zero to make claudio's netstat work easier. ok claudio@