From nobody Tue Feb 22 22:36:39 2022 X-Original-To: dev-commits-src-all@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 1AD9919E0862; Tue, 22 Feb 2022 22:36:40 +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 4K3DYN0DpNz3Jvy; Tue, 22 Feb 2022 22:36:40 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1645569400; 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=DrAVmudXzMDBS/vo1YE8MEWAqPUXfWzaZHRkYkkIoFU=; b=xycdzmjC87O8xUe2ZNJ/bFhyPs/E3OLzq/LokadGUns6lUM40Un5LTly1wDZSnCj/R5kMA ALDB9ug907I/PP2Xc3dNGrnFnhJuKPuw4vmJicMFlOnJwSUjZxPNeW+1UMGk8siI4cp/Og YQ56EkfIYo7dwR6MpJZdn20a8wwobM0Ga3n07G83Uobjwloq7i3upIPqtTupDfJSZs9SqT z/LfqDSOavS4pCAYmunsK71L564arGGUkOAU1RAHU5PGX0ItLGq1cd1At6BUvbCYZ4CQhj thisRoVpHO9f35jkodc7RiNoWrfq+p0N16dQtNPNMyMFBcD4GSJ6gwbhAm6SKg== 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 DD26E4BA6; Tue, 22 Feb 2022 22:36:39 +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 21MMadR7041915; Tue, 22 Feb 2022 22:36:39 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 21MMadMe041914; Tue, 22 Feb 2022 22:36:39 GMT (envelope-from git) Date: Tue, 22 Feb 2022 22:36:39 GMT Message-Id: <202202222236.21MMadMe041914@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Michael Tuexen Subject: git: ad9f3219d55c - stable/13 - sctp: improve handling of illegal parameters of INIT-ACK chunks List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@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/stable/13 X-Git-Reftype: branch X-Git-Commit: ad9f3219d55c4ccc3bb714cbe14b7fe64f09caf0 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1645569400; 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=DrAVmudXzMDBS/vo1YE8MEWAqPUXfWzaZHRkYkkIoFU=; b=owrturtERpSeSqae1O+biDAjcWlYOhf6Adf4gVxDDe6MqUkNLeBlq+WYtSsd17l2wl+fIx qLtniNIqjzsxG1K1J30AkFFZN1k0gQdieFmowptQqjGI58RCm3ARyX01GeOySF0MaMxBOR hJgAcZPYjy1l4WvOEUxE74DeM27/F0Kjh9PNOx1peMrLcNHoGhut3wlisePmLirvwjMRxQ PZkOeNz3nFLsap3RybJqzMiCJYT7/8IzGkjQf0DMlSg3nE5zzlR9xks5rN0QlsfUoSf5/U 04mqkO5g9boqvWCZl9ahYy0l199UmMVsTcrtVCD1INhy3g5MkY2L86y01hfMUQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1645569400; a=rsa-sha256; cv=none; b=F8PQnfrI1Up0zk+88H3103c7tEF35MNCoz5sKO4LlZi+jpy+/MLMpSOjtdXSZpdHKb1hzO 0HIGEv+JVk2XeT/Z2lHeqcOE7MCAoWmeNK0lklAHDAyFqwHoyFyW/VIMRYB7IJR54PKAUQ vEFDokWFdXSqljricLTfNsxrBuQ4KrCtGwlva3NyylLLtnnZesyc3CxxH+H+Y9D7WREmAX 34DWwupdn9EX9kLQV8ibeoNHuNxWe0xgmB8o8UJmiw2TlR/Qt4nEYxRtm1oH12Qfu6/1av AVIZKFjLnYKtsBsLxqKeWekZMIQwxuvU1EqjIb474EomLDQ6Q87+VHzT9ifUCg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=ad9f3219d55c4ccc3bb714cbe14b7fe64f09caf0 commit ad9f3219d55c4ccc3bb714cbe14b7fe64f09caf0 Author: Michael Tuexen AuthorDate: 2021-08-20 12:03:49 +0000 Commit: Michael Tuexen CommitDate: 2022-02-22 22:36:18 +0000 sctp: improve handling of illegal parameters of INIT-ACK chunks (cherry picked from commit a3665770d7d85e990f7703170a27f8e2d3e455b5) --- sys/netinet/sctp_input.c | 69 ++++++++++++++++++------------------------------ 1 file changed, 26 insertions(+), 43 deletions(-) diff --git a/sys/netinet/sctp_input.c b/sys/netinet/sctp_input.c index 5152c382b7b7..60439cf2f9e8 100644 --- a/sys/netinet/sctp_input.c +++ b/sys/netinet/sctp_input.c @@ -1244,26 +1244,23 @@ sctp_handle_init_ack(struct mbuf *m, int iphlen, int offset, "sctp_handle_init_ack: TCB is null\n"); return (-1); } - init_ack = &cp->init; - /* Validate parameters. */ - if ((ntohl(init_ack->initiate_tag) == 0) || - (ntohl(init_ack->a_rwnd) < SCTP_MIN_RWND) || - (ntohs(init_ack->num_inbound_streams) == 0) || - (ntohs(init_ack->num_outbound_streams) == 0)) { - /* protocol error... send an abort */ - op_err = sctp_generate_cause(SCTP_CAUSE_INVALID_PARAM, ""); - sctp_abort_association(stcb->sctp_ep, stcb, m, iphlen, - src, dst, sh, op_err, - mflowtype, mflowid, - vrf_id, net->port); - *abort_no_unlock = 1; - return (-1); - } - /* process according to association state... */ - switch (SCTP_GET_STATE(stcb)) { - case SCTP_STATE_COOKIE_WAIT: - /* this is the expected state for this chunk */ - /* process the INIT-ACK parameters */ + /* Only process the INIT-ACK chunk in COOKIE WAIT state. */ + if (SCTP_GET_STATE(stcb) == SCTP_STATE_COOKIE_WAIT) { + init_ack = &cp->init; + /* Validate parameters. */ + if ((ntohl(init_ack->initiate_tag) == 0) || + (ntohl(init_ack->a_rwnd) < SCTP_MIN_RWND) || + (ntohs(init_ack->num_inbound_streams) == 0) || + (ntohs(init_ack->num_outbound_streams) == 0)) { + /* One of the mandatory parameters is illegal. */ + op_err = sctp_generate_cause(SCTP_CAUSE_INVALID_PARAM, ""); + sctp_abort_association(stcb->sctp_ep, stcb, m, iphlen, + src, dst, sh, op_err, + mflowtype, mflowid, + vrf_id, net->port); + *abort_no_unlock = 1; + return (-1); + } if (stcb->asoc.primary_destination->dest_state & SCTP_ADDR_UNCONFIRMED) { /* @@ -1284,11 +1281,11 @@ sctp_handle_init_ack(struct mbuf *m, int iphlen, int offset, /* error in parsing parameters */ return (-1); } - /* update our state */ + /* Update our state. */ SCTPDBG(SCTP_DEBUG_INPUT2, "moving to COOKIE-ECHOED state\n"); SCTP_SET_STATE(stcb, SCTP_STATE_COOKIE_ECHOED); - /* reset the RTO calc */ + /* Reset the RTO calculation. */ if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_THRESHOLD_LOGGING) { sctp_misc_ints(SCTP_THRESHOLD_CLEAR, stcb->asoc.overall_error_count, @@ -1299,34 +1296,20 @@ sctp_handle_init_ack(struct mbuf *m, int iphlen, int offset, stcb->asoc.overall_error_count = 0; (void)SCTP_GETTIME_TIMEVAL(&stcb->asoc.time_entered); /* - * collapse the init timer back in case of a exponential - * backoff + * Collapse the init timer back in case of a exponential + * backoff. */ sctp_timer_start(SCTP_TIMER_TYPE_COOKIE, stcb->sctp_ep, stcb, net); /* - * the send at the end of the inbound data processing will - * cause the cookie to be sent + * The output routine at the end of the inbound data + * processing will cause the cookie to be sent. */ - break; - case SCTP_STATE_SHUTDOWN_SENT: - /* incorrect state... discard */ - break; - case SCTP_STATE_COOKIE_ECHOED: - /* incorrect state... discard */ - break; - case SCTP_STATE_OPEN: - /* incorrect state... discard */ - break; - case SCTP_STATE_EMPTY: - case SCTP_STATE_INUSE: - default: - /* incorrect state... discard */ + SCTPDBG(SCTP_DEBUG_INPUT1, "Leaving handle-init-ack end\n"); + return (0); + } else { return (-1); - break; } - SCTPDBG(SCTP_DEBUG_INPUT1, "Leaving handle-init-ack end\n"); - return (0); } static struct sctp_tcb *