Received: by 10.223.176.46 with SMTP id f43csp280259wra; Tue, 23 Jan 2018 20:57:54 -0800 (PST) X-Google-Smtp-Source: AH8x224b3mr7c1Z4oYWz/6/hOOepKIEL9s8M7EjTYTjM2sDHqFrHSJ2iULCKWcCNqI6n6MLzP5aC X-Received: by 10.98.161.16 with SMTP id b16mr11984873pff.34.1516769874448; Tue, 23 Jan 2018 20:57:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516769874; cv=none; d=google.com; s=arc-20160816; b=mThDjGkESEBrvGmIyYeBUrn3H7iQmbM441l3owUeoY60o/DNgBosEFVlzKgHHB0Ua1 NicnjJ0zjQDHUXgtZaC1bOVIv/trq+1X/7pCdApovrvA/P726FWmPnRVbSO5KZWFMknm RdRjk/Vu7qUWP0nn1282WM1bbXI1DyT8h61zuift8+ZURNNoVZo5vByWjD/TZ3sMcdVG EazjmFVNys66MDJgYAi3H3ifMLJXAnreRcux1KhlFvpzK3VU4TtmdNdaAjoZgZ7oUIAg rQ14UsYNs2jI1VOZ4qBJSoBWbpIYKQmFvl1DhXgBA3YbJj3g4XPu/8DSHoZp85pQkli2 iqTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=TeJv1m/yW6GXijYy95YHOF5KKccYS1seON2MgVC0zmQ=; b=UFLcATMakO4LAj2Mb2E/WSHOqY0B9EtRNqGdYQ6srLLpSWudHdB4G8AQYYqveMjA64 SidmCIDElBn0aZ8rAIzgishPFTuejZSv6d/7RF5DJ649+vYvpIxLMnXNU3LMLlv7sGT5 IMUq3eW49eh5Yuw6S5ZopRm2Y1EIUZ8qH36U3dN7xV/cHVbbxHeWaVXu7dlcOECif/br pIUNvOwlK83HrhHtgEDvRYQ2iQ80pO7lduRmMQ/brunm6WIGKWNpBkMI2XOYLNesNbYC 7M1fgIZqIQhzmWed8UxRANkdkKblXCq2Fx0EtTpQ1kTZCnUVjX117qvhAqGluGr2tUfs hVkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=VffDoxaP; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w18-v6si4357819pll.3.2018.01.23.20.57.40; Tue, 23 Jan 2018 20:57: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=@microsoft.com header.s=selector1 header.b=VffDoxaP; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932203AbeAXEPX (ORCPT + 99 others); Tue, 23 Jan 2018 23:15:23 -0500 Received: from mail-cys01nam02on0117.outbound.protection.outlook.com ([104.47.37.117]:59166 "EHLO NAM02-CY1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752848AbeAXEPT (ORCPT ); Tue, 23 Jan 2018 23:15:19 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=TeJv1m/yW6GXijYy95YHOF5KKccYS1seON2MgVC0zmQ=; b=VffDoxaPYdoXR49RK1Pn92EYCrP4aGmglkoHJuKeiVRRQ2Uw8OOWcn62LTzHkTGNqGpG6Prek6BqBzqSdXpdmOCrIblv2n1fxrg8Uo7angOL/vAzCfupCadtqxfQ8JgvoocZ9YC59ISJaanpfYzbxUsjZn8Vyas0ltk2T4VTHbo= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB1080.namprd21.prod.outlook.com (52.132.130.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.464.1; Wed, 24 Jan 2018 04:15:14 +0000 Received: from DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::6485:b98:d15e:9da7]) by DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::6485:b98:d15e:9da7%2]) with mapi id 15.20.0464.000; Wed, 24 Jan 2018 04:15:14 +0000 From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: Xin Long , "David S . Miller" , Sasha Levin Subject: [PATCH AUTOSEL for 4.14 044/100] sctp: avoid flushing unsent queue when doing asoc reset Thread-Topic: [PATCH AUTOSEL for 4.14 044/100] sctp: avoid flushing unsent queue when doing asoc reset Thread-Index: AQHTlMneabWPZB9GFkW5PvOegEP5vA== Date: Wed, 24 Jan 2018 04:14:46 +0000 Message-ID: <20180124041414.32065-44-alexander.levin@microsoft.com> References: <20180124041414.32065-1-alexander.levin@microsoft.com> In-Reply-To: <20180124041414.32065-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DM5PR2101MB1080;7:XW3xcV/xcSA5mHTgRnG4tZ84rlw7Zu2OYjabdPj2GmOeQSvVyRfivNpRh1y3LOfmKEFAb0aPHrVk+AefwOK2nXV2IgOXRnOwGZgt87G3adT71MOzNuywQIe3xsB0lnAnDmnYoZa5EhopQvp8rBpw9EsXMH87m83nUEJkGWEiz+dSP4RRfVQ+E+cM4IsO4IRFUQF5/Uf7puLDjT8QB+a7Zgg5Ucwd21B0oEFD1wNhzJ43zcBJRqupjjCIzOGIC/Re x-ms-office365-filtering-correlation-id: dcaac9d6-60e7-4f07-1acb-08d562e111d7 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(48565401081)(2017052603307)(7193020);SRVR:DM5PR2101MB1080; x-ms-traffictypediagnostic: DM5PR2101MB1080: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171)(85827821059158); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(61425038)(6040501)(2401047)(8121501046)(5005006)(3002001)(10201501046)(3231046)(2400081)(944501161)(93006095)(93001095)(6055026)(61426038)(61427038)(6041288)(20161123562045)(20161123558120)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011);SRVR:DM5PR2101MB1080;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB1080; x-forefront-prvs: 056297E276 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(376002)(396003)(346002)(39860400002)(39380400002)(366004)(189003)(199004)(72206003)(110136005)(316002)(5250100002)(6346003)(2900100001)(54906003)(1076002)(6116002)(3846002)(22452003)(36756003)(53936002)(99286004)(6512007)(68736007)(2501003)(3660700001)(14454004)(3280700002)(86362001)(102836004)(7736002)(5660300001)(305945005)(107886003)(6486002)(6506007)(2906002)(81156014)(26005)(25786009)(4326008)(81166006)(39060400002)(105586002)(8936002)(106356001)(478600001)(10290500003)(6436002)(8676002)(2950100002)(86612001)(97736004)(76176011)(6666003)(10090500001)(66066001)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB1080;H:DM5PR2101MB1032.namprd21.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-message-info: nMdp2LrcdU95j4VLS34DuruEcYIBjZvulvLbk/7eV+IhguBxK7yrqiiUtq+FGo3TVET0NvHU0ZflKnQWl0P+TQ== spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: dcaac9d6-60e7-4f07-1acb-08d562e111d7 X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Jan 2018 04:14:46.1482 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB1080 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- net/sctp/stream.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/net/sctp/stream.c b/net/sctp/stream.c index 7710133238ea..aa629654d27e 100644 --- a/net/sctp/stream.c +++ b/net/sctp/stream.c @@ -563,9 +563,10 @@ struct sctp_chunk *sctp_process_strreset_tsnreq( goto out; } =20 - /* 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 =3D 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_tsnreq( sctp_tsnmap_init(&asoc->peer.tsn_map, SCTP_TSN_MAP_INITIAL, init_tsn, GFP_ATOMIC); =20 - /* 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); =20 @@ -844,6 +844,7 @@ struct sctp_chunk *sctp_process_strreset_resp( if (result =3D=3D SCTP_STRRESET_PERFORMED) { __u32 mtsn =3D sctp_tsnmap_get_max_tsn_seen( &asoc->peer.tsn_map); + LIST_HEAD(temp); =20 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_resp( SCTP_TSN_MAP_INITIAL, stsn, GFP_ATOMIC); =20 + /* 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); =20 asoc->next_tsn =3D rtsn; asoc->ctsn_ack_point =3D asoc->next_tsn - 1; --=20 2.11.0