summaryrefslogtreecommitdiffstats
path: root/sys/kern/uipc_usrreq.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Move UNIX socket's garbage collector to `systqmp'. It touches nothingmvs2021-02-221-3/+3
| | | | | | which requires kernel lock to be held. ok mpi@
* Move UNIX domain sockets out of kernel lock. The new `unp_lock' rwlock(9)mvs2021-02-101-42/+144
| | | | | | | | used as solock()'s backend to protect the whole layer. With feedback from mpi@. ok bluhm@ claudio@
* Fix uipc white spaces.bluhm2019-07-161-3/+3
|
* Convert struct unpcb malloc(9) to pool_get(9).bluhm2019-07-151-4/+13
| | | | OK mpi@ visa@
* Prevent a kernel hang if an empty message is sent over an SOCK_SEQPACKETbluhm2019-05-241-2/+3
| | | | | socketpair. Do not wakeup receiver if there is no data available. OK claudio@ anton@
* Allow SO_PEERCRED to be called on sockets created with socketpair.martijn2019-02-131-1/+13
| | | | OK claudio@ and jca@
* Avoid an mbuf double free in the oob soreceive() path. In thebluhm2019-02-041-6/+6
| | | | | | | | | | usrreq functions move the mbuf m_freem() logic to the release block instead of distributing it over the switch statement. Then the goto release in the initial check, whether the pcb still exists, will not free the mbuf for the PRU_RCVD, PRU_RVCOOB, PRU_SENSE command. OK claudio@ mpi@ visa@ Reported-by: syzbot+8e7997d4036ae523c79c@syzkaller.appspotmail.com
* In unp_internalize() check the length more carefully preventing anclaudio2018-11-211-1/+3
| | | | | | | underflow in a later calcuation. Using the same CMSG_LEN(0) check that other cmsghdr handlers implemented. Probelm found by anton@ OK anton@, deraadt@, visa@
* When using MSG_PEEK to peak into packets skip control messages holdingclaudio2018-11-211-1/+8
| | | | | | SCM_RIGHTS from being sent to the userland since they hold kernel internal data and it does not make sense to externalize it. OK deraadt@, guenther@, visa@
* M_LEADINGSPACE() and M_TRAILINGSPACE() are just wrappers forclaudio2018-11-091-3/+3
| | | | | | m_leadingspace() and m_trailingspace(). Convert all callers to call directly the functions and remove the defines. OK krw@, mpi@
* Use function name in panic string, like in some other places.claudio2018-07-091-2/+2
| | | | OK henning@ benno@
* Update the file reference count field `f_count' using atomic operationsvisa2018-07-021-8/+8
| | | | | | | | | instead of using a mutex for update serialization. Use a per-fdp mutex to manage updating of file instance pointers in the `fd_ofiles' array to let fd_getfile() acquire file references safely with concurrent file reference releases. OK mpi@
* Lock the file descriptor table when accessing the `fd_ofileflags' array.visa2018-07-011-1/+4
| | | | | | | | This prevents the array from being freed too early. In the function unp_internalize(), the locking also ensures the per-fdp flags stay coherent with the file instance. OK mpi@
* Improve the consistency of variable naming in unp_externalize().visa2018-06-231-16/+17
| | | | | | | | Rename the int array `fdp' to `fds', and use the name `fdp' for a variable that points to the filedesc struct of the current process. This use of `fdp' puts unp_externalize() in line with filesystem code. OK millert@, kettenis@
* Unlock sendmsg(2) and sendto(2).mpi2018-06-201-2/+8
| | | | | | | | | | These syscalls can now be executed w/o the KERNEL_LOCK() depending on the kind of socket. The current solution uses a single global mutex to serialize access to, and reference count, 'struct file'. ok visa@, kettenis@
* Do not unlock the KERNEL_LOCK() unconditionally in sounlock().mpi2018-06-111-6/+4
| | | | | | | Instead introduce two flags to deal with global lock recursion. This is necessary until we get per-socket lock. Req. by and ok visa@
* Make callers of VOP_CREATE(9) and VOP_MKNOD(9) responsible forvisa2018-06-071-1/+2
| | | | | | unlocking the directory vnode. OK mpi@, helg@
* Pass the socket to sounlock(), this prepare the terrain for per-socketmpi2018-06-061-2/+10
| | | | | | locking. ok visa@, bluhm@
* Clean up the parameters of VOP_LOCK() and VOP_UNLOCK(). It is alwaysvisa2018-04-281-2/+2
| | | | | | | curproc that does the locking or unlocking, so the proc parameter is pointless and can be dropped. OK mpi@, deraadt@
* Move FREF() inside fd_getfile().mpi2018-04-271-2/+1
| | | | ok visa@
* Call FREF(9) earlier instead of incrementing `f_count' by hand.mpi2018-04-181-4/+6
| | | | ok millert@, visa@
* Unifdef snd/rcv.mpi2018-01-041-7/+3
| | | | ok visa@, claudio@
* Remove a 27 year old #ifdef notdef chunk involving SB_LOCK.mpi2017-12-191-17/+1
| | | | ok bluhm@
* Inline socket buffer related defines, no functional change.mpi2017-12-191-11/+8
| | | | ok bluhm@
* Move PRU_DETACH out of pr_usrreq into per proto pr_detachflorian2017-11-021-5/+16
| | | | | | functions to pave way for more fine grained locking. Suggested by, comments & OK mpi
* Validate sockaddr from userland in central functions. This resultsbluhm2017-08-111-24/+42
| | | | | | | in common checks for unix, inet, inet6 instead of partial checks here and there. Some checks are already done at a higher layer, but better be paranoid with user input. OK claudio@ millert@
* Assert that the corresponding socket is locked when manipulating socketmpi2017-06-261-5/+5
| | | | | | | | | | | | | | | | buffers. This is one step towards unlocking TCP input path. Note that all the functions asserting for the socket lock are not necessarilly MP-safe. All the fields of 'struct socket' aren't protected. Introduce a new kernel-only kqueue hint, NOTE_SUBMIT, to be able to tell when a filter needs to lock the underlying data structures. Logic and name taken from NetBSD. Tested by Hrvoje Popovski. ok claudio@, bluhm@, mikeb@
* Move PRU_ATTACH out of the pr_usrreq functions into pr_attach.claudio2017-03-131-11/+5
| | | | | | | Attach is quite a different thing to the other PRU functions and this should make locking a bit simpler. This also removes the ugly hack on how proto was passed to the attach function. OK bluhm@ and mpi@ on a previous version
* Wrap the NET_LOCK() into a per-socket solock() that does nothing formpi2017-02-141-25/+6
| | | | | | | | unix domain sockets. This should prevent the multiple deadlock related to unix domain sockets. Inputs from millert@ and bluhm@, ok bluhm@
* Temporarily grab the NET_LOCK() around soisdisconnected().mpi2017-02-091-1/+6
| | | | | | | | | | This makes a (wrong) assert disappear and makes sure we hack to avoid a recursion in the upcall case still work. The real solution to this problem is to not grab the NET_LOCK() before entering uipc_usrreq(). Issue reported by dtucker@
* Release the NET_LOCK() before calling unp_detach(), fix a recursionmpi2017-02-091-2/+5
| | | | found by dtucker@
* In sosend() the size of the control message for file descriptorbluhm2017-01-271-6/+1
| | | | | | | passing is checked. As the data type has changed in unp_internalize(), the calculation has to be adapted in sosend(). Found by relayd regress test on i386. OK millert@
* Enable the NET_LOCK(), take 2.mpi2017-01-251-1/+12
| | | | | | Recursions are currently known and marked a XXXSMP. Please report any assert to bugs@
* Track a per-fd flag UF_PLEDGED. This indicates the initial open was done by aderaadt2017-01-241-1/+4
| | | | | | | | | | | | | | | | pledged process. dup(2) and recvmsg(2) retain UF_PLEDGED from the original fd. In pledge "exec" circumstances, exceve clears UF_PLEDGED on all the process's fds. In a pledge'd process, ioctl(2) can use this additional information to grant access to ioctl's which are more sensitive or dive deeply into the kernel. Developers will be encouraged to open such sensitive resources before calling pledge(2), rather than afterwards. That matches the heading of privsep development practices. Future changes will introduce those ioctl(2) changes. Lots of discussions with semarie guenther and benno.
* File descriptor passing internalizes fd's into an mbuf-stored array ofderaadt2017-01-231-29/+43
| | | | | | | | | | struct file *, and then externalizes back to fd upon delivery. Convert storage to array of struct fdpass, containing struct file * (and soon something else). memcpy originally intended for alignment purposes can be removed because CMSG_ALIGN is _ALIGN. There is some anxiety over changing this code, but it reads easier. ok mpi guenther kettenis
* Change NET_LOCK()/NET_UNLOCK() to be simple wrappers aroundmpi2016-12-291-12/+1
| | | | | | | | | | | splsoftnet()/splx() until the known issues are fixed. In other words, stop using a rwlock since it creates a deadlock when chrome is used. Issue reported by Dimitris Papastamos and kettenis@ ok visa@
* Release the NET_LOCK() before calling unp_connect(). It is not possiblempi2016-12-291-19/+15
| | | | | | | | to hold it during VFS operations as NFS might try to grab it. Problem also reported by Siegfried Rudzio on bugs@. ok visa@
* Release the NET_LOCK() before namei(9) as a workaround to let NFS bootmpi2016-12-221-2/+17
| | | | | | work without assert. ok visa@, bluhm@
* Revert workaround for NFS boot, it triggers the following assert:mpi2016-12-221-4/+1
| | | | | | | | | | | | | swakeup sowakeup sowwakeup unp_connect2 unp_connect uipc_usrreq soconnect sys_connect reported by stsp@, tb@ and RT Thrush
* Work around a NET_LOCK() recursion seen during NFS netboot:visa2016-12-221-1/+4
| | | | | | | | | | | | | | | | sosend <- NET_LOCK() nfs_send nfs_request nfs_lookup VOP_LOOKUP vfs_lookup namei unp_connect uipc_usrreq soconnect <- NET_LOCK() sys_connect OK bluhm@ mpi@
* Introduce the NET_LOCK() a rwlock used to serialize accesses to the partsmpi2016-12-191-1/+4
| | | | | | | | | | | of the network stack that are not yet ready to be executed in parallel or where new sleeping points are not possible. This first pass replace all the entry points leading to ip_output(). This is done to not introduce new sleeping points when trying to acquire ART's write lock, needed when a new L2 entry is created via the RT_RESOLVE. Inputs from and ok bluhm@, ok dlg@
* m_free() and m_freem() test for NULL. Simplify callers which had their ownjsg2016-11-291-5/+3
| | | | | | NULL tests. ok mpi@
* The *_HEAD_INITIALIZER() macros are documented as taking the struct,guenther2016-08-261-3/+3
| | | | not a pointer to it
* Fix an mbuf leak and missing error propagation in uipc_usrreq(PRU_SEND)bluhm2016-08-171-1/+5
| | | | | in case sbappendcontrol() fails. From Simon Mages; OK mikeb@
* instead of messing about with pointer arithmetic, add an empty arraytedu2016-07-191-4/+4
| | | | to the end of the defer structure. solves sizing and alignment concerns.
* in the great unp_gc rewrite, a null check was lost. we have spent sometedu2016-07-121-1/+3
| | | | | | | | time investigating and arguing about whether a NULL fp is a bug or not, but what has become clear is that NULL fps get passed to unp_discard and have been for quite some time. restore old accomodating behavior by checking for null in unp_gc. ok deraadt kettenis
* The check for pledge "recvfd" was mistakenly only being performedderaadt2016-07-121-23/+19
| | | | | for chroot'd processes. ok stefan semarie
* remove systrace remnantstedu2016-04-251-4/+3
|
* Remove the unused flags argument from VOP_UNLOCK().natano2016-03-191-2/+2
| | | | | | torture tested on amd64, i386 and macppc ok beck mpi stefan "the change looks right" deraadt
* remove stale lint annotationstedu2015-12-051-2/+1
|