summaryrefslogtreecommitdiffstats
path: root/sys/kern
Commit message (Collapse)AuthorAgeFilesLines
* Socket MAC labels so_label and so_peerlabel are now protected byrwatson2004-06-136-0/+24
| | | | | | | | | | | | | SOCK_LOCK(so): - Hold socket lock over calls to MAC entry points reading or manipulating socket labels. - Assert socket lock in MAC entry point implementations. - When externalizing the socket label, first make a thread-local copy while holding the socket lock, then release the socket lock to externalize to userspace.
* Introduce socket and UNIX domain socket locks into hard-coded lockrwatson2004-06-131-1/+8
| | | | | | | | | | | | | | | | | order definition for witness. Send lock before receive lock, and socket locks after accept but before select: filedesc -> accept -> so_snd -> so_rcv -> sellck All routing locks after send lock: so_rcv -> radix node head All protocol locks before socket locks: unp -> so_snd udp -> udpinp -> so_snd tcp -> tcpinp -> so_snd
* Correct whitespace errors in merge from rwatson_netperf: tabs instead ofrwatson2004-06-121-5/+5
| | | | | | spaces, no trailing tab at the end of line. Pointed out by: csjp
* Extend coverage of SOCK_LOCK(so) to include so_count, the socketrwatson2004-06-124-1/+21
| | | | | | | | | | | | | | | | | | | | | | | | | reference count: - Assert SOCK_LOCK(so) macros that directly manipulate so_count: soref(), sorele(). - Assert SOCK_LOCK(so) in macros/functions that rely on the state of so_count: sofree(), sotryfree(). - Acquire SOCK_LOCK(so) before calling these functions or macros in various contexts in the stack, both at the socket and protocol layers. - In some cases, perform soisdisconnected() before sotryfree(), as this could result in frobbing of a non-present socket if sotryfree() actually frees the socket. - Note that sofree()/sotryfree() will release the socket lock even if they don't free the socket. Submitted by: sam Sponsored by: FreeBSD Foundation Obtained from: BSD/OS
* Introduce a mutex into struct sockbuf, sb_mtx, which will be used torwatson2004-06-121-0/+4
| | | | | | | | | | | | | protect fields in the socket buffer. Add accessor macros to use the mutex (SOCKBUF_*()). Initialize the mutex in soalloc(), and destroy it in sodealloc(). Add addition, add SOCK_*() access macros which will protect most remaining fields in the socket; for the time being, use the receive socket buffer mutex to implement socket level locking to reduce memory overhead. Submitted by: sam Sponosored by: FreeBSD Foundation Obtained from: BSD/OS
* Fix registration of loadable line disciplines.phk2004-06-121-1/+2
| | | | This should make watch(8)/snp(4) work again.
* Gah! Plug a mbuf leak I introduced in the last commit.bmilekic2004-06-111-2/+3
| | | | | | I don the pointy-hat. Problem reported by: Peter Holm <pho@>
* Shuffle some code around.julian2004-06-112-43/+67
|
* Deorbit COMPAT_SUNOS.phk2004-06-1111-46/+34
| | | | | We inherited this from the sparc32 port of BSD4.4-Lite1. We have neither a sparc32 port nor a SunOS4.x compatibility desire these days.
* Make sysctl_wire_old_buffer() respect ENOMEM from vslock() by markinggreen2004-06-111-2/+5
| | | | | | | the valid length as 0. This prevents vsunlock() from removing a system wire from memory that was not successfully wired (by us). Submitted by: tegge
* Introduce a subsystem lock around UNIX domain sockets in order to protectrwatson2004-06-101-58/+193
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | global and allocated variables. This strategy is derived from work originally developed by BSDi for BSD/OS, and applied to FreeBSD by Sam Leffler: - Add unp_mtx, a global mutex which will protect all UNIX domain socket related variables, structures, etc. - Add UNP_LOCK(), UNP_UNLOCK(), UNP_LOCK_ASSERT() macros. - Acquire unp_mtx on entering most UNIX domain socket code, drop/re-acquire around calls into VFS, and release it on return. - Avoid performing sodupsockaddr() while holding the mutex, so in general move to allocating storage before acquiring the mutex to copy the data. - Make a stack copy of the xucred rather than copying out while holding unp_mtx. Copy the peer credential out after releasing the mutex. - Add additional assertions of vnode locks following VOP_CREATE(). A few notes: - Use of an sx lock for the file list mutex may cause problems with regard to unp_mtx when garbage collection passed file descriptors. - The locking in unp_pcblist() for sysctl monitoring is correct subject to the unpcb zone not returning memory for reuse by other subsystems (consistent with similar existing concerns). - Sam's version of this change, as with the BSD/OS version, made use of both a global lock and per-unpcb locks. However, in practice, the global lock covered all accesses, so I have simplified out the unpcb locks in the interest of getting this merged faster (reducing the overhead but not sacrificing granularity in most cases). We will want to explore possibilities for improving lock granularity in this code in the future. Submitted by: sam Sponsored by: FreeBSD Foundatiuon Obtained from: BSD/OS 5 snapshot provided by BSDi
* Plug a race where upon free this scenario could occur:bmilekic2004-06-101-15/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (time grows downward) thread 1 thread 2 ------------|------------ dec ref_cnt | | dec ref_cnt <-- ref_cnt now zero cmpset | free all | return | | alloc again,| reuse prev | ref_cnt | | cmpset, read | already freed | ref_cnt ------------|------------ This should fix that by performing only a single atomic test-and-set that will serve to decrement the ref_cnt, only if it hasn't changed since the earlier read, otherwise it'll loop and re-read. This forces ordering of decrements so that truly the thread which did the LAST decrement is the one that frees. This is how atomic-instruction-based refcnting should probably be handled. Submitted by: Julian Elischer
* Fix a panic happening when m_getm() is called with len < MCLBYTES.mux2004-06-091-1/+1
| | | | | | Reported by: ale Tested by: ale Reviewed by: bosko
* Add a comment explaining td_critnest's initial state and its life from thatjmallett2004-06-091-0/+13
| | | | | | | point on, as it happens relatively indirectly, and in a codepath the casual reader may not be acquainted with or find obvious. Glanced at by: jhb
* Rename struct pt_ioctl to "ptsc" and pointers to it from "pti" to "pt"phk2004-06-091-65/+65
|
* Ditch K&R function stylephk2004-06-091-63/+15
|
* Reference count struct tty.phk2004-06-092-22/+96
| | | | | | | | | | | Add two new functions: ttyref() and ttyrel(). ttymalloc() creates a struct tty with a reference count of one. when ttyrel sees the count go to zero, struct tty is freed. Hold references for open ttys and for ttys which are controlling terminal for sessions. Until drivers start using ttyrel(), this commit will make no difference.
* Fix a race in destruction of sessions.phk2004-06-091-2/+3
|
* Move PTY private defines into PTY private files.phk2004-06-091-0/+4
|
* Avoid assignments to cast expressions.stefanf2004-06-081-2/+2
| | | | | Reviewed by: md5 Approved by: das (mentor)
* Remove remnants of PGINPROF.tjr2004-06-081-5/+0
|
* Correct a resource leak introduced in recent accept locking changes:rwatson2004-06-071-4/+4
| | | | | | | | | | | | | | | | | | | | when I reordered events in accept1() to allocate a file descriptor earlier, I didn't properly update use of goto on exit to unwind for cases where the file descriptor is now held, but wasn't previously. The result was that, in the event of accept() on a non-blocking socket, or in the event of a socket error, a file descriptor would be leaked. This ended up being non-fatal in many cases, as the file descriptor would be properly GC'd on process exit, so only showed up for processes that do a lot of non-blocking accept() calls, and also live for a long time (such as qmail). This change updates the use of goto targets to do additional unwinding. Eyes provided by: Brian Feldman <green@freebsd.org> Feet, hands provided by: Stefan Ehmann <shoesoft@gmx.net>, Dimitry Andric <dimitry@andric.com> Arjan van Leeuwen <avleeuwen@piwebs.com>
* Make linesw[] an array of pointers to linedesc instead of an array ofphk2004-06-072-64/+60
| | | | linedisc.
* Split kern_thread.c into 2 parts. kern_kse.c and kern_thread.cjulian2004-06-071-1209/+13
| | | | | Kern_kse has already been committed. This separates out the KSE threading ABI from generic thread support.
* According to SUSv3, sigwait is different with sigwaitinfo, sigwaitdavidxu2004-06-071-5/+12
| | | | returns error code in return value, not in errno.
* Remove unused code.pjd2004-06-072-12/+2
| | | | Submitted by: Bjoern A. Zeeb
* allow more than MLEN bytes for ancillary data to meet theume2004-06-071-1/+9
| | | | | | | requirement of Section 20.1 of RFC3542. Obtained from: KAME MFC after: 1 week
* Remove a stale and misleading comment.tjr2004-06-071-7/+0
|
* Move the KSE ABI specific code here and separate it from code thatjulian2004-06-071-977/+19
| | | | | | is generic to any threading system. This commit does not link this file to the build yet, nor does it remove these functions from their current location in kern_thread.c. (that commit coming up after further review)
* Remove filename+line number from panic messages.phk2004-06-061-3/+3
|
* Detect interrupt storms better. The storm detection didn't work at allbde2004-06-051-23/+50
| | | | | | | | | | | | | | | | | with an ASUS A7N8X-E motherboard in APIC mode, since storming interrupts don't repeat immediately. Use DELAY(1) to wait a bit for them to repeat. This affects all systems. Only delay for the first (10 * intr_storm_threshold) interrupts (per interrupt handler) so that this is only a pessimization while warming up. Throttle after calling the sub-handlers instead of before so that the long delay given by throttling can be used instead of the DELAY(1) to detect storms after warming up. Reduced the throttling period from 1/10 second to 1/hz seconds so that throttling doesn't destroy performance so much. Interrupts that are detected as storming are effectively handled by polling at a frequency of hz Hz. On A7N8X-E's there is another hardware or configuration bug that makes the throttled frequency closer to 2*hz Hz.
* When we don't have any meaningful value to print for the device sysctlmux2004-06-051-8/+4
| | | | | | | | | tree, output an empty string instead of "?". This is already what happened with DEVICE_SYSCTL_LOCATION and DEVICE_SYSCTL_PNPINFO. This makes the output of "sysctl dev" much nicer (it won't display those empty sysctls). Reviewed by: des
* Change the types of vn_rdwr_inchunks()'s len and aresid arguments totjr2004-06-053-6/+8
| | | | | | size_t and size_t *, respectively. Update callers for the new interface. This is a better fix for overflows that occurred when dumping segments larger than 2GB to core files.
* Back out workaround for vn_rdwr_inchunks()'s INT_MAX length limitationtjr2004-06-051-21/+8
| | | | after discussions with bde; vn_rdwr_inchunks() itself should be fixed.
* Centralize the line discipline optimization determination in a functionphk2004-06-041-0/+18
| | | | | | | | | called ttyldoptim(). Use this function from all the relevant drivers. I belive no drivers finger linesw[] directly anymore, paving the way for locking and refcounting.
* Manual edits to change linesw[]-frobbing to ttyld_*() calls.phk2004-06-041-1/+1
|
* Machine generated patch which changes linedisc calls from accessingphk2004-06-042-13/+13
| | | | | | linesw[] directly to using the ttyld...() functions The ttyld...() functions ar inline so there is no performance hit.
* Remove a stale comment.tjr2004-06-042-8/+0
|
* Add a devclass level to the dev sysctl tree, in order to support per-des2004-06-041-10/+64
| | | | | | class variables in addition to per-device variables. In plain English, this means that dev.foo0.bar is now called dev.foo.0.bar, and it is possible to to have dev.foo.bar as well.
* Get rid of ttyregister(). All drivers now use ttymalloc() for structphk2004-06-041-8/+2
| | | | | tty, so now we stand a chance of implementing refcounting and getting rid of the damn things again.
* Use ttymalloc() instead of ttyregister(). Use ttyioctl() instead ofphk2004-06-041-8/+6
| | | | direct calls to the linedisc.
* Write segments to core dump files in maximally-sized chunks that neithertjr2004-06-041-8/+21
| | | | | | | exceed vn_rdwr_inchunks()'s INT_MAX length limitation nor span a block boundary. This fixes dumping segments larger than 2GB. PR: 67546
* Mark sun_noname as const since it's immutable. Update definitionsrwatson2004-06-043-7/+7
| | | | | of functions that potentially accept &sun_noname (sbappendaddr(), et al) to accept a const sockaddr pointer.
* Move the definitions of SWAPBLK_NONE and SWAPBLK_MASK from vm_page.h toalc2004-06-041-5/+0
| | | | | blist.h, enabling the removal of numerous #includes from subr_blist.c. (subr_blist.c and swap_pager.c are the only users of these definitions.)
* - Comment out NULL, NULL barrier for Unix domain sockets section as thejhb2004-06-031-1/+2
| | | | | | | | double NULL entries signal Witness to stop processing the array of order entries meaning none of the spin locks are added resulting in panics on boot. - Add a missing NULL, NULL terminator to the Slip locks list to keep them separate from the spin locks.
* Remove checks for curthread == NULL - it can't happen.tjr2004-06-031-5/+3
|
* Move TDF_DEADLKTREAT into td_pflags (and rename it accordingly) to avoidtjr2004-06-032-13/+6
| | | | | | | having to acquire sched_lock when manipulating it in lockmgr(), uiomove(), and uiomove_fromphys(). Reviewed by: jhb
* Expand the hard-coded WITNESS lock order to include the followingrwatson2004-06-021-0/+35
| | | | | | | | | | | | | relationships: Sockets: filedesc->accept->sellck Routing: radix node head->rtentry->ifaddr UDP: udp->udpinp TCP: tcp->tcpinp SLIP: slip_mtx->slip sc_mtx Drop in a place holder section for UNIX domain sockets. Various sections to be expanded over the next few days.
* As discussed on arch@, flatten the device sysctl tree to make itmux2004-06-021-13/+12
| | | | | more convenient to deal with. The notion of hierarchy is however preserved by adding a new %parent node.
* Remove a redundant "td = curthread" statement from profclock().tjr2004-06-021-1/+0
|
OpenPOWER on IntegriCloud