From nobody Wed May 03 18:32:05 2023 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4QBQXP3MWvz497bf; Wed, 3 May 2023 18:32:05 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4QBQXP2V6pz3KmQ; Wed, 3 May 2023 18:32:05 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1683138725; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=l4ErhG72MgE52ZfqLDcCnWHfwXv3T+1i7hQ/oNEQqE8=; b=iVT787ws+4OnJrslfdASlT2gJIIPPkhrA2eig8Xst1eoGq0hyNkO+3v+d8t8NFLQbH5ctf xyG7k3OwGTv2zO0KELBiAvIs67O5QsOriUVVUKcChNT4iQfBgyklk/SiEkcE2NEBxX/5o9 oigbG6sfVwBju/CD5kNpRcaf/JXtHFotHWRPfxV1B9GOLXsIM//xCkXEjKo3RQrY7ydzOa ap4zjFEu514r3E7EfBOp7TB2FV00lm0RxItJpuFc9ogwxYEP6u6bVzLCyy4httIaOt+Elq twQol6glK4+VTGL+/BzunEHUbWxugyq8k4uo/1AfZrUhUUaCWMpLuxLo8ZC47Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1683138725; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=l4ErhG72MgE52ZfqLDcCnWHfwXv3T+1i7hQ/oNEQqE8=; b=mdM5v3GyVovlNP06AKhfw+8obtVRrl/ILGv42XlV1mB3jw55hLKIO6gl7k6rqXHq9mmEFZ Mh1EAnOTkhPiCuPWWg/UO/jmmiLyyJC4BHQb2p49su8gYIyo35qbFYGAD2ALRJoY6rfWwm 4Bn4RHSA6Uhk3BiIU2Z7ZplV97c1IONmu3HeGvxp0/DrJB66ReDMYwk0FS8m+Pv4g6A0yY UzR4X5paD+UQ3jA08BDdWiUEsD1vnsenwnS8zKHYZa/q7FvACm5FkYOYOm4ThMjr5lLsiH mkUR2Lo5OzkB3sPniGitUcnXtbstYyoo62+RHQOC2dUXPILoMXrXgE2oSdfCjw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1683138725; a=rsa-sha256; cv=none; b=yUcF+N+GR26sp0LNGNDVkx6O1jswq6HgGgKoMayTXq18euRQWuWwQWWuClOWikgxoH84Jx yVSSRsiDC1ZpJOpSltnCQme1ch0fEQLbcJ0uZP8flAywMqdlu1rx+LjGrEi7ELIgIrsNbL uxEiNmHw9u7lRE6Ng3puzjuQlR+uBxFFrUy1hM3xdxnypW9gZhRDpsGVS/cFwweqtWLjYD 2J7YkKwnSbkDf9VfxxacZrGoOyukCDwmCj/2FGev0/HyLPGlAq8YcZPUFz5VjOLPnhVxZS vM2gnOyg+ZN7pt+QSfmOSflVEhOczA3pt0T+PlhwWieHkqIhT8Zo26E073EL3g== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4QBQXP1Ym9zggL; Wed, 3 May 2023 18:32:05 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 343IW5sT069925; Wed, 3 May 2023 18:32:05 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 343IW5hq069924; Wed, 3 May 2023 18:32:05 GMT (envelope-from git) Date: Wed, 3 May 2023 18:32:05 GMT Message-Id: <202305031832.343IW5hq069924@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Michael Tuexen Subject: git: 04ede3675e44 - main - sctp: only start shutdown guard timer when sending SHUTDOWN chunk List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: tuexen X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 04ede3675e44847c3e9e4a9bd44509cdf42ed60a Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=04ede3675e44847c3e9e4a9bd44509cdf42ed60a commit 04ede3675e44847c3e9e4a9bd44509cdf42ed60a Author: Michael Tuexen AuthorDate: 2023-05-03 18:28:46 +0000 Commit: Michael Tuexen CommitDate: 2023-05-03 18:28:46 +0000 sctp: only start shutdown guard timer when sending SHUTDOWN chunk The intention is to protect a malicious peer not following the shutdown procedures. MFC after: 1 week --- sys/netinet/sctp_input.c | 14 -------------- sys/netinet/sctp_output.c | 4 ---- sys/netinet/sctp_pcb.c | 1 - sys/netinet/sctp_usrreq.c | 6 +++--- 4 files changed, 3 insertions(+), 22 deletions(-) diff --git a/sys/netinet/sctp_input.c b/sys/netinet/sctp_input.c index fc362d091a22..5a7ed6ffde90 100644 --- a/sys/netinet/sctp_input.c +++ b/sys/netinet/sctp_input.c @@ -1501,10 +1501,6 @@ sctp_process_cookie_existing(struct mbuf *m, int iphlen, int offset, SCTP_STAT_INCR_COUNTER32(sctps_collisionestab); SCTP_SET_STATE(stcb, SCTP_STATE_OPEN); - if (asoc->state & SCTP_STATE_SHUTDOWN_PENDING) { - sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD, - stcb->sctp_ep, stcb, NULL); - } SCTP_STAT_INCR_GAUGE32(sctps_currestab); sctp_stop_all_cookie_timers(stcb); if (((stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) || @@ -1718,10 +1714,6 @@ sctp_process_cookie_existing(struct mbuf *m, int iphlen, int offset, SCTP_STAT_INCR_COUNTER32(sctps_collisionestab); } SCTP_SET_STATE(stcb, SCTP_STATE_OPEN); - if (asoc->state & SCTP_STATE_SHUTDOWN_PENDING) { - sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD, - stcb->sctp_ep, stcb, NULL); - } sctp_stop_all_cookie_timers(stcb); sctp_toss_old_cookies(stcb, asoc); sctp_send_cookie_ack(stcb); @@ -1788,8 +1780,6 @@ sctp_process_cookie_existing(struct mbuf *m, int iphlen, int offset, } if (asoc->state & SCTP_STATE_SHUTDOWN_PENDING) { SCTP_SET_STATE(stcb, SCTP_STATE_OPEN); - sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD, - stcb->sctp_ep, stcb, NULL); } else if (SCTP_GET_STATE(stcb) != SCTP_STATE_SHUTDOWN_SENT) { /* move to OPEN state, if not in SHUTDOWN_SENT */ @@ -2176,10 +2166,6 @@ sctp_process_cookie_new(struct mbuf *m, int iphlen, int offset, /* update current state */ SCTPDBG(SCTP_DEBUG_INPUT2, "moving to OPEN state\n"); SCTP_SET_STATE(stcb, SCTP_STATE_OPEN); - if (asoc->state & SCTP_STATE_SHUTDOWN_PENDING) { - sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD, - stcb->sctp_ep, stcb, NULL); - } sctp_stop_all_cookie_timers(stcb); SCTP_STAT_INCR_COUNTER32(sctps_passiveestab); SCTP_STAT_INCR_GAUGE32(sctps_currestab); diff --git a/sys/netinet/sctp_output.c b/sys/netinet/sctp_output.c index 3b9a06b72d8a..fdea88002194 100644 --- a/sys/netinet/sctp_output.c +++ b/sys/netinet/sctp_output.c @@ -6768,8 +6768,6 @@ sctp_sendall_iterator(struct sctp_inpcb *inp, struct sctp_tcb *stcb, void *ptr, atomic_subtract_int(&stcb->asoc.refcnt, 1); goto no_chunk_output; } - sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD, stcb->sctp_ep, stcb, - NULL); } } } @@ -13562,8 +13560,6 @@ dataless_eof: error = ECONNABORTED; goto out; } - sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD, stcb->sctp_ep, stcb, - NULL); sctp_feature_off(inp, SCTP_PCB_FLAGS_NODELAY); } } diff --git a/sys/netinet/sctp_pcb.c b/sys/netinet/sctp_pcb.c index 7567764bfd72..4e97dc4e7ad3 100644 --- a/sys/netinet/sctp_pcb.c +++ b/sys/netinet/sctp_pcb.c @@ -3461,7 +3461,6 @@ sctp_inpcb_free(struct sctp_inpcb *inp, int immediate, int from) } else { /* mark into shutdown pending */ SCTP_ADD_SUBSTATE(stcb, SCTP_STATE_SHUTDOWN_PENDING); - sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD, stcb->sctp_ep, stcb, NULL); if ((*stcb->asoc.ss_functions.sctp_ss_is_user_msgs_incomplete) (stcb, &stcb->asoc)) { SCTP_ADD_SUBSTATE(stcb, SCTP_STATE_PARTIAL_MSG_LEFT); } diff --git a/sys/netinet/sctp_usrreq.c b/sys/netinet/sctp_usrreq.c index 6e17545c9a3b..917d301a85dc 100644 --- a/sys/netinet/sctp_usrreq.c +++ b/sys/netinet/sctp_usrreq.c @@ -736,7 +736,7 @@ sctp_disconnect(struct socket *so) stcb->sctp_ep, stcb, netp); sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD, stcb->sctp_ep, stcb, NULL); - sctp_chunk_output(stcb->sctp_ep, stcb, SCTP_OUTPUT_FROM_T3, SCTP_SO_LOCKED); + sctp_chunk_output(stcb->sctp_ep, stcb, SCTP_OUTPUT_FROM_CLOSING, SCTP_SO_LOCKED); } } else { /* @@ -750,7 +750,6 @@ sctp_disconnect(struct socket *so) * and move to SHUTDOWN-PENDING */ SCTP_ADD_SUBSTATE(stcb, SCTP_STATE_SHUTDOWN_PENDING); - sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD, stcb->sctp_ep, stcb, NULL); if ((*asoc->ss_functions.sctp_ss_is_user_msgs_incomplete) (stcb, asoc)) { SCTP_ADD_SUBSTATE(stcb, SCTP_STATE_PARTIAL_MSG_LEFT); } @@ -933,6 +932,8 @@ sctp_shutdown(struct socket *so) sctp_send_shutdown(stcb, netp); sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWN, stcb->sctp_ep, stcb, netp); + sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD, + stcb->sctp_ep, stcb, NULL); } else { /* * We still got (or just got) data to send, so set @@ -957,7 +958,6 @@ sctp_shutdown(struct socket *so) return (0); } } - sctp_timer_start(SCTP_TIMER_TYPE_SHUTDOWNGUARD, stcb->sctp_ep, stcb, NULL); /* * XXX: Why do this in the case where we have still data * queued?