Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753859AbdHRAiN (ORCPT ); Thu, 17 Aug 2017 20:38:13 -0400 Received: from mail-pu1apc01on0104.outbound.protection.outlook.com ([104.47.126.104]:58880 "EHLO APC01-PU1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753342AbdHRAiL (ORCPT ); Thu, 17 Aug 2017 20:38:11 -0400 From: Dexuan Cui To: "Jorgen S. Hansen" , "davem@davemloft.net" CC: "netdev@vger.kernel.org" , "gregkh@linuxfoundation.org" , "devel@linuxdriverproject.org" , KY Srinivasan , Haiyang Zhang , "Stephen Hemminger" , George Zhang , Michal Kubecek , Stefan Hajnoczi , 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/OcqyyawNZsSxaayApZ7QpUYgBQnVgAABiHcQA= Date: Fri, 18 Aug 2017 00:37:47 +0000 Message-ID: References: In-Reply-To: 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-17T17:37:45.6563452-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.201] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;KL1P15301MB0088;6:XnWlhCeDiDjE7l+3pz3D9KBZtboubW7eUMDlA4WM23ETaLRgkyMrDDVU9Bf0RHEUeHVaNoKS+4uvzxuuI8TKVfDgfiz/2O7gRjsH6MyxfgnDj6OPkS+8ZZ/rrqdokctCNw+EVnIbiRpZJWDuKQWBLGN84kgvmVweSLnjDROTR6xrJgMLzTUA0u3fXqGzY3EFoCI7R7TbYm/kvngrPPlqULQbuEDoCt1gYeGix8M3qKvXkHA9+5SeI3clRQDTOaEfmxb25/P12nSmP3rKUobqrdERHwki0Tq993vYpxWybAUG7e6Je+/SLysZ7VcqAY2cUX6yMkps1qWeayRfUqMZbA==;5:b+3puyJeyI7DunoNMsNUfWpfg8CDvgQXOv06iuR7Wha9SoF5xUE+6iz497Ys/2MOpQSy6WAHkXu0fZr37pR+NtCjdjwWCnTlh8FXn/rAmjV4oafUBs9riYuqQEUR2XppVeRHsToVpDtNwow++SN5Qg==;24:0ax5ugpfS710BbBBDQpfT8/6wOhceU44O8gfh9TtVf4r036eIIZQcsx8YFDy3aH59WILr6pJGDPxHZCKjTk2OMj2i2byh3pgjHUYTCiIp9c=;7:NmFOZ3HyupGM00ztyzbb8W6L3xxxdvotmTdffIUOEihtKDv0PjcyStiL/dUhR02SRgufHageInIMm2qORC2Xwa5EJKGOi0jHFBaZn5/QF81iStQZnBjv3PS+nx3CJFNbJ9cUf7EguUwhK5K90RTtxhbq6CfAGg7mF7znZEg9hJb6mVC5TJS09NJYxFpoY9Fm2ALrEmWh2i7J/cEyYrEksvCduS4S6w4SloRmFTPNlrA= x-ms-office365-filtering-correlation-id: e8bc3e27-9835-4154-95c6-08d4e5d159c8 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:KL1P15301MB0088; x-ms-traffictypediagnostic: KL1P15301MB0088: x-exchange-antispam-report-test: UriScan:(89211679590171); x-microsoft-antispam-prvs: x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(61425038)(6040450)(2401047)(5005006)(8121501046)(3002001)(10201501046)(93006095)(93001095)(100000703101)(100105400095)(6055026)(61426038)(61427038)(6041248)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123555025)(20161123562025)(20161123564025)(20161123558100)(20161123560025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:KL1P15301MB0088;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:KL1P15301MB0088; x-forefront-prvs: 040359335D x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(6009001)(47760400005)(24454002)(189002)(199003)(377454003)(10090500001)(68736007)(54906002)(33656002)(53546010)(478600001)(14454004)(10290500003)(76176999)(4326008)(54356999)(2906002)(50986999)(101416001)(5660300001)(7696004)(25786009)(2950100002)(6246003)(3280700002)(7416002)(9686003)(74316002)(229853002)(3660700001)(106356001)(105586002)(53936002)(77096006)(2900100001)(189998001)(66066001)(6116002)(97736004)(8936002)(3846002)(102836003)(305945005)(5005710100001)(8990500004)(8676002)(81156014)(7736002)(81166006)(6506006)(6436002)(86362001)(55016002)(86612001)(2501003);DIR:OUT;SFP:1102;SCL:1;SRVR:KL1P15301MB0088;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 00:37:47.5669 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: KL1P15301MB0088 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 v7I0cKJH016432 Content-Length: 966 Lines: 22 > > On Aug 16, 2017, at 12:15 AM, 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. > > For the VMCI socket transport, we always lock the sockets before calling into > vsock_enqueue_accept and af_vsock.c locks the socket before calling > vsock_dequeue_accept, so from our point of view these operations are already > protected, but with finer granularity than a single global lock. As far as I can see, > the virtio transport also locks the socket before calling vsock_enqueue_accept, > so they should be fine with the current version as well, but Stefan can comment > on that. > > Jorgen Hi Jorgen, Thanks, you're correct. Please ignore this patch. I'll update the hv_sock driver to add proper lock_sock()/relesae_sock(). Thanks, -- Dexuan