Received: by 2002:ac0:8c9a:0:0:0:0:0 with SMTP id r26csp3647171ima; Mon, 4 Feb 2019 02:45:54 -0800 (PST) X-Google-Smtp-Source: ALg8bN5BpZ4i0UgRf9+12OA2K3+27Jiv+3I/X8qEaE6crNs1JQ7Qq0BCYPu4YgRVWI9Bslgmp/A0 X-Received: by 2002:a62:109b:: with SMTP id 27mr49655795pfq.227.1549277154258; Mon, 04 Feb 2019 02:45:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549277154; cv=none; d=google.com; s=arc-20160816; b=Y8Me7/rPrFCGgycmZxgr4f73zrCVd+xvdbcmQbqtDIqYKO8VgABLmGSKWCOpGy1E9O 6WQ6GnL62BNHmbWHGBG9nTjZDWwI53/bcQXGfaLUCh8Qm+83UwYSmgIg8JprXOHrgYuj Dv+/WXaOeVhyl59AJ1/5Po23oshC5eVPQdnWWmH5iWBLUHKkez5eTDR6wQYycxPqXILr KuBrKIBy+M/Gf3WAbf33H1OgPZzE+ZzYLO9l21l5jPOB5zu+hHb70CbMx04Un0meyd6Z x72duk0tG3eyGrJMo8wWyn9P8EdRRlUwXfc4ua0W9ukdACqUwl3OTUb4wX1bsSIUIsty w5hg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=f/FBlWUkrMfCNNIMiFiuP8cU3FD3z+O9XWlRxExJDQ8=; b=OwZwxCpkoeMKklPbvhvB/ZulPcp53AGx807cZEIaHuh0/EiiL6YESH394hnQ5WMw0U FgEFUDn/qBg2j1AH0wF7nnLpZLw4qomqBmC0avoe3pDRYI8vYT+x5+fmC1FI2CId5xqx gnCyJSPVWLQ9fBXQZ5HIA16cEm26x3d5StLZSAm3H/Ot9aXtmfDv9CpO/LJtdjYXM6BI bN35wvFPNnJaJyGu1ChfZ/0PVI8QnabIXYc4DWzfJdn+R9s6U3rD0n2CKmJqN2FFz/Sa WhIHyd3LLARSIG/dDOSYhyq0b40OI5pZXOlWtYOnlIYZ9RR0kqVBRdNfJJa/nv0rSYXh jcrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=LJLdiyCS; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q2si2932201plr.204.2019.02.04.02.45.38; Mon, 04 Feb 2019 02:45:54 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=LJLdiyCS; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731076AbfBDKop (ORCPT + 99 others); Mon, 4 Feb 2019 05:44:45 -0500 Received: from mail.kernel.org ([198.145.29.99]:42592 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730254AbfBDKon (ORCPT ); Mon, 4 Feb 2019 05:44:43 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B47132070C; Mon, 4 Feb 2019 10:44:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549277082; bh=tVSoC78QT16o00EGtdGy8L6UAm5xwitBReZNAOVtypY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LJLdiyCSdhafcUVB04JOMSwUAIwT5Ed9IlZLfr7FkaoT7GGAUTl/VSVAXAfhHHYRR 7xrMtLoAsokvIAmhInBGlYRIvsT/At78cZzXn7RDphnvMUZRWxj+I0dqI71pMAZV4E Ke+6ceDbcFVQofXQmakDjPueQ8rFF6BhJJiuSxGo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ying Xu , Xin Long , "David S. Miller" Subject: [PATCH 4.14 16/46] sctp: improve the events for sctp stream reset Date: Mon, 4 Feb 2019 11:36:47 +0100 Message-Id: <20190204103611.512896461@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190204103608.651205056@linuxfoundation.org> References: <20190204103608.651205056@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Xin Long [ Upstream commit 2e6dc4d95110becfe0ff4c3d4749c33ea166e9e7 ] This patch is to improve sctp stream reset events in 4 places: 1. In sctp_process_strreset_outreq(), the flag should always be set with SCTP_STREAM_RESET_INCOMING_SSN instead of OUTGOING, as receiver's in stream is reset here. 2. In sctp_process_strreset_outreq(), move up SCTP_STRRESET_ERR_WRONG_SSN check, as the reset has to succeed after reconf_timer stops for the in stream reset request retransmission. 3. In sctp_process_strreset_inreq(), no event should be sent, as no in or out stream is reset here. 4. In sctp_process_strreset_resp(), SCTP_STREAM_RESET_INCOMING_SSN or OUTGOING event should always be sent for stream reset requests, no matter it fails or succeeds to process the request. Fixes: 810544764536 ("sctp: implement receiver-side procedures for the Outgoing SSN Reset Request Parameter") Fixes: 16e1a91965b0 ("sctp: implement receiver-side procedures for the Incoming SSN Reset Request Parameter") Fixes: 11ae76e67a17 ("sctp: implement receiver-side procedures for the Reconf Response Parameter") Reported-by: Ying Xu Signed-off-by: Xin Long Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/sctp/stream.c | 39 +++++++++++++++++---------------------- 1 file changed, 17 insertions(+), 22 deletions(-) --- a/net/sctp/stream.c +++ b/net/sctp/stream.c @@ -360,9 +360,9 @@ struct sctp_chunk *sctp_process_strreset struct sctp_strreset_outreq *outreq = param.v; struct sctp_stream *stream = &asoc->stream; __u32 result = SCTP_STRRESET_DENIED; - __u16 i, nums, flags = 0; __be16 *str_p = NULL; __u32 request_seq; + __u16 i, nums; request_seq = ntohl(outreq->request_seq); @@ -390,6 +390,15 @@ struct sctp_chunk *sctp_process_strreset if (!(asoc->strreset_enable & SCTP_ENABLE_RESET_STREAM_REQ)) goto out; + nums = (ntohs(param.p->length) - sizeof(*outreq)) / sizeof(__u16); + str_p = outreq->list_of_streams; + for (i = 0; i < nums; i++) { + if (ntohs(str_p[i]) >= stream->incnt) { + result = SCTP_STRRESET_ERR_WRONG_SSN; + goto out; + } + } + if (asoc->strreset_chunk) { if (!sctp_chunk_lookup_strreset_param( asoc, outreq->response_seq, @@ -412,32 +421,19 @@ struct sctp_chunk *sctp_process_strreset sctp_chunk_put(asoc->strreset_chunk); asoc->strreset_chunk = NULL; } - - flags = SCTP_STREAM_RESET_INCOMING_SSN; } - nums = (ntohs(param.p->length) - sizeof(*outreq)) / 2; - if (nums) { - str_p = outreq->list_of_streams; - for (i = 0; i < nums; i++) { - if (ntohs(str_p[i]) >= stream->incnt) { - result = SCTP_STRRESET_ERR_WRONG_SSN; - goto out; - } - } - + if (nums) for (i = 0; i < nums; i++) stream->in[ntohs(str_p[i])].ssn = 0; - } else { + else for (i = 0; i < stream->incnt; i++) stream->in[i].ssn = 0; - } result = SCTP_STRRESET_PERFORMED; *evp = sctp_ulpevent_make_stream_reset_event(asoc, - flags | SCTP_STREAM_RESET_OUTGOING_SSN, nums, str_p, - GFP_ATOMIC); + SCTP_STREAM_RESET_INCOMING_SSN, nums, str_p, GFP_ATOMIC); out: sctp_update_strreset_result(asoc, result); @@ -507,9 +503,6 @@ struct sctp_chunk *sctp_process_strreset result = SCTP_STRRESET_PERFORMED; - *evp = sctp_ulpevent_make_stream_reset_event(asoc, - SCTP_STREAM_RESET_INCOMING_SSN, nums, str_p, GFP_ATOMIC); - out: sctp_update_strreset_result(asoc, result); err: @@ -802,10 +795,10 @@ struct sctp_chunk *sctp_process_strreset for (i = 0; i < stream->outcnt; i++) stream->out[i].ssn = 0; } - - flags = SCTP_STREAM_RESET_OUTGOING_SSN; } + flags |= SCTP_STREAM_RESET_OUTGOING_SSN; + for (i = 0; i < stream->outcnt; i++) stream->out[i].state = SCTP_STREAM_OPEN; @@ -823,6 +816,8 @@ struct sctp_chunk *sctp_process_strreset str_p = inreq->list_of_streams; nums = (ntohs(inreq->param_hdr.length) - sizeof(*inreq)) / 2; + flags |= SCTP_STREAM_RESET_INCOMING_SSN; + *evp = sctp_ulpevent_make_stream_reset_event(asoc, flags, nums, str_p, GFP_ATOMIC); } else if (req->type == SCTP_PARAM_RESET_TSN_REQUEST) {