Received: by 10.223.176.5 with SMTP id f5csp989678wra; Fri, 2 Feb 2018 09:19:34 -0800 (PST) X-Google-Smtp-Source: AH8x224ojPy7hraihtx6EpB8Wm0HsOgle4Nvw9M1Vfdgf4WRJ8PfNt3R8N1uZB8X9tNhbpqKU+nD X-Received: by 2002:a17:902:102:: with SMTP id 2-v6mr35685362plb.178.1517591974040; Fri, 02 Feb 2018 09:19:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517591974; cv=none; d=google.com; s=arc-20160816; b=pvyceHpCccgpR33xX9PnQ2TephZvdM1/6Tt5gn6joEf4fPle4qTgTR7i/NorAmvjFz q7SJgnW3w1Kh9dgykoxRh1VzePBt7jiXckKSIGY1/rbz9/eZtX0uUHA9MZRKZB7dAX4U 3LpQ9MZVpp477UlKI7V7iYt8EEdYYfmzgtScvIpbjstzh9eYybePP7v5MLxUCSkGBgji ryHmGgpWVGHbIwnXT6Ef3vuyPzYdkMOYNMHEmG2Q9I+K1R5+DsEyscUNAUxGyGIDo3hf fjC7sNIU0xLzSifOnleFvzPePkTi5LUqcgNJzoOJ5BBqb4oAoRWpYHrf2M0X0xf+D7aC XDIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=31807pIAv9n2+Zh7QhBzyK+hG5BUrXc0GiNTncabKfE=; b=kR1hdGuPKdkeTYVX2St9WKD/mqMQ9il6f151Wt9sBDnenb/Bag/+b2G/dy8RH7p5cJ j+s3sa7jzBgOPytPRa/lwzrg3vzg+5oGcsA//MrBSrffzaC8TYmedcTqd3Kz5OFEXWkR nrUqZP2JKkIg+WrblEb0ySGBOXbWRC9eIPXZRunF0eb6BWG2ITSnvTmT3NXzZ/zJz8U9 yTR2K2w4GJY6TDleTRGTZzNwkid0Qz6gNKAWJOuVhmwcdFyTIpjxgFiiv0JY2WGXZBvu uzRFPCLuAk9DT6ixque/Kjt1XqghbOjiVH34HTMA4ZERzEnz5de2AJg0OVbY9gs7P2Ju 0SlA== ARC-Authentication-Results: i=1; mx.google.com; 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 e3si205224pfi.191.2018.02.02.09.19.19; Fri, 02 Feb 2018 09:19:33 -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; 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 S1753574AbeBBRSr (ORCPT + 99 others); Fri, 2 Feb 2018 12:18:47 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:38740 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753146AbeBBRLn (ORCPT ); Fri, 2 Feb 2018 12:11:43 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id E7E64F09; Fri, 2 Feb 2018 17:11:42 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Xin Long , Marcelo Ricardo Leitner , "David S. Miller" , Sasha Levin Subject: [PATCH 4.14 073/156] sctp: avoid flushing unsent queue when doing asoc reset Date: Fri, 2 Feb 2018 17:57:34 +0100 Message-Id: <20180202140843.584159834@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180202140840.242829545@linuxfoundation.org> References: <20180202140840.242829545@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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 159f2a7456c6ae95c1e1a58e8b8ec65ef12d51cf ] Now when doing asoc reset, it cleans up sacked and abandoned queues by calling sctp_outq_free where it also cleans up unsent, retransmit and transmitted queues. It's safe for the sender of response, as these 3 queues are empty at that time. But when the receiver of response is doing the reset, the users may already enqueue some chunks into unsent during the time waiting the response, and these chunks should not be flushed. To void the chunks in it would be removed, it moves the queue into a temp list, then gets it back after sctp_outq_free is done. The patch also fixes some incorrect comments in sctp_process_strreset_tsnreq. Signed-off-by: Xin Long Acked-by: Marcelo Ricardo Leitner Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- net/sctp/stream.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) --- a/net/sctp/stream.c +++ b/net/sctp/stream.c @@ -563,9 +563,10 @@ struct sctp_chunk *sctp_process_strreset goto out; } - /* G3: The same processing as though a SACK chunk with no gap report - * and a cumulative TSN ACK of the Sender's Next TSN minus 1 were - * received MUST be performed. + /* G4: The same processing as though a FWD-TSN chunk (as defined in + * [RFC3758]) with all streams affected and a new cumulative TSN + * ACK of the Receiver's Next TSN minus 1 were received MUST be + * performed. */ max_tsn_seen = sctp_tsnmap_get_max_tsn_seen(&asoc->peer.tsn_map); sctp_ulpq_reasm_flushtsn(&asoc->ulpq, max_tsn_seen); @@ -580,10 +581,9 @@ struct sctp_chunk *sctp_process_strreset sctp_tsnmap_init(&asoc->peer.tsn_map, SCTP_TSN_MAP_INITIAL, init_tsn, GFP_ATOMIC); - /* G4: The same processing as though a FWD-TSN chunk (as defined in - * [RFC3758]) with all streams affected and a new cumulative TSN - * ACK of the Receiver's Next TSN minus 1 were received MUST be - * performed. + /* G3: The same processing as though a SACK chunk with no gap report + * and a cumulative TSN ACK of the Sender's Next TSN minus 1 were + * received MUST be performed. */ sctp_outq_free(&asoc->outqueue); @@ -844,6 +844,7 @@ struct sctp_chunk *sctp_process_strreset if (result == SCTP_STRRESET_PERFORMED) { __u32 mtsn = sctp_tsnmap_get_max_tsn_seen( &asoc->peer.tsn_map); + LIST_HEAD(temp); sctp_ulpq_reasm_flushtsn(&asoc->ulpq, mtsn); sctp_ulpq_abort_pd(&asoc->ulpq, GFP_ATOMIC); @@ -852,7 +853,13 @@ struct sctp_chunk *sctp_process_strreset SCTP_TSN_MAP_INITIAL, stsn, GFP_ATOMIC); + /* Clean up sacked and abandoned queues only. As the + * out_chunk_list may not be empty, splice it to temp, + * then get it back after sctp_outq_free is done. + */ + list_splice_init(&asoc->outqueue.out_chunk_list, &temp); sctp_outq_free(&asoc->outqueue); + list_splice_init(&temp, &asoc->outqueue.out_chunk_list); asoc->next_tsn = rtsn; asoc->ctsn_ack_point = asoc->next_tsn - 1;