Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752253AbdHRVN3 (ORCPT ); Fri, 18 Aug 2017 17:13:29 -0400 Received: from mail-eopbgr1280095.outbound.protection.outlook.com ([40.107.128.95]:23772 "EHLO APC01-HK2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751350AbdHRVN1 (ORCPT ); Fri, 18 Aug 2017 17:13:27 -0400 From: Dexuan Cui To: Stefan Hajnoczi CC: "davem@davemloft.net" , "netdev@vger.kernel.org" , "devel@linuxdriverproject.org" , KY Srinivasan , "Haiyang Zhang" , Stephen Hemminger , George Zhang , Jorgen Hansen , Michal Kubecek , Vitaly Kuznetsov , Cathy Avery , "jasowang@redhat.com" , Rolf Neugebauer , Dave Scott , Marcelo Cerri , "apw@canonical.com" , "olaf@aepfle.de" , "joe@perches.com" , "linux-kernel@vger.kernel.org" , Dan Carpenter Subject: RE: [PATCH net-next 2/3] vsock: fix vsock_dequeue/enqueue_accept race Thread-Topic: [PATCH net-next 2/3] vsock: fix vsock_dequeue/enqueue_accept race Thread-Index: AdMWE/OcqyyawNZsSxaayApZ7QpUYgBTfVCAAEEBXPA= Date: Fri, 18 Aug 2017 21:13:05 +0000 Message-ID: References: <20170817140541.GH5539@stefanha-x1.localdomain> In-Reply-To: <20170817140541.GH5539@stefanha-x1.localdomain> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Enabled=True; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SiteId=72f988bf-86f1-41af-91ab-2d7cd011db47; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Ref=https://api.informationprotection.azure.com/api/72f988bf-86f1-41af-91ab-2d7cd011db47; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Owner=decui@microsoft.com; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SetDate=2017-08-18T14:13:03.3254114-07:00; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Name=General; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Application=Microsoft Azure Information Protection; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Extended_MSFT_Method=Automatic; Sensitivity=General authentication-results: spf=none (sender IP is ) smtp.mailfrom=decui@microsoft.com; x-originating-ip: [167.220.1.87] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;KL1P15301MB0037;6:lYMv+ImvRL2oDX92PsJSOJlx/PohrxUTou+KN/H9rop8eX+D98Fnc5OqZgdvxRsE5J//AYjjQAIzvoNa8CFS+Wx/czPzEbgol+8uvocbWwLRJZr+M2z2HllTaF2GWiVEuokGlZ3ZH0SjbQFfl6kt0Z2eo7KwmGbnzrmMNwZdprw6ObCY0lyIWfR9hRzt+R737ZTMe0g9ootrsXGljt2iZI50AgACWGz4zysdBhZ/YXyGiT081AdPSlH0UmX8tXl/uLJZX8qvEWFnEYqrkmBBLI34hw1WW0EYmKjLQ55UZEDWIuNgNE53rhHUSVamqDTS5CeDzg4v7yBcDxbON6dBeA==;5:zR7JdCyGL7NiFIhjNlQsvRUj1v9+aXGRvWXxDDUrNS/5zFr/rp78N7DFxYEYitpBLwMXrjDVsakiUJN0la4RgYWINcqKNJp1z87y9vZEDdn0nvWKUwbQ3+h43YCmihIZmxouSJChEPBJdjPd1fabpg==;24:Rj4W/VS2GkdK11sbVwE5rWfz06XDRlESDOPSOpBajwR0X7EvJr25735FvhoEyuEch29HLt5hFhce+NfxSVRpg7SmpFa7smzDLNLvgGmV66k=;7:gajEni2WpQ+A0NbUUAjXCzq7F/wFoiJLeN4Uia791R9WKDZf5AhukLs6PRo1AQWpengpOihYeotRicHkqSwAvIWAucCBPvQ3aO0cpalge3BYpKi9J9uicYRND3ER/oRS5zT77qzL9jVrk441FWuY7KQoll5JR9RxBIKun8YoyTsuDnQKf0DWPzsYAoOvu+38MuUxKuSXgQVyP0ENh3uDW5bfiPZNnkb2kU7BxWsTvMc= x-ms-office365-filtering-correlation-id: 494008a5-b255-4131-4ef2-08d4e67deb4c x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(48565401081)(300000503095)(300135400095)(2017052603031)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095);SRVR:KL1P15301MB0037; x-ms-traffictypediagnostic: KL1P15301MB0037: x-exchange-antispam-report-test: UriScan:; x-microsoft-antispam-prvs: x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(61425038)(6040450)(2401047)(8121501046)(5005006)(3002001)(93006095)(93001095)(100000703101)(100105400095)(10201501046)(6055026)(61426038)(61427038)(6041248)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(20161123555025)(20161123564025)(20161123560025)(20161123558100)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:KL1P15301MB0037;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:KL1P15301MB0037; x-forefront-prvs: 040359335D x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(6009001)(39860400002)(47760400005)(24454002)(189002)(199003)(54906002)(66066001)(101416001)(110136004)(478600001)(10290500003)(74316002)(7696004)(55016002)(305945005)(8936002)(10090500001)(189998001)(106356001)(105586002)(68736007)(229853002)(53936002)(25786009)(6246003)(6116002)(102836003)(3846002)(9686003)(7416002)(86612001)(81156014)(81166006)(54356999)(4326008)(77096006)(8676002)(76176999)(33656002)(6916009)(50986999)(6506006)(5005710100001)(2950100002)(3660700001)(3280700002)(7736002)(2906002)(6436002)(8990500004)(14454004)(5660300001)(97736004)(86362001)(2900100001);DIR:OUT;SFP:1102;SCL:1;SRVR:KL1P15301MB0037;H:KL1P15301MB0008.APCP153.PROD.OUTLOOK.COM;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Aug 2017 21:13:05.1323 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: KL1P15301MB0037 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by nfs id v7ILDj3g030706 Content-Length: 892 Lines: 22 > From: Stefan Hajnoczi [mailto:stefanha@redhat.com] > Sent: Thursday, August 17, 2017 07:06 > > On Tue, Aug 15, 2017 at 10:15:39PM +0000, Dexuan Cui wrote: > > With the current code, when vsock_dequeue_accept() is removing a sock > > from the list, nothing prevents vsock_enqueue_accept() from adding a new > > sock into the list concurrently. We should add a lock to protect the list. > > The listener sock is locked, preventing concurrent modification. I have > checked both the virtio and vmci transports. Can you post an example > where the listener sock isn't locked? > > Stefan Sorry, I was not careful when checking the vmci code. Please ignore the patch. Now I realized the expectation is that the individual transport drivers should do the locking for vsock_enqueue_accept(), but for vsock_dequeue_accept(), the locking is done by the common vsock driver. Thanks, -- Dexuan