summaryrefslogtreecommitdiff
path: root/sys/kern
AgeCommit message (Collapse)Author
2016-10-06Separate splsoftnet() from variable initialization.Alexander Bluhm
From mpi@'s netlock diff; OK mikeb@
2016-10-06In pledge_namei_wlpath() if resolvpath() errors out early it will notJonathan Gray
set variables that will be later used as the size argument to free(NULL calls. This should be harmless as free returns early if the address is NULL without checking the size. Initialise these variables before the call to ensure they are never passed to another function uninitialised. ok tedu@ millert@ deraadt@
2016-10-05Display the process's PID with p->p_p->ps_pid, not p->p_pid.Philip Guenther
Use a local variable struct process *pr to simplify expressions ok deraadt@
2016-10-05Display/test/use the process PID, not the thread's TID, in a few places.Philip Guenther
ok mpi@ mikeb@
2016-10-03avoid holding timeout_mutex while interacting with the scheduler.David Gwynne
as noted by haesbaert, this is necessary to avoid deadlocks because the scheduler can call back into the timeout subsystem while its holding its own locks. this happened in two places. firstly, in softclock() it would take timeout_mutex to find pending work. if that pending work needs a process context, it would queue the work for the thread and call wakeup, which enters the scheduler locks. if another cpu is trying to tsleep (or msleep) with a timeout specified, the sleep code would be holding the sched lock and call timeout_add, which takes timeout_mutex. this is solved by deferring the wakeup to after timeout_mutex is left. this also has the benefit of mitigating the number of wakeups done per softclock tick. secondly, the timeout worker thread takes timeout_mutex and calls msleep when there's no work to do (ie, the queue is empty). msleep will take the sched locks. again, if another cpu does a tsleep with a timeout, you get a deadlock. to solve this im using sleep_setup and sleep_finish to sleep on an empty queue, which is safe to do outside the lock as it is comparisons of the queue head pointers, not derefs of the contents of the queue. as long as the sleeps and wakeups are ordered correctly with the enqueue and dequeue operations under the mutex, this all works. you can think of the queue as a single descriptor ring, and the wakeup as an interrupt. the second deadlock was identified by guenther@ ok tedu@ mpi@
2016-10-02Add va_nlink information to struct kinfo_file (so bump the shlib minor)Philip Guenther
from Sebastien Marie
2016-09-30Drop a now unneeded variable initialization; spotted by bluhm@Jeremie Courreges-Anglas
2016-09-30Make read(2) return EISDIR on directories.Jeremie Courreges-Anglas
Years ago Theo made read(2) return 0 on directories, instead of dumping the directory content. Another behavior is allowed as an extension by POSIX, returning an EISDIR error, as used on a few other systems. This behavior is deemed more useful as it helps spotting errors. This implies that it might break some setups. Ports bulk builds by ajacoutot@ and naddy@, ok millert@ bluhm@ naddy@ deraadt@
2016-09-28Cast enum to u_int when doing a bounds check to avoid a clang warning thatMark Kettenis
the comparison is always true. ok jca@, tedu@
2016-09-27move from RB macros to RBT functionsDavid Gwynne
2016-09-26RegenJeremie Courreges-Anglas
2016-09-26unbalenced->unbalancedJeremie Courreges-Anglas
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-24move knhash size to event.h, use it for hashfree. from Mathieu -Ted Unangst
ok guenther
2016-09-24introduce hashfree() function to free hash tables, with sizes.Ted Unangst
ok guenther
2016-09-22Introduce a new 'softclock' thread that will be used to execute timeoutMartin Pieuchot
callbacks needing a process context. The function timeout_set_proc(9) has to be used instead of timeout_set(9) when a timeout callback needs a process context. Note that if such a timeout is waiting, understand sleeping, for a non negligible amount of time it might delay other timeouts needing a process context. dlg@ agrees with this as a temporary solution. Manpage tweaks from jmc@ ok kettenis@, bluhm@, mikeb@
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-20Protect soshutdown() with splsoftnet() to define one layer whereAlexander Bluhm
we enter networking code. Fixes an splassert() found by David Hill. OK mikeb@
2016-09-20Add some spl softnet assertions that will help us to find the rightAlexander Bluhm
places for the upcoming network lock. This might trigger some asserts, but we have to find the missing code paths. OK mpi@
2016-09-20whitespace fixes, no functional changeDavid Gwynne
2016-09-18option INSECURE is obsoleteTheo de Raadt
2016-09-18add missing call to db_ctf_init().Jasper Lievisse Adriaanse
this was part of the larger diff that was ok guenther@ mpi@, somehow I forgot to commit this particular piece.
2016-09-17Make the flag tests consistent in buf_realloc_pages() and explain what'sPhilip Guenther
going on more clearly ok beck@ tedu@
2016-09-17NPF > 0 is a better test than SMALL for presence of pf.Ted Unangst
ok deraadt
2016-09-16move the namecache_rb_tree from RB macros to RBT functions.David Gwynne
i had to shuffle the includes a bit. all the knowledge of the RB tree is now inside vfs_cache.c, and all accesses are via cache_* functions.
2016-09-16move buf_rb_bufs from RB macros to RBT functionsDavid Gwynne
i had to shuffle the order of some header bits cos RBT_PROTOTYPE needs to see what RBT_HEAD produces.
2016-09-16move the vm_page struct from being stored in RB macro trees to RBT functionsDavid Gwynne
vm_page structs go into three trees, uvm_objtree, uvm_pmr_addr, and uvm_pmr_size. all these have been moved to RBT code. this should give us a decent chunk of code space back.
2016-09-16remove a trailing \David Gwynne
i mustnt have cleaned this up properly when i copied the tree.h code from Ilya Kaliman
2016-09-15add RBT_POISON and RBT_CHECK so you can poison the pointers in RBT_ENTRYsDavid Gwynne
this seems like a better way forward than simply removing the poisoning that uvm does.
2016-09-15fix $OpenBSD$ tagDavid Gwynne
2016-09-15rename the members of rb_entry so they dont keep working with RB macrosDavid Gwynne
2016-09-15all pools have their ipl set via pool_setipl, so fold it into pool_init.David Gwynne
the ioff argument to pool_init() is unused and has been for many years, so this replaces it with an ipl argument. because the ipl will be set on init we no longer need pool_setipl. most of these changes have been done with coccinelle using the spatch below. cocci sucks at formatting code though, so i fixed that by hand. the manpage and subr_pool.c bits i did myself. ok tedu@ jmatthew@ @ipl@ expression pp; expression ipl; expression s, a, o, f, m, p; @@ -pool_init(pp, s, a, o, f, m, p); -pool_setipl(pp, ipl); +pool_init(pp, s, a, ipl, f, m, p);
2016-09-15move pools to using the subr_tree version of rb treesDavid Gwynne
this is half way to recovering the space used by the subr_tree code.
2016-09-15we dont need m_copym0 with m_copym as a single wrapper, so merge them.David Gwynne
cos m_copym only does shallow copies, we can make the code do them unconditionally. for millert@
2016-09-15remove m_copym2 as its use has been replaced by m_dup_pktDavid Gwynne
ok millert@ mpi@ henning@ claudio@ markus@
2016-09-13avoid extensive mbuf allocation for IPsec by replacing m_inject(4)Markus Friedl
with m_makespace(4) from freebsd; ok mpi@, bluhm@, mikeb@, dlg@
2016-09-13Introduce rwsleep(9), an equivalent to msleep(9) but for code protectedMartin Pieuchot
by a write lock. ok guenther@, vgross@
2016-09-13Do not raise splsoftnet() recursively in soaccept().Martin Pieuchot
This is not an issue right now, but it will become one when an non recursive lock will be used. ok claudio@
2016-09-12When trying to run an ELF binary marked PT_OPENBSD_WXNEEDED from aIngo Schwarze
file system mounted without MNT_WXALLOWED, fail with EACCES rather than with ENOEXEC, to discourage the shell from trying to run the file as a shell script. OK deraadt@ millert@; tedu@ and halex@ agreed with the general direction.
2016-09-10Add a noperm mount flag for FFS to be used for building release setsMartin Natano
without root privileges. This is only the kernel/mount flag; additional work in the build Makefile's will be necessary such that the files in $DESTDIR are created with correct permissions. tedu couldn't find anything wrong with it in a quick review idea & ok deraadt
2016-09-07Remove usermount remnants. ok teduMartin Natano
2016-09-06it's not wrong, but it's not clear what the verauth check is for.Ted Unangst
add a comment to this effect, and explain the intention.
2016-09-05Fix hibernation - make stack protector writable during resumeBob Beck
Committing for guenther@ because he is on United and apparently they break ssh (as well as guitars) ok deraadt@ in the car from cambridge
2016-09-05Kill raw_ctlinput() this function is INCOMPLETE since rev 1.1 and is notClaudio Jeker
needed. All callers using the protosw pr_ctlinput pointer do a NULL check before so there is no need to provide the function.
2016-09-05revert moving pools from tree.h to subr_tree.c rb trees.David Gwynne
itll go in again when i dont break userland.
2016-09-05move pool red-black trees from tree.h code to subr_tree.c codeDavid Gwynne
ok tedu@
2016-09-04Regen.Joel Sing
2016-09-04Remove sys_o58_kill since OpenBSD 6.0 has been tagged/released.Joel Sing
ok deraadt@
2016-09-04Remove support for tape block devices. Nobody mount(8)s tapes any longer.Christian Weisgerber
ok deraadt@ guenther@
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@