Commit graph

7056 commits

Author SHA1 Message Date
Franco Fichtner
d3e338662f netinet: simplify RSS ifdef statements
Approved by:	transport (rrs)
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D31583

(cherry picked from commit 47ded797ce)
2022-03-03 08:56:22 -07:00
Kristof Provost
4bca16a4fb netinet: allow UDP tunnels to be removed
udp_set_kernel_tunneling() rejects new callbacks if one is already set.
Allow callbacks to be cleared. The use case for this is OpenVPN DCO,
where the socket is opened by userspace and then adopted by the kernel
to run the tunnel. If the DCO interface is removed but userspace does
not close the socket (something the kernel cannot prevent) the installed
callbacks could be called with an invalidated context.

Allow new functions to be set, but only if they're NULL (i.e. allow the
callback functions to be cleared).

Reviewed by:	tuexen
MFC after:	3 weeks
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D34288

(cherry picked from commit 995cba5a0c)
2022-02-28 16:38:05 +01:00
Robert Wing
95eea15111 tcp_twrespond: send signed segment when connection is TCP-MD5
When a connection is established to use TCP-MD5, tcp_twrespond() doesn't
respond with a signed segment. This results in the host performing the
active close to remain in a TIME_WAIT state and the other host in the
LAST_ACK state. Fix this by sending a signed segment when the connection
is established to use TCP-MD5.

Reviewed by:	glebius
Differential Revision:	https://reviews.freebsd.org/D33490

(cherry picked from commit 2a28b045ca)
2022-02-23 09:19:59 -09:00
Robert Wing
bcc9518b98 Fix dtrace SDT probe tcp:::debug-input
The tcp:::debug-input probe is passed an mbuf pointer, use the correct
translator for ipinfo_t when defining tcp:::debug-input.

Fixes:  82988b50a1 ("Add an mbuf to ipinfo_t translator to finish ...")
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D33066

(cherry picked from commit 08d157a832)
2022-02-23 08:47:40 -09:00
Michael Tuexen
985883fd13 sctp: remove KASSERT() which not always holds
Reported by:	syzbot+c907045aed2043011f3c@syzkaller.appspotmail.com

(cherry picked from commit bdb99f6f5e)
2022-02-23 01:19:41 +01:00
Michael Tuexen
af04a618ed sctp: make sure new locking requirements are satisfied.
Reported by:	syzbot+cd3c1dd64861b8c200bd@syzkaller.appspotmail.com

(cherry picked from commit e255f0c9fb)
2022-02-23 01:19:01 +01:00
Michael Tuexen
73fd476901 sctp: don't hold the assoc create lock longer than needed
Reported by:	syzbot+c738e3df67cf425c49a2@syzkaller.appspotmail.com

(cherry picked from commit 2f0656fb9b)
2022-02-23 01:18:05 +01:00
Michael Tuexen
f37224f026 sctp: cleanup sctp_lower_sosend
This is a preparation for retiring the tcp send lock in the
next step.

(cherry picked from commit a4a31271cc)
2022-02-23 01:17:25 +01:00
Michael Tuexen
153446e530 sctp: improve robustness
(cherry picked from commit fd0d53f85c)
2022-02-23 01:16:36 +01:00
Michael Tuexen
03e166d6ea sctp: cleanup, no functional change intended.
(cherry picked from commit 274a0e4a8d)
2022-02-23 01:15:43 +01:00
Michael Tuexen
5871b7c81a sctp: remove unused parameter
(cherry picked from commit 3ca204c97a)
2022-02-23 01:14:53 +01:00
Michael Tuexen
948608b013 sctp: fix a signed/unsigned mismatch.
(cherry picked from commit 11c4d4b966)
2022-02-23 01:14:07 +01:00
Michael Tuexen
b6e6748b2b sctp: avoid undefined behaviour and cleanup the code.
(cherry picked from commit 76e03cc940)
2022-02-23 01:13:10 +01:00
Michael Tuexen
b20c5963de sctp: improve counting of incoming chunks
(cherry picked from commit 502d5e8500)
2022-02-23 01:07:31 +01:00
Michael Tuexen
30cba4faf1 udp: use appropriate pcbinfo when signalling EHOSTDOWN
Sponsored by:	Netflix, Inc.

(cherry picked from commit 4760956e9a)
2022-02-23 01:00:38 +01:00
Michael Tuexen
f921b952dc sctp: retire sctp_mtu_size_reset()
Thanks to Timo Voelker for making me aware that sctp_mtu_size_reset()
is very similar to sctp_pathmtu_adjustment().

(cherry picked from commit 1adb91e521)
2022-02-23 00:58:56 +01:00
Michael Tuexen
81a1bfac59 sctp: improve sctp_pathmtu_adjustment()
Allow the resending of DATA chunks to be controlled by the caller,
which allows retiring sctp_mtu_size_reset() in a separate commit.
Also improve the computaion of the overhead and use 32-bit integers
consistently.
Thanks to Timo Voelker for pointing me to the code.

(cherry picked from commit 2de2ae331b)
2022-02-23 00:58:06 +01:00
Michael Tuexen
fe06ce5232 sctp: minor improvements in sctp_get_frag_point
(cherry picked from commit a7ba00a438)
2022-02-23 00:57:06 +01:00
Michael Tuexen
0f63c2d187 sctp: check that the computed frag point is a multiple of 4
Reported by:	syzbot+5da189fc1fe80b31f5bd@syzkaller.appspotmail.com

(cherry picked from commit ca0dd19f09)
2022-02-23 00:56:17 +01:00
Michael Tuexen
ff4150b9a5 sctp: cleanup the SCTP_MAXSEG socket option.
This patch makes the handling of the SCTP_MAXSEG socket option
compliant with RFC 6458 (SCTP socket API) and fixes an issue
found by syzkaller.

Reported by:	syzbot+a2791b89ab99121e3333@syzkaller.appspotmail.com

(cherry picked from commit 989453da05)
2022-02-23 00:55:23 +01:00
Michael Tuexen
a27063a574 sctp: cleanup, on functional change intended.
(cherry picked from commit 34ae6a1a44)
2022-02-23 00:54:24 +01:00
Michael Tuexen
4abd7785da sctp: apply limit for socket buffers as indicated in comment
(cherry picked from commit a859e9f9aa)
2022-02-23 00:53:31 +01:00
Michael Tuexen
f801f2c762 sctp: improve consistency, no functional change intended
(cherry picked from commit 3c1ba6f394)
2022-02-23 00:27:28 +01:00
Michael Tuexen
7c17c354ff sctp: add some asserts, no functional changes intended
This might help in narrowing down
https://syzkaller.appspot.com/bug?id=fbd79abaec55f5aede63937182f4247006ea883b

(cherry picked from commit 0906362646)
2022-02-23 00:26:35 +01:00
Michael Tuexen
0f448d4338 sctp: improve KASSERT messages
(cherry picked from commit bd19202c92)
2022-02-22 23:59:52 +01:00
Michael Tuexen
615ff3cb60 sctp: don't keep being locked on a stream which is removed
Reported by:	syzbot+f5f551e8a3a0302a4914@syzkaller.appspotmail.com

(cherry picked from commit 3ff3733991)
2022-02-22 23:59:05 +01:00
Michael Tuexen
932fc05901 sctp: provide a specific stream scheduler function for FCFS
A KASSERT in the genric routine does not apply and triggers
incorrectly.

Reported by:	syzbot+8435af157238c6a11430@syzkaller.appspotmail.com

(cherry picked from commit 28ea947078)
2022-02-22 23:58:10 +01:00
Michael Tuexen
ba0ac9095a sctp: cleanup and adding KASSERT()s, no functional change
(cherry picked from commit fa947a3687)
2022-02-22 23:57:22 +01:00
Michael Tuexen
d67ef74735 sctp: fix usage of stream scheduler functions
sctp_ss_scheduled() should only be called for streams that are
scheduled. So call sctp_ss_remove_from_stream() before it.
This bug was uncovered by the earlier cleanup.

Reported by:	syzbot+bbf739922346659df4b2@syzkaller.appspotmail.com
Reported by:	syzbot+0a0857458f4a7b0507c8@syzkaller.appspotmail.com
Reported by:	syzbot+a0b62c6107b34a04e54d@syzkaller.appspotmail.com
Reported by:	syzbot+0aa0d676429ebcd53299@syzkaller.appspotmail.com
Reported by:	syzbot+104cc0c1d3ccf2921c1d@syzkaller.appspotmail.com

(cherry picked from commit 5b53e749a9)
2022-02-22 23:56:26 +01:00
Michael Tuexen
d7351c4104 sctp: avoid locking an already locked mutex
Reported by:	syzbot+f048680690f2e8d7ddad@syzkaller.appspotmail.com
Reported by:	syzbot+0725c712ba89d123c2e9@syzkaller.appspotmail.com

(cherry picked from commit 171633765c)
2022-02-22 23:55:45 +01:00
Michael Tuexen
b529329487 sctp: Cleanup stream schedulers.
No functional change intended.

(cherry picked from commit 414499b3f9)
2022-02-22 23:54:42 +01:00
Michael Tuexen
c0f034484a sctp: Simplify stream scheduler usage
Callers are getting the stcb send lock, so just KASSERT that.
No need to signal this when calling stream scheduler functions.
No functional change intended.

(cherry picked from commit 762ae0ec8d)
2022-02-22 23:53:52 +01:00
Michael Tuexen
1df7036fdd sctp: improve consistency when calling stream scheduler
Hold always the stcb send lock when calling sctp_ss_init() and
sctp_ss_remove_from_stream().

(cherry picked from commit 0b79a76f84)
2022-02-22 23:53:07 +01:00
Michael Tuexen
eb426ae323 sctp: use a valid outstream when adding it to the scheduler
Without holding the stcb send lock, the outstreams might get
reallocated if the number of streams are increased.

Reported by:	syzbot+4a5431d7caa666f2c19c@syzkaller.appspotmail.com
Reported by:	syzbot+aa2e3b013a48870e193d@syzkaller.appspotmail.com
Reported by:	syzbot+e4368c3bde07cd2fb29f@syzkaller.appspotmail.com
Reported by:	syzbot+fe2f110e34811ea91690@syzkaller.appspotmail.com
Reported by:	syzbot+ed6e8de942351d0309f4@syzkaller.appspotmail.com

(cherry picked from commit 34b1efcea1)
2022-02-22 23:52:20 +01:00
Michael Tuexen
c05bf58603 sctp: fix FCFS stream scheduler
Reported by:	syzbot+c6793f0f0ce698bce230@syzkaller.appspotmail.com

(cherry picked from commit e19d93b19d)
2022-02-22 23:51:26 +01:00
Michael Tuexen
e79dff84b1 sctp: cleanup, no functional change intended
(cherry picked from commit 4542164685)
2022-02-22 23:50:33 +01:00
Michael Tuexen
91ef9a745e sctp: avoid LOR
Don't lock the inp-info lock while holding an stcb lock.

Differential Revision:	https://reviews.freebsd.org/D31921

(cherry picked from commit 29545986bd)
2022-02-22 23:49:39 +01:00
Michael Tuexen
e24d4d533f sctp: minor cleanup, no functional change
(cherry picked from commit 4181fa2a20)
2022-02-22 23:48:24 +01:00
Mark Johnston
aa16c2fcaf sctp: Tighten up locking around sctp_aloc_assoc()
All callers of sctp_aloc_assoc() mark the PCB as connected after a
successful call (for one-to-one-style sockets).  In all cases this is
done without the PCB lock, so the PCB's flags can be corrupted.  We also
do not atomically check whether a one-to-one-style socket is a listening
socket, which violates various assumptions in solisten_proto().

We need to hold the PCB lock across all of sctp_aloc_assoc() to fix
this.  In order to do that without introducing lock order reversals, we
have to hold the global info lock as well.

So:
- Convert sctp_aloc_assoc() so that the inp and info locks are
  consistently held.  It returns with the association lock held, as
  before.
- Fix an apparent bug where we failed to remove an association from a
  global hash if sctp_add_remote_addr() fails.
- sctp_select_a_tag() is called when initializing an association, and it
  acquires the global info lock.  To avoid lock recursion, push locking
  into its callers.
- Introduce sctp_aloc_assoc_connected(), which atomically checks for a
  listening socket and sets SCTP_PCB_FLAGS_CONNECTED.

There is still one edge case in sctp_process_cookie_new() where we do
not update PCB/socket state correctly.

Reviewed by:	tuexen
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D31908

(cherry picked from commit 2d5c48eccd)
2022-02-22 23:47:28 +01:00
Michael Tuexen
238e4a1179 sctp: add explicit cast, no functional change intended
(cherry picked from commit 3ea2cdd45e)
2022-02-22 23:42:37 +01:00
Michael Tuexen
5fb0f68396 sctp: use appropriate argument when freeing association
Reported by:	syzbot+7fe26e26911344e7211d@syzkaller.appspotmail.com

(cherry picked from commit 0c1a20beb4)
2022-02-22 23:41:37 +01:00
Michael Tuexen
7d2c146991 sctp: cleanup timewait handling for vtags
(cherry picked from commit 58a7bf124c)
2022-02-22 23:40:21 +01:00
Michael Tuexen
e02d28a7bb sctp: minor cleanups, no functional change intended
(cherry picked from commit aab1d593b2)
2022-02-22 23:39:26 +01:00
Michael Tuexen
2a2dd4bd43 tcp: make network epoch expectations of LRO explicit
Reviewed by:		gallatin, hselasky
Sponsored by:		Netflix, Inc.
Differential Revision:	https://reviews.freebsd.org/D31648

(cherry picked from commit dc6ab77d66)
2022-02-22 23:37:44 +01:00
Michael Tuexen
ad9f3219d5 sctp: improve handling of illegal parameters of INIT-ACK chunks
(cherry picked from commit a3665770d7)
2022-02-22 23:36:18 +01:00
Michael Tuexen
75102e8fb9 sctp: improve handling of INIT chunks with invalid parameters
(cherry picked from commit eba8e643b1)
2022-02-22 23:35:17 +01:00
Michael Tuexen
bc107e4e59 sctp: remove some set, but unused variables
Thanks to pkasting for submitting the patch for the userland stack.

(cherry picked from commit 3808ab732e)
2022-02-22 23:34:09 +01:00
Michael Tuexen
4b3cfa86d0 sctp: improve input validation of mapped addresses in sctp_connectx()
(cherry picked from commit 112899c6af)
2022-02-22 23:30:20 +01:00
Michael Tuexen
946fc2cb73 sctp: improve input validation of mapped addresses in send()
Reported by:	syzbot+35528f275f2eea6317cc@syzkaller.appspotmail.com
Reported by:	syzbot+ac29916d5f16d241553d@syzkaller.appspotmail.com

(cherry picked from commit b732091a76)
2022-02-22 23:28:53 +01:00
Michael Tuexen
db8fc0ef23 tcp, udp: improve input validation in handling bind()
Reported by:		syzbot+24fcfd8057e9bc339295@syzkaller.appspotmail.com
Reported by:		syzbot+6e90ceb5c89285b2655b@syzkaller.appspotmail.com
Reviewed by:		markj, rscheff
Sponsored by:		Netflix, Inc.
Differential Revision:	https://reviews.freebsd.org/D31422

(cherry picked from commit 3f1f6b6ef7)
2022-02-22 23:27:01 +01:00