summaryrefslogtreecommitdiffstats
path: root/sys/netinet/udp_usrreq.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Avoid an mbuf double free in the oob soreceive() path. In thebluhm2019-02-041-8/+8
| | | | | | | | | | 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
* Do not translate the EACCES error from pf(4) to EHOSTUNREACH anymore.bluhm2018-11-101-3/+1
| | | | | | It also translated a documented send(2) EACCES case erroneously. This was too much magic and always prone to errors. from Jan Klemkow; man page jmc@; OK claudio@
* Revert the inpcb table mutex commit. It triggers a witness panicbluhm2018-10-041-3/+1
| | | | | | | in raw IP delivery and UDP broadcast loops. There inpcbtable_mtx is held and sorwakeup() is called within the loop. As sowakeup() grabs the kernel lock, we have a lock ordering problem. found by Hrvoje Popovski; OK deraadt@ mpi@
* As a step towards per inpcb or socket locks, remove the net lockbluhm2018-09-201-1/+3
| | | | | | | | | | | | for netstat -a. Introduce a global mutex that protects the tables and hashes for the internet PCBs. To detect detached PCB, set its inp_socket field to NULL. This has to be protected by a per PCB mutex. The protocol pointer has to be protected by the mutex as netstat uses it. Always take the kernel lock in in_pcbnotifyall() and in6_pcbnotify() before the table mutex to avoid lock ordering problems in the notify functions. OK visa@
* Add reference counting for inet pcb, this will be needed when webluhm2018-09-131-2/+2
| | | | | | start locking the socket. An inp can be referenced by the PCB queue and hashes, by a pf mbuf header, or by a pf state key. OK visa@
* It was possible to leak the control mbuf in raw ip user requestbluhm2018-07-051-2/+1
| | | | | | with sendmsg(2) and MSG_OOB. Sync the code in udp, rip, and rip6_usrreq. Add an inp NULL check in rip6_usrreq for consistency. OK benno@ mpi@
* The udp control option processing was implemented three times.bluhm2018-06-081-77/+44
| | | | | | | | | Multicast lacked receive destination port. Better use a function and do it all in one place. The pipex chunk does not use the options, so it can happen before. Adding the udp header length to the ip header length was done inconsistently. Do it explicitly when needed. OK mpi@ visa@
* When checking the IPsec enable sysctls, ipsec_common_input() hadbluhm2018-05-141-2/+2
| | | | | | | | | | | | switches for protocol and address family. Move this code to the specific functions from where the common function is called. As a consequence the raw ip input functions can never be called from udp_input() anymore. If IPsec is disabled, the functions ah6_input(), esp6_input(), and ipcomp6_input() do not start processing the header chain. The raw ip input functions are called with the mbuf and offset pointers from the protocol walking loop which is the usual behavior. OK mpi@ markus@
* Push NET_LOCK down in the default ifioctl case.pirofti2018-04-241-3/+3
| | | | | | | For the PRU_CONTROL bit the NET_LOCK surrounds in[6]_control() and on the ENOTSUPP case we guard the driver if_ioctl functions. OK mpi@
* Use the existing pf state to speed up UDP socket lookup. This wasbluhm2018-04-061-2/+2
| | | | | | | | disabled as there were some stability issues. It seems that the crashes were fixed when reference counting for pf states was implemented. Se reenable this code. Apart from the performance improvement it also makes corner cases for pf divert-to more reliable. OK henning@
* Simplify the reverse PCB lookup logic. The PF_TAG_TRANSLATE_LOCALHOSTbluhm2017-12-011-11/+6
| | | | | | | | security check prevents that the user accidentally configures redirect where a divert-to would be appropriate. Instead of spreading the logic into tcp and udp input, check the flag during PCB listen lookup. This also reduces parameters of in_pcblookup_listen(). OK visa@
* Sprinkle some NET_ASSERT_LOCKED(), const and co to prepare runningmpi2017-11-201-3/+8
| | | | | | pr_input handlers without KERNEL_LOCK(). ok visa@
* Make {ah,esp,ipcomp}stat use percpu counters.visa2017-11-081-2/+2
| | | | OK bluhm@, mpi@
* 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
* Reduces the scope of the NET_LOCK() in sysctl(2) path.mpi2017-10-091-8/+20
| | | | | | Exposes per-CPU counters to real parrallelism. ok visa@, bluhm@, jca@
* Replace NET_ASSERT_LOCKED() by soassertlocked() in *_usrreq().mpi2017-09-051-2/+2
| | | | | | Not all of them need the NET_LOCK(). ok bluhm@
* Validate sockaddr from userland in central functions. This resultsbluhm2017-08-111-12/+2
| | | | | | | 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-4/+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@
* Checking for IPv4 mapped addreses and dropping the packet is donebluhm2017-05-061-7/+1
| | | | | | in ip6_input(). Do not check that again in the protocol input functions. OK mpi@
* If m is not a continuous mbuf cluster, m_pullup() in pr_input maybluhm2017-05-041-3/+3
| | | | | | | change the pointer. Then *mp keeps the invalid pointer and it might be used. Fix the potential use after free and also reset *mp in other places to have less dangling pointers to freed mbufs. OK mpi@ mikeb@
* Use the address family passed down with pr_input to simplifybluhm2017-04-171-49/+23
| | | | | udp_input(). OK florian@
* Pass down the address family through the pr_input calls. Thisbluhm2017-04-141-2/+2
| | | | | allows to simplify code used for both IPv4 and IPv6. OK mikeb@ deraadt@
* When building counter memory in preparation to copy to userland, alwaysderaadt2017-04-051-2/+2
| | | | | | zero the buffers first. All the current objects appear to be safe, however future changes might introduce structure pads. Discussed with guenther, ok bluhm
* Move PRU_ATTACH out of the pr_usrreq functions into pr_attach.claudio2017-03-131-18/+22
| | | | | | | 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
* Always allocate counters memory using type M_COUNTERS.jca2017-02-051-2/+2
| | | | | | | This makes the API simpler, and is probably more useful than spreading counters memory other several types, making it harder to track. Prodded by mpi, ok mpi@ stsp@
* Use CTASSERT instead of KASSERT for a few sysctl that use the counters APIjca2017-01-311-2/+2
| | | | ok dlg@ mpi@
* Change the IPv4 pr_input function to the way IPv6 is implemented,bluhm2017-01-291-21/+14
| | | | | | | to get rid of struct ip6protosw and some wrapper functions. It is more consistent to have less different structures. The divert_input functions cannot be called anyway, so remove them. OK visa@ mpi@
* Reduce the difference between struct protosw and ip6protosw. Thebluhm2017-01-261-9/+8
| | | | | | IPv4 pr_ctlinput functions did return a void pointer that was always NULL and never used. Make all functions void like in the IPv6 case. OK mpi@
* Since raw_input() and route_input() are gone from pr_input, we canbluhm2017-01-251-8/+3
| | | | | | make the variable parameters of the protocol input functions fixed. Also add the proto to make it similar to IPv6. OK mpi@ guenther@ millert@
* Remove redundant splsoftnet().mpi2016-12-191-3/+1
| | | | ok bluhm@
* Introduce the NET_LOCK() a rwlock used to serialize accesses to the partsmpi2016-12-191-2/+2
| | | | | | | | | | | 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@
* Pass the correct offset of the next protocol field for the given IPpatrick2016-12-101-3/+9
| | | | | | | | version to the upper layers. The stack will set this field to IPIP later on, so make sure it doesn't overwrite the packet in the wrong location. ok bluhm@ deraadt@ stsp@
* Allow to build kernels without IPSEC but with PIPEX.mpi2016-11-281-2/+4
|
* Enforce that pr_usrreq functions are called at IPL_SOFTNET.mpi2016-11-211-7/+3
| | | | | | | This will allow us to keep locking simple as soon as we trade splsoftnet() for a rwlock. ok bluhm@, claudio@
* turn ipstat into a set of percpu counters.dlg2016-11-181-23/+44
| | | | | | | | | | | | | each counter is identified by an enum value which correspond to the original members of the udpstat struct. udpstat_inc(udps_foo) replaces udpstat.udps_foo++ for the actual updates. udpstat_inc is a thin wrapper around counters_inc. counters are still returned to userland via the udpstat struct for now. ok mpi@ mikeb@ deraadt@
* Remove obsolete vxlan_lookup return value handlingmikeb2016-11-031-7/+2
| | | | With input from reyk@, OK mpi
* Add support for a multipoint-to-multipoint mode in vxlan(4). In thisreyk2016-09-031-3/+19
| | | | | | | | | | | | mode, vxlan(4) must be configured to accept any virtual network identifier with "vnetid any" and added to a bridge(4) or switch(4). This way the driver will dynamically learn the tunnel endpoints and their vnetids for the responses and can be used to dynamically bridge between VXLANs. It is also being used in combination with switch(4) and the OpenFlow tunnel classifiers. With input from yasuoka@ goda@ OK deraadt@ dlg@
* Add IP_SENDSRCADDR cmsg for UDP sockets. As suggested by sthen@,vgross2016-08-161-3/+28
| | | | | | IP_SENDSRCADDR == IP_RECVDSTADDR. OK sthen@ jca@ bluhm@
* Commit in6_selectsrc() split again, with missing assignment fixed.vgross2016-08-041-3/+2
|
* Revert in_selectsrc() refactoring, it breaks IPv6.mpi2016-07-221-2/+3
| | | | | | Reported by Heiko on bugs@. ok stsp@, claudio@
* Split in6_selectsrc() into a low-level part and a pcb-level part, andvgross2016-07-201-3/+2
| | | | | | convert in_selectsrc() prototype to match. Ok bluhm@ mpi@.
* Add UDP unicast and multicast support for IP_MINTTL/IPV6_MINHOPCOUNTjca2016-06-281-3/+24
| | | | Requested by renato@, ok blumh@
* Add net.inet.{tcp,udp}.rootonly sysctl, to mark which portsvgross2016-06-181-1/+7
| | | | | | cannot be bound to by non-root users. Ok millert@ bluhm@
* Fix typo from rebase : extra parenthesevgross2016-06-151-2/+2
|
* Move the cmsg handling code on top of udp_output(), to makevgross2016-06-151-40/+42
| | | | | | IP_SENDSRCADDR introduction easier. Ok jca@
* Merge in_pcbbind() and in6_pcbbind(), and change every call tovgross2016-03-231-7/+2
| | | | | | in6_pcbbind() into in_pcbbind(). Ok jca@ mpi@
* Sync no-argument function declaration and definition by adding (void).naddy2016-03-071-2/+2
| | | | ok mpi@ millert@
* To avoid that the stack manipules the pf statekeys directly, introducebluhm2015-12-031-20/+5
| | | | | | | | | pf_inp_...() lookup, link and unlink functions as an interface. Locking can be added to them later. Remove the first linking at the beginning of tcp_input() and udp_input() as it is not necessary. It will be done later anyway. That code was a relict, from the time before I had added the second linking. Input from mikeb@ and sashan@; OK sashan@
* in6_embedscope() needs to lose some weight. Remove the last argument.claudio2015-09-111-5/+5
| | | | | | | | | In all but two calls NULL is passed and in the other 2 cases the ifp is only used to maybe feed it to in6_selecthlim() to select the hoplimit for the link. Since in6_embedscope() only works on link-local addresses it does not matter what hop limit we select since the destination is directly reachable. OK florian@ mpi@
* It is time to put inet6 on a diet. Use the flensing knife and cut outclaudio2015-09-101-2/+2
| | | | | the 3rd argument of in6_recoverscope() and make it return void. OK dlg@ mikeb@